From bc05ea82da290d3845a9f0abba0e3f186dbf2f76 Mon Sep 17 00:00:00 2001 From: sanj Date: Sat, 20 Nov 2010 19:43:49 +0530 Subject: [PATCH] comments done right --- COPYING | 14 ++++++ itf/erang_organised/models.py | 17 +++++++ itf/erang_organised/views.py | 5 +- itf/festival/views.py | 2 +- itf/settings.py | 2 + itf/static/css/erang/comments.css | 52 +++++++++++++++++++++ itf/static/css/erang/erang.css | 4 ++ itf/templates/erang/home.html | 78 ++++++++++++++++++++++--------- itf/templates/resources.html | 2 +- itf/urls.py | 1 + 10 files changed, 152 insertions(+), 25 deletions(-) create mode 100644 COPYING create mode 100644 itf/static/css/erang/comments.css diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..c97633a --- /dev/null +++ b/COPYING @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2010 Sanjay Bhangar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/itf/erang_organised/models.py b/itf/erang_organised/models.py index 0f684e1..d2f9864 100644 --- a/itf/erang_organised/models.py +++ b/itf/erang_organised/models.py @@ -1,4 +1,6 @@ from django.db import models +from django.contrib.comments.signals import comment_was_posted + class Issue(models.Model): title = models.CharField(max_length=255) @@ -18,3 +20,18 @@ class Issue(models.Model): } # Create your models here. + +def comments_notify(sender, **kwargs): + comment = kwargs['comment'] + name = comment.name + email = comment.email + content = comment.comment + erang_id = comment.content_object.id + comment_id = comment.id + url = "http://theatreforum.in/erang/?issue_id=%d" % (img_id) + admin_url = "http://theatreforum.in/admin/comments/comment/%d/" % (comment_id) + message = "Page: %s \n Name: %s \n Email: %s \n Comment: %s\n\n Moderate: %s" % (url, name, email, content, admin_url) + send_mail("New comment on E-Rang", message, "do_not_reply@theatreforum.in", ["erang@theatreforum.in", "sanjaybhangar@gmail.com", "sharvari@theatreforum.in"]) + return True + +comment_was_posted.connect(comments_notify) diff --git a/itf/erang_organised/views.py b/itf/erang_organised/views.py index aea6cee..52dbbd6 100644 --- a/itf/erang_organised/views.py +++ b/itf/erang_organised/views.py @@ -8,6 +8,7 @@ from django.core.mail import send_mail from django.db.models import Q from oxdjango.shortcuts import render_to_json_response from django.core.paginator import Paginator, InvalidPage, EmptyPage +from django.template import RequestContext RESULTS_PER_PAGE = 6 @@ -21,10 +22,12 @@ def home(request): issue_id = all_issues[0].id current_issue = Issue.objects.get(pk=issue_id) other_issues = all_issues.exclude(pk=issue_id) + hasCommented = request.GET.has_key('c') return render_to_response("erang/home.html", { 'current_issue': current_issue, + 'hasCommented': hasCommented # 'past_issues': other_issues - }) + }, context_instance=RequestContext(request)) def issue_list(request): p = RESULTS_PER_PAGE diff --git a/itf/festival/views.py b/itf/festival/views.py index a22c48c..4017579 100644 --- a/itf/festival/views.py +++ b/itf/festival/views.py @@ -130,7 +130,7 @@ def projects(request): return render_to_response("projects.html", {'projects': projects}) def resources(request): - resources = Document.objects.filter(is_resource=True) + resources = Document.objects.filter(is_resource=True).order_by('title') return render_to_response("resources.html", {'resources': resources}) def people(request): diff --git a/itf/settings.py b/itf/settings.py index 7afa0c7..dda7b1b 100644 --- a/itf/settings.py +++ b/itf/settings.py @@ -89,6 +89,7 @@ TEMPLATE_LOADERS = ( ) MIDDLEWARE_CLASSES = ( + 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', @@ -116,6 +117,7 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', + 'django.contrib.comments', 'itfcore', 'festival', 'erang_organised', diff --git a/itf/static/css/erang/comments.css b/itf/static/css/erang/comments.css new file mode 100644 index 0000000..f3ded6a --- /dev/null +++ b/itf/static/css/erang/comments.css @@ -0,0 +1,52 @@ +#commentWrapper { + width: 80%; + margin-left: auto; + margin-right: auto; +} + +#commentWrapper h3 { + text-align: center; + font-family: "Times", "Times New Roman", serif; + font-size: 1.2em; + text-shadow: #bbb 5px 3px 1px; + margin-bottom: 8px; + +} + +h4.formHeader { + text-align: center; + font-family: "Times", "Times New Roman", serif; + font-size: 1em; + margin-bottom: 0px; + text-shadow: #bbb 3px 2px 1px; + margin-bottom: 8px; +} + +.comment { + padding-bottom: 6px; +} + +.comment_user { + font-weight: bold; + margin-left: 12px; + font-family: "Times", "Times New Roman", serif; +} + +.comment_comment { + margin-left: 24px; + font-family: "DejaVu Sans", Arial, Verdana, sans-serif; +} + +.commentOdd { + background: #FFFBCE; +} + +.commentEven { + background: #CAE9E7; +} + +#form_table th { + text-align: right; + font-family: "Times", "Times New Roman", serif; + font-size: 1em; +} diff --git a/itf/static/css/erang/erang.css b/itf/static/css/erang/erang.css index d188140..bb8f51f 100644 --- a/itf/static/css/erang/erang.css +++ b/itf/static/css/erang/erang.css @@ -52,6 +52,10 @@ height: 250px; } + .currentIssue { + color: #640000 !important; + } + .newsletterList a { text-decoration: none; color: #666; diff --git a/itf/templates/erang/home.html b/itf/templates/erang/home.html index 2020320..1c3a589 100644 --- a/itf/templates/erang/home.html +++ b/itf/templates/erang/home.html @@ -3,16 +3,23 @@ {% block head %} India Theatre Forum - {{ current_issue.title }} + + {% endblock %} {% block body %}