Comments fully integrated.
authorKriti Godey <kriti.godey@gmail.com>
Thu, 18 Mar 2010 20:22:15 +0000 (16:22 -0400)
committerKriti Godey <kriti.godey@gmail.com>
Thu, 18 Mar 2010 20:22:15 +0000 (16:22 -0400)
15 files changed:
templates/comments/400-debug.html [new file with mode: 0644]
templates/comments/approve.html [new file with mode: 0644]
templates/comments/approved.html [new file with mode: 0644]
templates/comments/base.html [new file with mode: 0644]
templates/comments/delete.html [new file with mode: 0644]
templates/comments/deleted.html [new file with mode: 0644]
templates/comments/flag.html [new file with mode: 0644]
templates/comments/flagged.html [new file with mode: 0644]
templates/comments/form.html [new file with mode: 0644]
templates/comments/moderation_queue.html [new file with mode: 0644]
templates/comments/posted.html [new file with mode: 0644]
templates/comments/preview.html [new file with mode: 0644]
templates/onesandwich.html
urls.py
views.py

diff --git a/templates/comments/400-debug.html b/templates/comments/400-debug.html
new file mode 100644 (file)
index 0000000..3c4532b
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+  <title>Comment post not allowed (400)</title>
+  <meta name="robots" content="NONE,NOARCHIVE" />
+  <style type="text/css">
+    html * { padding:0; margin:0; }
+    body * { padding:10px 20px; }
+    body * * { padding:0; }
+    body { font:small sans-serif; background:#eee; }
+    body>div { border-bottom:1px solid #ddd; }
+    h1 { font-weight:normal; margin-bottom:.4em; }
+    h1 span { font-size:60%; color:#666; font-weight:normal; }
+    table { border:none; border-collapse: collapse; width:100%; }
+    td, th { vertical-align:top; padding:2px 3px; }
+    th { width:12em; text-align:right; color:#666; padding-right:.5em; }
+    #info { background:#f6f6f6; }
+    #info ol { margin: 0.5em 4em; }
+    #info ol li { font-family: monospace; }
+    #summary { background: #ffc; }
+    #explanation { background:#eee; border-bottom: 0px none; }
+  </style>
+</head>
+<body>
+  <div id="summary">
+    <h1>Comment post not allowed <span>(400)</span></h1>
+    <table class="meta">
+      <tr>
+        <th>Why:</th>
+        <td>{{ why }}</td>
+      </tr>
+    </table>
+  </div>
+  <div id="info">
+    <p>
+    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 <a
+    href="http://docs.djangoproject.com/en/dev/ref/contrib/comments/">comment
+    documentation</a> for more help.
+    </p>
+  </div>
+
+  <div id="explanation">
+    <p>
+      You're seeing this error because you have <code>DEBUG = True</code> in
+      your Django settings file. Change that to <code>False</code>, and Django
+      will display a standard 400 error page.
+    </p>
+  </div>
+</body>
+</html>
diff --git a/templates/comments/approve.html b/templates/comments/approve.html
new file mode 100644 (file)
index 0000000..a4306a6
--- /dev/null
@@ -0,0 +1,15 @@
+{% extends "comments/base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Approve a comment" %}{% endblock %}
+
+{% block content %}
+  <h1>{% trans "Really make this comment public?" %}</h1>
+  <blockquote>{{ comment|linebreaks }}</blockquote>
+  <form action="." method="post">
+    {% if next %}<input type="hidden" name="next" value="{{ next }}" id="next" />{% endif %}
+    <p class="submit">
+      <input type="submit" name="submit" value="{% trans "Approve" %}" /> or <a href="{{ comment.get_absolute_url }}">cancel</a>
+    </p>
+  </form>
+{% endblock %}
diff --git a/templates/comments/approved.html b/templates/comments/approved.html
new file mode 100644 (file)
index 0000000..d4ba245
--- /dev/null
@@ -0,0 +1,8 @@
+{% extends "comments/base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Thanks for approving" %}.{% endblock %}
+
+{% block content %}
+  <h1>{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.</h1>
+{% endblock %}
diff --git a/templates/comments/base.html b/templates/comments/base.html
new file mode 100644 (file)
index 0000000..dd6dc3e
--- /dev/null
@@ -0,0 +1,45 @@
+<html>
+       <head>
+               <link rel="stylesheet" href="{{ media_url }}sandwiches/style.css" type="text/css">
+               <title>{% block title %}Ma'ayanwich Tracker{% endblock %}</title>
+               {% block extrahead %}{% endblock %}
+       </head>
+       <body>
+               <div id="wrapper">
+                       <div id="header">
+                               <h1 class="header">Ma'ayanwich Tracker</h1>
+                       </div>
+                       <div id="sidebar">
+                               <h3 class="navtitle">Account</h3>
+                               <ul class="nav">
+                                       {% if user.is_authenticated %}
+                                               <li><a href="{% url add_sandwich %}" class="navlink">Add sandwich</a></li>
+                                               <li><a href="{% url logout %}" class="navlink">Logout</a></li>
+                                       {% else %}
+                                               <li><a href="{% url login %}" class="navlink">Login</a></li>
+                                               <li><a href="{% url signup %}" class="navlink">Signup</a></li>
+                                       {% endif %}
+                               </ul>
+                               <h3 class="navtitle">Newest</h3>
+                               <ul class="newest">
+                                       {% for s in sandwiches %}
+                                               <li><a href="{{ s.get_absolute_url }}">{{ s.adjective }}</a></li>
+                                       {% endfor %}
+                               </ul>
+                               <h3 class="navtitle">Sandwiches</h3>
+                               <ul class="newest">
+                                       {% for m in monthly %}
+                                       <li><a href="{% url sandwich_by_month year=m.year, month=m.month %}"> {{ m|date:"F" }} {{m.year}} </a></li>
+                                       {% endfor %}
+                               </ul>
+                               <ul class="newest">
+                                       <li><a href="{% url all_sandwiches %}" class="navlink">All sandwiches</a></li>
+                               </ul>
+                       </div>
+                       <div id="content">
+                               {% block content %}     
+                               {% endblock %}
+                       </div>
+               </div>
+       <body>
+</html>
\ No newline at end of file
diff --git a/templates/comments/delete.html b/templates/comments/delete.html
new file mode 100644 (file)
index 0000000..7d73eac
--- /dev/null
@@ -0,0 +1,15 @@
+{% extends "comments/base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Remove a comment" %}{% endblock %}
+
+{% block content %}
+<h1>{% trans "Really remove this comment?" %}</h1>
+  <blockquote>{{ comment|linebreaks }}</blockquote>
+  <form action="." method="post">
+    {% if next %}<input type="hidden" name="next" value="{{ next }}" id="next" />{% endif %}
+    <p class="submit">
+    <input type="submit" name="submit" value="{% trans "Remove" %}" /> or <a href="{{ comment.get_absolute_url }}">cancel</a>
+    </p>
+  </form>
+{% endblock %}
diff --git a/templates/comments/deleted.html b/templates/comments/deleted.html
new file mode 100644 (file)
index 0000000..e608481
--- /dev/null
@@ -0,0 +1,8 @@
+{% extends "comments/base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Thanks for removing" %}.{% endblock %}
+
+{% block content %}
+  <h1>{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.</h1>
+{% endblock %}
diff --git a/templates/comments/flag.html b/templates/comments/flag.html
new file mode 100644 (file)
index 0000000..08dbe0b
--- /dev/null
@@ -0,0 +1,15 @@
+{% extends "comments/base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Flag this comment" %}{% endblock %}
+
+{% block content %}
+<h1>{% trans "Really flag this comment?" %}</h1>
+  <blockquote>{{ comment|linebreaks }}</blockquote>
+  <form action="." method="post">
+    {% if next %}<input type="hidden" name="next" value="{{ next }}" id="next" />{% endif %}
+    <p class="submit">
+    <input type="submit" name="submit" value="{% trans "Flag" %}" /> or <a href="{{ comment.get_absolute_url }}">cancel</a>
+    </p>
+  </form>
+{% endblock %}
diff --git a/templates/comments/flagged.html b/templates/comments/flagged.html
new file mode 100644 (file)
index 0000000..e558019
--- /dev/null
@@ -0,0 +1,8 @@
+{% extends "comments/base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Thanks for flagging" %}.{% endblock %}
+
+{% block content %}
+  <h1>{% trans "Thanks for taking the time to improve the quality of discussion on our site" %}.</h1>
+{% endblock %}
diff --git a/templates/comments/form.html b/templates/comments/form.html
new file mode 100644 (file)
index 0000000..73b306d
--- /dev/null
@@ -0,0 +1,20 @@
+{% load comments i18n %}
+<form action="{% comment_form_target %}" method="post">
+  {% if next %}<input type="hidden" name="next" value="{% url comment.get_content_object_url() %}" />{% endif %}
+  {% for field in form %}
+    {% if field.is_hidden %}
+      {{ field }}
+    {% else %}
+      {% if field.errors %}{{ field.errors }}{% endif %}
+      <p
+        {% if field.errors %} class="error"{% endif %}
+        {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
+        {{ field.label_tag }} {{ field }}
+      </p>
+    {% endif %}
+  {% endfor %}
+  <p class="submit">
+    <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
+    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
+  </p>
+</form>
diff --git a/templates/comments/moderation_queue.html b/templates/comments/moderation_queue.html
new file mode 100644 (file)
index 0000000..73012b3
--- /dev/null
@@ -0,0 +1,75 @@
+{% extends "admin/change_list.html" %}
+{% load adminmedia i18n %}
+
+{% block title %}{% trans "Comment moderation queue" %}{% endblock %}
+
+{% block extrahead %}
+  {{ block.super }}
+  <style type="text/css" media="screen">
+    p#nocomments { font-size: 200%; text-align: center; border: 1px #ccc dashed; padding: 4em; }
+    td.actions { width: 11em; }
+    td.actions form { display: inline; }
+    td.actions form input.submit { width: 5em; padding: 2px 4px; margin-right: 4px;}
+    td.actions form input.approve { background: green; color: white; }
+    td.actions form input.remove { background: red; color: white; }
+  </style>
+{% endblock %}
+
+{% block branding %}
+<h1 id="site-name">{% trans "Comment moderation queue" %}</h1>
+{% endblock %}
+
+{% block breadcrumbs %}{% endblock %}
+
+{% block content %}
+{% if empty %}
+<p id="nocomments">{% trans "No comments to moderate" %}.</p>
+{% else %}
+<div id="content-main">
+  <div class="module" id="changelist">
+    <table cellspacing="0">
+      <thead>
+        <tr>
+          <th>{% trans "Action" %}</th>
+          <th>{% trans "Name" %}</th>
+          <th>{% trans "Comment" %}</th>
+          <th>{% trans "Email" %}</th>
+          <th>{% trans "URL" %}</th>
+          <th>{% trans "Authenticated?" %}</th>
+          <th>{% trans "IP Address" %}</th>
+          <th class="sorted desc">{% trans "Date posted" %}</th>
+        </tr>
+    </thead>
+    <tbody>
+      {% for comment in comments %}
+        <tr class="{% cycle 'row1' 'row2' %}">
+          <td class="actions">
+            <form action="{% url comments-approve comment.pk %}" method="post">
+              <input type="hidden" name="next" value="{% url comments-moderation-queue %}" />
+              <input class="approve submit" type="submit" name="submit" value="{% trans "Approve" %}" />
+            </form>
+            <form action="{% url comments-delete comment.pk %}" method="post">
+              <input type="hidden" name="next" value="{% url comments-moderation-queue %}" />
+              <input class="remove submit" type="submit" name="submit" value="{% trans "Remove" %}" />
+            </form>
+          </td>
+          <td>{{ comment.name }}</td>
+          <td>{{ comment.comment|truncatewords:"50" }}</td>
+          <td>{{ comment.email }}</td>
+          <td>{{ comment.url }}</td>
+          <td>
+            <img
+              src="{% admin_media_prefix %}img/admin/icon-{% if comment.user %}yes{% else %}no{% endif %}.gif"
+              alt="{% if comment.user %}{% trans "yes" %}{% else %}{% trans "no" %}{% endif %}"
+            />
+          </td>
+          <td>{{ comment.ip_address }}</td>
+          <td>{{ comment.submit_date|date:"F j, P" }}</td>
+        </tr>
+      {% endfor %}
+    </tbody>
+    </table>
+  </div>
+</div>
+{% endif %}
+{% endblock %}
diff --git a/templates/comments/posted.html b/templates/comments/posted.html
new file mode 100644 (file)
index 0000000..76f7f6d
--- /dev/null
@@ -0,0 +1,8 @@
+{% extends "comments/base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Thanks for commenting" %}.{% endblock %}
+
+{% block content %}
+  <h1>{% trans "Thank you for your comment" %}.</h1>
+{% endblock %}
diff --git a/templates/comments/preview.html b/templates/comments/preview.html
new file mode 100644 (file)
index 0000000..d388457
--- /dev/null
@@ -0,0 +1,36 @@
+{% extends "comments/base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Preview your comment" %}{% endblock %}
+
+{% block content %}
+  {% load comments %}
+  <form action="{% comment_form_target %}" method="post">
+    {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
+    {% if form.errors %}
+    <h1>{% blocktrans count form.errors|length as counter %}Please correct the error below{% plural %}Please correct the errors below{% endblocktrans %}</h1>
+    {% else %}
+    <h1>{% trans "Preview your comment" %}</h1>
+      <blockquote>{{ comment|linebreaks }}</blockquote>
+      <p>
+      {% trans "and" %} <input type="submit" name="submit" class="submit-post" value="{% trans "Post your comment" %}" id="submit" /> {% trans "or make changes" %}:
+      </p>
+    {% endif %}
+    {% for field in form %}
+      {% if field.is_hidden %}
+        {{ field }}
+      {% else %}
+        {% if field.errors %}{{ field.errors }}{% endif %}
+        <p
+          {% if field.errors %} class="error"{% endif %}
+          {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
+          {{ field.label_tag }} {{ field }}
+        </p>
+      {% endif %}
+    {% endfor %}
+    <p class="submit">
+    <input type="submit" name="submit" class="submit-post" value="{% trans "Post" %}" />
+    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
+    </p>
+  </form>
+{% endblock %}
index 60ea42b..e1654fa 100644 (file)
@@ -36,6 +36,7 @@
                <p class="sandnotes">{{ comment.comment }}</p>
                <p class="metadata">{{ comment.submit_date }}</p>
        {% endfor %}
                <p class="sandnotes">{{ comment.comment }}</p>
                <p class="metadata">{{ comment.submit_date }}</p>
        {% endfor %}
+       <a name="comments"></a> 
        <h4 class="addcomment">Add a Comment</h4>
        {% render_comment_form for s %}
 {% endblock %}
\ No newline at end of file
        <h4 class="addcomment">Add a Comment</h4>
        {% render_comment_form for s %}
 {% endblock %}
\ No newline at end of file
diff --git a/urls.py b/urls.py
index 628eb02..9eefa92 100644 (file)
--- 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'^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'),
 )
        (r'^comments/', include('django.contrib.comments.urls')),
        url(r'^home/$', views.current_home, name='index'),
 )
index 39ec141..d653118 100644 (file)
--- 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 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
 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))
        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):
 
 
 def ajaxfun(request):