From 81606986e8f00a5b3c70f01e526518c53d532abf Mon Sep 17 00:00:00 2001 From: sanj Date: Mon, 2 Aug 2010 03:20:16 +0530 Subject: [PATCH] added erang_organised --- itf/erang_organised/__init__.py | 0 itf/erang_organised/admin.py | 13 +++ itf/erang_organised/models.py | 10 +++ itf/erang_organised/tests.py | 23 ++++++ itf/erang_organised/urls.py | 11 +++ itf/erang_organised/views.py | 43 ++++++++++ itf/settings.py | 2 +- itf/templates/erang/home.html | 135 ++++++++++++++++++++++++++++++++ 8 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 itf/erang_organised/__init__.py create mode 100644 itf/erang_organised/admin.py create mode 100644 itf/erang_organised/models.py create mode 100644 itf/erang_organised/tests.py create mode 100644 itf/erang_organised/urls.py create mode 100644 itf/erang_organised/views.py create mode 100644 itf/templates/erang/home.html diff --git a/itf/erang_organised/__init__.py b/itf/erang_organised/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/itf/erang_organised/admin.py b/itf/erang_organised/admin.py new file mode 100644 index 0000000..bc64e49 --- /dev/null +++ b/itf/erang_organised/admin.py @@ -0,0 +1,13 @@ +from django.contrib import admin +from models import * +# from forms import ArticleForm + + + +class IssueAdmin(admin.ModelAdmin): + list_display = ('title', 'date',) + + +admin.site.register(Issue, IssueAdmin) + + diff --git a/itf/erang_organised/models.py b/itf/erang_organised/models.py new file mode 100644 index 0000000..21241e3 --- /dev/null +++ b/itf/erang_organised/models.py @@ -0,0 +1,10 @@ +from django.db import models + +class Issue(models.Model): + title = models.CharField(max_length=255) + date = models.DateField() + html = models.TextField(blank=True) + + + +# Create your models here. diff --git a/itf/erang_organised/tests.py b/itf/erang_organised/tests.py new file mode 100644 index 0000000..2247054 --- /dev/null +++ b/itf/erang_organised/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/itf/erang_organised/urls.py b/itf/erang_organised/urls.py new file mode 100644 index 0000000..73ef3db --- /dev/null +++ b/itf/erang_organised/urls.py @@ -0,0 +1,11 @@ +from django.conf.urls.defaults import * +import views + +urlpatterns = patterns('', + # Example: + # (r'^bhangar/', include('bhangar.foo.urls')), + #(r'^search/', include('solango.urls')), + (r'^$', views.home), + (r'^subscribe/$', views.subscribe), + (r'^postfeedback/$', views.postfeedback) +) diff --git a/itf/erang_organised/views.py b/itf/erang_organised/views.py new file mode 100644 index 0000000..0801bd4 --- /dev/null +++ b/itf/erang_organised/views.py @@ -0,0 +1,43 @@ +# Create your views here. +from django.shortcuts import render_to_response +from models import Issue +from settings import ERANG_SUBSCRIBE_URL +import urllib2 +from django.http import HttpResponse +from django.core.mail import send_mail + +def home(request): + all_issues = Issue.objects.all().order_by('-date') + if request.GET.has_key('issue_id'): + issue_id = request.GET.get('issue_id') + else: + issue_id = all_issues[0].id + current_issue = Issue.objects.get(pk=issue_id) + other_issues = all_issues.exclude(pk=issue_id) + return render_to_response("erang/home.html", { + 'current_issue': current_issue, + 'past_issues': other_issues + }) + +def subscribe(request): + email = request.POST.get("email") + url = ERANG_SUBSCRIBE_URL + email + re = urllib2.urlopen(url).read() + return HttpResponse(re) + + +def postfeedback(request): + p = request.POST + issue = p.get("issue") + name = p.get("name") + email = p.get("email") + comment = p.get("feedback") + txt = """ + Feedback on Issue: %s + + Name: %s + Email: %s + Feedback %s + """ % (issue, name, email, comment,) + send_mail("eRang Feedback", txt, "do-not-reply@theatreforum.in", ['sanjaybhangar@gmail.com']) + return HttpResponse("1") diff --git a/itf/settings.py b/itf/settings.py index cb8b419..0c7763a 100644 --- a/itf/settings.py +++ b/itf/settings.py @@ -116,7 +116,7 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'itfcore', 'festival', - 'erang', + 'erang_organised', # 'solango', 'multilingual', # 'multilingual.flatpages', diff --git a/itf/templates/erang/home.html b/itf/templates/erang/home.html new file mode 100644 index 0000000..eeb6d48 --- /dev/null +++ b/itf/templates/erang/home.html @@ -0,0 +1,135 @@ +{% extends 'base.html' %} + +{% block head %} +{{ current_issue.title }} + + +{% endblock %} + +{% block body %} +
+

Past Issues:

+ +
+

Subscribe:

+
+
+ +
+
+
+
+ {% autoescape off %} + {{ current_issue.html }} + {% endautoescape %} +
+ +
+ + + + + + + + + + + + + + + + + +
Name:
Email:
Feedback:
+
+
+
+{% endblock %}