From 21a5b5aafd25a996530e2575b32fca7a0ccac30d Mon Sep 17 00:00:00 2001 From: Kriti Godey Date: Thu, 18 Mar 2010 16:22:15 -0400 Subject: [PATCH] Comments fully integrated. --- templates/comments/400-debug.html | 53 +++++++++++++++++ templates/comments/approve.html | 15 +++++ templates/comments/approved.html | 8 +++ templates/comments/base.html | 45 ++++++++++++++ templates/comments/delete.html | 15 +++++ templates/comments/deleted.html | 8 +++ templates/comments/flag.html | 15 +++++ templates/comments/flagged.html | 8 +++ templates/comments/form.html | 20 +++++++ templates/comments/moderation_queue.html | 75 ++++++++++++++++++++++++ templates/comments/posted.html | 8 +++ templates/comments/preview.html | 36 ++++++++++++ templates/onesandwich.html | 1 + urls.py | 1 + views.py | 10 ++++ 15 files changed, 318 insertions(+) create mode 100644 templates/comments/400-debug.html create mode 100644 templates/comments/approve.html create mode 100644 templates/comments/approved.html create mode 100644 templates/comments/base.html create mode 100644 templates/comments/delete.html create mode 100644 templates/comments/deleted.html create mode 100644 templates/comments/flag.html create mode 100644 templates/comments/flagged.html create mode 100644 templates/comments/form.html create mode 100644 templates/comments/moderation_queue.html create mode 100644 templates/comments/posted.html create mode 100644 templates/comments/preview.html diff --git a/templates/comments/400-debug.html b/templates/comments/400-debug.html new file mode 100644 index 0000000..3c4532b --- /dev/null +++ b/templates/comments/400-debug.html @@ -0,0 +1,53 @@ + + + + + Comment post not allowed (400) + + + + +
+

Comment post not allowed (400)

+ + + + + +
Why:{{ why }}
+
+
+

+ The comment you tried to post to this view wasn't saved because something + tampered with the security information in the comment form. The message + above should explain the problem, or you can check the comment + documentation for more help. +

+
+ +
+

+ You're seeing this error because you have DEBUG = True in + your Django settings file. Change that to False, and Django + will display a standard 400 error page. +

+
+ + diff --git a/templates/comments/approve.html b/templates/comments/approve.html new file mode 100644 index 0000000..a4306a6 --- /dev/null +++ b/templates/comments/approve.html @@ -0,0 +1,15 @@ +{% extends "comments/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Approve a comment" %}{% endblock %} + +{% block content %} +

{% trans "Really make this comment public?" %}

+
{{ comment|linebreaks }}
+
+ {% if next %}{% endif %} +

+ or cancel +

+
+{% endblock %} diff --git a/templates/comments/approved.html b/templates/comments/approved.html new file mode 100644 index 0000000..d4ba245 --- /dev/null +++ b/templates/comments/approved.html @@ -0,0 +1,8 @@ +{% extends "comments/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Thanks for approving" %}.{% endblock %} + +{% block content %} +

