# HG changeset patch # User neko259 # Date 2015-10-29 16:47:45 # Node ID 1252678f53ed30e41f0e66705f7f602882daa4bd # Parent c9a1cd47c75d7c6cef3e767654af6a2173821aaf Do not pass over perms variable manually to the post template. Fixed thread diff using old method to check permissions diff --git a/boards/models/post/__init__.py b/boards/models/post/__init__.py --- a/boards/models/post/__init__.py +++ b/boards/models/post/__init__.py @@ -44,7 +44,6 @@ PARAMETER_DIFF_TYPE = 'type' PARAMETER_CSS_CLASS = 'css_class' PARAMETER_THREAD = 'thread' PARAMETER_IS_OPENING = 'is_opening' -PARAMETER_MODERATOR = 'moderator' PARAMETER_POST = 'post' PARAMETER_OP_ID = 'opening_post_id' PARAMETER_NEED_OPEN_LINK = 'need_open_link' diff --git a/boards/models/post/export.py b/boards/models/post/export.py --- a/boards/models/post/export.py +++ b/boards/models/post/export.py @@ -1,3 +1,5 @@ +from django.contrib.auth.context_processors import PermWrapper + from boards import utils @@ -24,7 +26,7 @@ class HtmlExporter(Exporter): reply_link = True return post.get_view(truncated=truncated, reply_link=reply_link, - moderator=utils.is_moderator(request)) + perms=PermWrapper(request.user)) class JsonExporter(Exporter): diff --git a/boards/templates/boards/all_threads.html b/boards/templates/boards/all_threads.html --- a/boards/templates/boards/all_threads.html +++ b/boards/templates/boards/all_threads.html @@ -99,7 +99,7 @@ {% for thread in threads %}
- {% post_view thread.get_opening_post perms=perms thread=thread truncated=True need_open_link=True %} + {% post_view thread.get_opening_post thread=thread truncated=True need_open_link=True %} {% if not thread.archived %} {% with last_replies=thread.get_last_replies %} {% if last_replies %} @@ -114,7 +114,7 @@ {% endwith %}
{% for post in last_replies %} - {% post_view post perms=perms truncated=True %} + {% post_view post truncated=True %} {% endfor %}
{% endif %} diff --git a/boards/templates/boards/thread_normal.html b/boards/templates/boards/thread_normal.html --- a/boards/templates/boards/thread_normal.html +++ b/boards/templates/boards/thread_normal.html @@ -34,7 +34,7 @@
{% for post in thread.get_replies %} - {% post_view post perms=perms reply_link=True %} + {% post_view post reply_link=True %} {% endfor %}
diff --git a/boards/templatetags/board.py b/boards/templatetags/board.py --- a/boards/templatetags/board.py +++ b/boards/templatetags/board.py @@ -39,8 +39,9 @@ def image_actions(*args, **kwargs): action['link'] % image_link, action['name']) for action in actions]) -@register.simple_tag(name='post_view') -def post_view(post, *args, **kwargs): +@register.simple_tag(name='post_view', takes_context=True) +def post_view(context, post, *args, **kwargs): + kwargs['perms'] = context['perms'] return post.get_view(*args, **kwargs) @register.simple_tag(name='page_url')