From c665db20b8441da5ca9e2a479d682b67beb75454 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Fri, 6 Mar 2015 18:42:16 -0800 Subject: [PATCH] Enforce blog posts not allowing commenting on them --- .../blog/templates/blog/entry.inc.html | 1 + rophako/modules/comment/__init__.py | 10 +- .../comment/templates/comment/form.inc.html | 128 +++++++++--------- 3 files changed, 75 insertions(+), 64 deletions(-) diff --git a/rophako/modules/blog/templates/blog/entry.inc.html b/rophako/modules/blog/templates/blog/entry.inc.html index 0afda7d..6f2dc04 100644 --- a/rophako/modules/blog/templates/blog/entry.inc.html +++ b/rophako/modules/blog/templates/blog/entry.inc.html @@ -81,6 +81,7 @@ {{ include_page("comment.partial_index", thread="blog-"+post["post_id"]|string, subject=post["subject"], + addable=post["comments"], ) | safe }} {% endif %} diff --git a/rophako/modules/comment/__init__.py b/rophako/modules/comment/__init__.py index 99808d2..fffeb2b 100644 --- a/rophako/modules/comment/__init__.py +++ b/rophako/modules/comment/__init__.py @@ -168,8 +168,13 @@ def unsubscribe(): return template("comment/unsubscribed.html") -def partial_index(thread, subject, header=True): - """Partial template for including the index view of a comment thread.""" +def partial_index(thread, subject, header=True, addable=True): + """Partial template for including the index view of a comment thread. + + * thread: unique name for the comment thread + * subject: subject name for the comment thread + * header: show the Comments h1 header + * addable: boolean, can new comments be added to the thread""" comments = Comment.get_comments(thread) @@ -199,6 +204,7 @@ def partial_index(thread, subject, header=True): g.info["header"] = header g.info["thread"] = thread g.info["subject"] = subject + g.info["commenting_disabled"] = not addable g.info["url"] = request.url g.info["comments"] = sorted_comments g.info["photo_url"] = Config.photo.root_public diff --git a/rophako/modules/comment/templates/comment/form.inc.html b/rophako/modules/comment/templates/comment/form.inc.html index d6c97f8..5ea82fe 100644 --- a/rophako/modules/comment/templates/comment/form.inc.html +++ b/rophako/modules/comment/templates/comment/form.inc.html @@ -1,66 +1,70 @@ {# Common template for leaving a comment/updating the comment preview. #} -
- - - - - - - - - - - - - - - - - - - - -
- Your name: - - {% if session["login"] %} - {{ session["name"] }} - {% else %} - - {% endif %} -
- Your Email: - - -
- Message: - - -
- Comments can be formatted with Markdown, - and you can use
emoticons - in your comment.
-
-
- -

- -

- If you can see this, don't touch the following fields.
-
- -
- -{% if preview %} - - +{% if commenting_disabled %} + No new comments may be added to this thread. {% else %} - -{% endif %} + + + + + + + + + + + + + + + + + + + + + +
+ Your name: + + {% if session["login"] %} + {{ session["name"] }} + {% else %} + + {% endif %} +
+ Your Email: + + +
+ Message: + + +
+ Comments can be formatted with Markdown, + and you can use
emoticons + in your comment.
+
+
+ +

-

+
+ If you can see this, don't touch the following fields.
+
+ +
+ + {% if preview %} + + + {% else %} + + {% endif %} + + +{% endif %}