{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.

+{% endblock %} diff --git a/templates/comments/base.html b/templates/comments/base.html new file mode 100644 index 0000000..dd6dc3e --- /dev/null +++ b/templates/comments/base.html @@ -0,0 +1,45 @@ + + + + {% block title %}Ma'ayanwich Tracker{% endblock %} + {% block extrahead %}{% endblock %} + + +
+ + +
+ {% block content %} + {% endblock %} +
+
+ + \ No newline at end of file diff --git a/templates/comments/delete.html b/templates/comments/delete.html new file mode 100644 index 0000000..7d73eac --- /dev/null +++ b/templates/comments/delete.html @@ -0,0 +1,15 @@ +{% extends "comments/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Remove a comment" %}{% endblock %} + +{% block content %} +

{% trans "Really remove this comment?" %}

+
{{ comment|linebreaks }}
+
+ {% if next %}{% endif %} +

+ or cancel +

+
+{% endblock %} diff --git a/templates/comments/deleted.html b/templates/comments/deleted.html new file mode 100644 index 0000000..e608481 --- /dev/null +++ b/templates/comments/deleted.html @@ -0,0 +1,8 @@ +{% extends "comments/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Thanks for removing" %}.{% endblock %} + +{% block content %} +

{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.

+{% endblock %} diff --git a/templates/comments/flag.html b/templates/comments/flag.html new file mode 100644 index 0000000..08dbe0b --- /dev/null +++ b/templates/comments/flag.html @@ -0,0 +1,15 @@ +{% extends "comments/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Flag this comment" %}{% endblock %} + +{% block content %} +

{% trans "Really flag this comment?" %}

+
{{ comment|linebreaks }}
+
+ {% if next %}{% endif %} +

+ or cancel +

+
+{% endblock %} diff --git a/templates/comments/flagged.html b/templates/comments/flagged.html new file mode 100644 index 0000000..e558019 --- /dev/null +++ b/templates/comments/flagged.html @@ -0,0 +1,8 @@ +{% extends "comments/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Thanks for flagging" %}.{% endblock %} + +{% block content %} +

{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.

+{% endblock %} diff --git a/templates/comments/form.html b/templates/comments/form.html new file mode 100644 index 0000000..73b306d --- /dev/null +++ b/templates/comments/form.html @@ -0,0 +1,20 @@ +{% load comments i18n %} +
+ {% if next %}{% endif %} + {% for field in form %} + {% if field.is_hidden %} + {{ field }} + {% else %} + {% if field.errors %}{{ field.errors }}{% endif %} + + {% endif %} + {% endfor %} +

+ + +

+
diff --git a/templates/comments/moderation_queue.html b/templates/comments/moderation_queue.html new file mode 100644 index 0000000..73012b3 --- /dev/null +++ b/templates/comments/moderation_queue.html @@ -0,0 +1,75 @@ +{% extends "admin/change_list.html" %} +{% load adminmedia i18n %} + +{% block title %}{% trans "Comment moderation queue" %}{% endblock %} + +{% block extrahead %} + {{ block.super }} + +{% endblock %} + +{% block branding %} +

{% trans "Comment moderation queue" %}

+{% endblock %} + +{% block breadcrumbs %}{% endblock %} + +{% block content %} +{% if empty %} +

{% trans "No comments to moderate" %}.

+{% else %} +
+
+ + + + + + + + + + + + + + + {% for comment in comments %} + + + + + + + + + + + {% endfor %} + +
{% trans "Action" %}{% trans "Name" %}{% trans "Comment" %}{% trans "Email" %}{% trans "URL" %}{% trans "Authenticated?" %}{% trans "IP Address" %}{% trans "Date posted" %}
+
+ + +
+
+ + +
+
{{ comment.name }}{{ comment.comment|truncatewords:"50" }}{{ comment.email }}{{ comment.url }} + {% if comment.user %}{% trans + {{ comment.ip_address }}{{ comment.submit_date|date:"F j, P" }}
+
+
+{% endif %} +{% endblock %} diff --git a/templates/comments/posted.html b/templates/comments/posted.html new file mode 100644 index 0000000..76f7f6d --- /dev/null +++ b/templates/comments/posted.html @@ -0,0 +1,8 @@ +{% extends "comments/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Thanks for commenting" %}.{% endblock %} + +{% block content %} +

{% trans "Thank you for your comment" %}.

+{% endblock %} diff --git a/templates/comments/preview.html b/templates/comments/preview.html new file mode 100644 index 0000000..d388457 --- /dev/null +++ b/templates/comments/preview.html @@ -0,0 +1,36 @@ +{% extends "comments/base.html" %} +{% load i18n %} + +{% block title %}{% trans "Preview your comment" %}{% endblock %} + +{% block content %} + {% load comments %} +
+ {% if next %}{% endif %} + {% if form.errors %} +

{% blocktrans count form.errors|length as counter %}Please correct the error below{% plural %}Please correct the errors below{% endblocktrans %}

+ {% else %} +

{% trans "Preview your comment" %}

+
{{ comment|linebreaks }}
+

+ {% trans "and" %} {% trans "or make changes" %}: +

+ {% endif %} + {% for field in form %} + {% if field.is_hidden %} + {{ field }} + {% else %} + {% if field.errors %}{{ field.errors }}{% endif %} + + {% endif %} + {% endfor %} +

+ + +

+
+{% endblock %} diff --git a/templates/onesandwich.html b/templates/onesandwich.html index 60ea42b..e1654fa 100644 --- a/templates/onesandwich.html +++ b/templates/onesandwich.html @@ -36,6 +36,7 @@

{{ comment.comment }}

{{ comment.submit_date }}

{% endfor %} +

Add a Comment

{% render_comment_form for s %} {% endblock %} \ No newline at end of file diff --git a/urls.py b/urls.py index 628eb02..9eefa92 100644 --- a/urls.py +++ b/urls.py @@ -13,6 +13,7 @@ urlpatterns = patterns('', url(r'^logout/$', views.logout_view, name='logout'), url(r'^signup/$', views.create_user, name='signup'), url(r'^ajaxfun', views.ajaxfun, name='ajaxfun'), + url(r'^comments/posted/$', views.comment_posted, name='comment_posted'), (r'^comments/', include('django.contrib.comments.urls')), url(r'^home/$', views.current_home, name='index'), ) diff --git a/views.py b/views.py index 39ec141..d653118 100644 --- a/views.py +++ b/views.py @@ -6,6 +6,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile from models import Sandwich, Ingredient from django.contrib.auth import authenticate, login, logout from django.contrib.auth.forms import AuthenticationForm +from django.contrib.comments.models import Comment from django.template import RequestContext from django.core import serializers from slugify import SlugifyUniquely @@ -193,6 +194,15 @@ def create_user(request): else: form = NewUserForm() # An unbound form return render_to_response('newuser.html', {'cform': form,}, context_instance=RequestContext(request)) + + +def comment_posted(request): + if request.GET['c']: + comment_id = request.GET['c'] + com = Comment.objects.get( pk = comment_id ) + post = com.content_object + if post: + return HttpResponseRedirect( post.get_absolute_url() + '#comments' ) def ajaxfun(request): -- 2.20.1