45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
# 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:
|
|
# l = 0
|
|
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("comment")
|
|
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'])
|
|
return HttpResponse("1")
|