comments done right

This commit is contained in:
sanj 2010-11-20 19:43:49 +05:30
parent 50944b7ccd
commit bc05ea82da
10 changed files with 152 additions and 25 deletions

14
COPYING Normal file
View File

@ -0,0 +1,14 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2010 Sanjay Bhangar <sanjay@camputer.org>
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.

View File

@ -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)

View File

@ -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

View File

@ -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):

View File

@ -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',

View File

@ -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;
}

View File

@ -52,6 +52,10 @@
height: 250px;
}
.currentIssue {
color: #640000 !important;
}
.newsletterList a {
text-decoration: none;
color: #666;

View File

@ -3,16 +3,23 @@
{% block head %}
<title>India Theatre Forum - {{ current_issue.title }}</title>
<script type="text/javascript" src="/static/js/utils.js"></script>
<script type="text/javascript">
var ERANG_ISSUE_ID = {{ current_issue.id }};
</script>
<script type="text/javascript" src="/static/js/erang/erang.js"></script>
<link rel="stylesheet" href="/static/css/erang/erang.css" />
<link rel="stylesheet" href="/static/css/erang/comments.css" />
{% endblock %}
{% block body %}
<script type="text/html" id="tmpl_issue_list">
<ul class="newsletterList">
<% for (var i=0; i<issues.length; i++) { var issue = issues[i]; %>
<% for (var i=0; i<issues.length; i++) {
var issue = issues[i];
if (issue.id === ERANG_ISSUE_ID) { var classname="currentIssue" } else { var classname="otherIssue"}
%>
<li>
<a href="?issue_id=<%= issue.id %>"><%= issue.title %></a>
<a href="?issue_id=<%= issue.id %>" class="<%= classname %>"><%= issue.title %></a>
<br />
<span class="date"></span>
</li>
@ -52,28 +59,55 @@
{{ current_issue.html|absolutify_links }}
{% endautoescape %}
<div id="commentWrapper">
{% load comments %}
<h3>Comments and Feedback</h3>
<a name="comments"></a>
<form id="commentForm" action="">
<table id="commentTable">
<tr>
<td class="label">Name:</td>
<td><input name="commentName" id="commentName" /></td>
{% get_comment_list for erang_organised.issue current_issue.id as comment_list %}
{% ifnotequal comment_list|length 0 %}
<div id="comments_list">
<!--
<h4 class="responsesHeader">
Responses:
</h4>
-->
{% for comment in comment_list %}
<div class="comment {% cycle 'commentOdd' 'commentEven' %}">
<div class="comment_user">
{{ comment.user_name }}:
</div>
<div class="comment_comment">
{{ comment.comment }}
</div>
</div>
{% endfor %}
</div>
{% endifnotequal %}
{% get_comment_form for current_issue as form %}
<div id="comment_form">
<h4 class="formHeader">
Leave a Response:
</h4>
<form action="{% comment_form_target %}" method="POST">{% csrf_token %}
<input type="hidden" name="next" value="/erang/?issue_id={{ current_issue.id }}" />
<table id="form_table">
<tr class="leave_response">
<th></th>
<td>
</td>
</tr>
{{ form }}
<tr>
<td class="label">Email:</td>
<td><input name="commentEmail" id="commentEmail" /></td>
</tr>
<tr>
<td class="label">Comment:</td>
<td><textarea name="commentComment" id="commentComment"></textarea></td>
</tr>
<tr>
<td class="label"></td>
<td><button id="commentSubmit">Submit</button></td>
<th></th>
<td><input type="submit" name="post" class="submit-post" value="Post"></td>
</tr>
</table>
</form>
</div>
</div>
</div>
{% endblock %}

View File

@ -26,7 +26,7 @@
{% for r in resources %}
<div class="objWrapper">
<div class="titleLink">
<a href="/static/{{r.file}}">{{ r.title }}</a>
<a href="/static/{{r.file}}" target="_blank">{{ r.title }}</a>
</div>
<div class="intro">
{{ r.intro }}

View File

@ -13,6 +13,7 @@ urlpatterns = patterns('',
# Example:
# (r'^bhangar/', include('bhangar.foo.urls')),
#(r'^search/', include('solango.urls')),
(r'^comments/', include('django.contrib.comments.urls')),
(r'^robots.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text/plain'}),
(r'^erang/', include('erang_organised.urls')),
(r'^itf/$', 'festival.views.home'),