Show More
@@ -9,7 +9,6 b' from boards.models import Post, Tag' | |||||
9 |
|
9 | |||
10 | CONTEXT_SITE_NAME = 'site_name' |
|
10 | CONTEXT_SITE_NAME = 'site_name' | |
11 | CONTEXT_VERSION = 'version' |
|
11 | CONTEXT_VERSION = 'version' | |
12 | CONTEXT_MODERATOR = 'moderator' |
|
|||
13 | CONTEXT_THEME_CSS = 'theme_css' |
|
12 | CONTEXT_THEME_CSS = 'theme_css' | |
14 | CONTEXT_THEME = 'theme' |
|
13 | CONTEXT_THEME = 'theme' | |
15 | CONTEXT_PPD = 'posts_per_day' |
|
14 | CONTEXT_PPD = 'posts_per_day' | |
@@ -50,9 +49,6 b' def user_and_ui_processor(request):' | |||||
50 | context[CONTEXT_THEME] = theme |
|
49 | context[CONTEXT_THEME] = theme | |
51 | context[CONTEXT_THEME_CSS] = 'css/' + theme + '/base_page.css' |
|
50 | context[CONTEXT_THEME_CSS] = 'css/' + theme + '/base_page.css' | |
52 |
|
51 | |||
53 | # This shows the moderator panel |
|
|||
54 | context[CONTEXT_MODERATOR] = utils.is_moderator(request) |
|
|||
55 |
|
||||
56 | context[CONTEXT_VERSION] = settings.get('Version', 'Version') |
|
52 | context[CONTEXT_VERSION] = settings.get('Version', 'Version') | |
57 | context[CONTEXT_SITE_NAME] = settings.get('Version', 'SiteName') |
|
53 | context[CONTEXT_SITE_NAME] = settings.get('Version', 'SiteName') | |
58 |
|
54 |
@@ -54,10 +54,10 b" PARAMETER_NEED_OP_DATA = 'need_op_data'" | |||||
54 | POST_VIEW_PARAMS = ( |
|
54 | POST_VIEW_PARAMS = ( | |
55 | 'need_op_data', |
|
55 | 'need_op_data', | |
56 | 'reply_link', |
|
56 | 'reply_link', | |
57 | 'moderator', |
|
|||
58 | 'need_open_link', |
|
57 | 'need_open_link', | |
59 | 'truncated', |
|
58 | 'truncated', | |
60 | 'mode_tree', |
|
59 | 'mode_tree', | |
|
60 | 'perms', | |||
61 | ) |
|
61 | ) | |
62 |
|
62 | |||
63 |
|
63 |
@@ -99,7 +99,7 b'' | |||||
99 |
|
99 | |||
100 | {% for thread in threads %} |
|
100 | {% for thread in threads %} | |
101 | <div class="thread"> |
|
101 | <div class="thread"> | |
102 |
{% post_view thread.get_opening_post |
|
102 | {% post_view thread.get_opening_post perms=perms thread=thread truncated=True need_open_link=True %} | |
103 | {% if not thread.archived %} |
|
103 | {% if not thread.archived %} | |
104 | {% with last_replies=thread.get_last_replies %} |
|
104 | {% with last_replies=thread.get_last_replies %} | |
105 | {% if last_replies %} |
|
105 | {% if last_replies %} | |
@@ -114,7 +114,7 b'' | |||||
114 | {% endwith %} |
|
114 | {% endwith %} | |
115 | <div class="last-replies"> |
|
115 | <div class="last-replies"> | |
116 | {% for post in last_replies %} |
|
116 | {% for post in last_replies %} | |
117 |
{% post_view post |
|
117 | {% post_view post perms=perms truncated=True %} | |
118 | {% endfor %} |
|
118 | {% endfor %} | |
119 | </div> |
|
119 | </div> | |
120 | {% endif %} |
|
120 | {% endif %} |
@@ -45,15 +45,19 b'' | |||||
45 | <a href="#form" onclick="addQuickReply('{{ post.id }}'); return false;">{% trans 'Reply' %}</a> |
|
45 | <a href="#form" onclick="addQuickReply('{{ post.id }}'); return false;">{% trans 'Reply' %}</a> | |
46 | {% endif %} |
|
46 | {% endif %} | |
47 |
|
47 | |||
48 | {% if moderator %} |
|
48 | {% if perms.boards.change_post or perms.boards.delete_post or perms.boards.change_thread or perms_boards.delete_thread %} | |
49 | <span class="moderator_info"> |
|
49 | <span class="moderator_info"> | |
50 | | <a href="{% url 'admin:boards_post_change' post.id %}">{% trans 'Edit' %}</a> |
|
50 | {% if perms.boards.change_post or perms.boards.delete_post %} | |
51 | {% if is_opening %} |
|
51 | | <a href="{% url 'admin:boards_post_change' post.id %}">{% trans 'Edit' %}</a> | |
52 | | <a href="{% url 'admin:boards_thread_change' thread.id %}">{% trans 'Edit thread' %}</a> |
|
52 | <form action="{% url 'thread' thread.get_opening_post_id %}?post_id={{ post.id }}" method="post" class="post-button-form"> | |
|
53 | | <button name="method" value="toggle_hide_post">H</button> | |||
|
54 | </form> | |||
53 | {% endif %} |
|
55 | {% endif %} | |
54 | <form action="{% url 'thread' thread.get_opening_post_id %}?post_id={{ post.id }}" method="post" class="post-button-form"> |
|
56 | {% if perms.boards.change_thread or perms_boards.delete_thread %} | |
55 | | <button name="method" value="toggle_hide_post">H</button> |
|
57 | {% if is_opening %} | |
56 | </form> |
|
58 | | <a href="{% url 'admin:boards_thread_change' thread.id %}">{% trans 'Edit thread' %}</a> | |
|
59 | {% endif %} | |||
|
60 | {% endif %} | |||
57 | </form> |
|
61 | </form> | |
58 | </span> |
|
62 | </span> | |
59 | {% endif %} |
|
63 | {% endif %} |
@@ -34,7 +34,7 b'' | |||||
34 |
|
34 | |||
35 | <div class="thread"> |
|
35 | <div class="thread"> | |
36 | {% for post in thread.get_replies %} |
|
36 | {% for post in thread.get_replies %} | |
37 |
{% post_view post |
|
37 | {% post_view post perms=perms reply_link=True %} | |
38 | {% endfor %} |
|
38 | {% endfor %} | |
39 | </div> |
|
39 | </div> | |
40 |
|
40 |
@@ -19,7 +19,6 b' from boards.settings import get_bool' | |||||
19 | from neboard import settings |
|
19 | from neboard import settings | |
20 |
|
20 | |||
21 | CACHE_KEY_DELIMITER = '_' |
|
21 | CACHE_KEY_DELIMITER = '_' | |
22 | PERMISSION_MODERATE = 'moderation' |
|
|||
23 |
|
22 | |||
24 | HTTP_FORWARDED = 'HTTP_X_FORWARDED_FOR' |
|
23 | HTTP_FORWARDED = 'HTTP_X_FORWARDED_FOR' | |
25 | META_REMOTE_ADDR = 'REMOTE_ADDR' |
|
24 | META_REMOTE_ADDR = 'REMOTE_ADDR' | |
@@ -103,15 +102,6 b' def cached_result(key_method=None):' | |||||
103 | return _cached_result |
|
102 | return _cached_result | |
104 |
|
103 | |||
105 |
|
104 | |||
106 | def is_moderator(request): |
|
|||
107 | try: |
|
|||
108 | moderate = request.user.has_perm(PERMISSION_MODERATE) |
|
|||
109 | except AttributeError: |
|
|||
110 | moderate = False |
|
|||
111 |
|
||||
112 | return moderate |
|
|||
113 |
|
||||
114 |
|
||||
115 | def get_file_hash(file) -> str: |
|
105 | def get_file_hash(file) -> str: | |
116 | md5 = hashlib.md5() |
|
106 | md5 = hashlib.md5() | |
117 | for chunk in file.chunks(): |
|
107 | for chunk in file.chunks(): |
General Comments 0
You need to be logged in to leave comments.
Login now