Mercurial > public > sg101
changeset 104:59688577a8f1
Forums: display of sticky status. Moderators/superusers see IP address of post. Added a can_reply flag to the template and have view compute it.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 17 Sep 2009 01:44:51 +0000 |
parents | bb3f0d315c5f |
children | 08ddfd835305 |
files | gpp/forums/views.py gpp/templates/forums/display_post.html gpp/templates/forums/topic.html |
diffstat | 3 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/forums/views.py Thu Sep 17 00:20:00 2009 +0000 +++ b/gpp/forums/views.py Thu Sep 17 01:44:51 2009 +0000 @@ -112,12 +112,21 @@ # we do this for the template since it is rendered twice page_nav = render_to_string('forums/pagination.html', {'page': page}) + can_moderate = request.user.is_authenticated() and ( + request.user.is_superuser or \ + request.user in topic.forum.moderators.all()) + + can_reply = request.user.is_authenticated() and ( + not topic.locked or can_moderate) + return render_to_response('forums/topic.html', { 'forum': topic.forum, 'topic': topic, 'page': page, 'page_nav': page_nav, 'last_page': last_page, + 'can_moderate': can_moderate, + 'can_reply': can_reply, 'form': PostForm(initial={'topic_id': topic.id}), }, context_instance=RequestContext(request))
--- a/gpp/templates/forums/display_post.html Thu Sep 17 00:20:00 2009 +0000 +++ b/gpp/templates/forums/display_post.html Thu Sep 17 01:44:51 2009 +0000 @@ -12,6 +12,8 @@ <div class="forum-post-info quiet"> <a href="{{ post.get_absolute_url }}"><img src="{{ MEDIA_URL }}icons/link.png" alt="Link" title="Link to this post" /></a> Posted on {{ post.creation_date|date:"M d, Y H:i" }} + {% if can_moderate %}from IP: {{ post.user_ip }}{% endif %} + </div> <div class="forum-post-body"> {{ post.html|safe }}
--- a/gpp/templates/forums/topic.html Thu Sep 17 00:20:00 2009 +0000 +++ b/gpp/templates/forums/topic.html Thu Sep 17 01:44:51 2009 +0000 @@ -11,9 +11,14 @@ </h3> <div class="forum-block"> +{% if topic.sticky %} +<img src="{{ MEDIA_URL }}/icons/asterisk_orange.png" alt="Sticky" title="Sticky" /> +{% endif %} {% if topic.locked %} <img src="{{ MEDIA_URL }}/icons/lock.png" alt="Lock" title="This topic is locked" /> -{% else %} +{% endif %} +{% if can_reply %} +{% if topic.locked or topic.sticky %}•{% endif %} {% if last_page %} <a href="#forum-reply-form">New Reply</a> {% else %} @@ -30,7 +35,7 @@ </table> {{ page_nav }} -{% if last_page and user.is_authenticated and not topic.locked %} +{% if last_page and can_reply %} <a name="forum-reply-form"></a> <form action="" method="post" id="forums-quick-reply"> <fieldset>