it/itf/erang_organised/views.py

45 lines
1.2 KiB
Python
Raw Normal View History

2010-08-01 21:50:16 +00:00
# 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):
2010-10-21 16:51:01 +00:00
all_issues = Issue.objects.all().order_by('-date')
2010-08-01 21:50:16 +00:00
if request.GET.has_key('issue_id'):
issue_id = request.GET.get('issue_id')
else:
2010-10-23 15:30:51 +00:00
# l = 0
issue_id = all_issues[0].id
2010-08-01 21:50:16 +00:00
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")
2010-08-01 22:05:46 +00:00
comment = p.get("comment")
2010-08-01 21:50:16 +00:00
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', 'erang@theatreforum.in'])
2010-08-01 21:50:16 +00:00
return HttpResponse("1")