##// END OF EJS Templates
Don't check perms for every post moderation action
neko259 -
r2036:265c0022 default
parent child Browse files
Show More
@@ -28,6 +28,14 b''
28 data-pow-difficulty="{{ pow_difficulty|safe }}"
28 data-pow-difficulty="{{ pow_difficulty|safe }}"
29 data-update-script="{% static 'js/updates.js' %}">
29 data-update-script="{% static 'js/updates.js' %}">
30 <script src="{% static 'js/jquery-2.2.0.min.js' %}"></script>
30 <script src="{% static 'js/jquery-2.2.0.min.js' %}"></script>
31 <script>
32 var PERMS = {
33 'change_post': '{{ perms.boards.change_post }}' === 'True',
34 'delete_post': '{{ perms.boards.delete_post }}' === 'True',
35 'change_thread': '{{ perms.boards.change_thread }}' === 'True',
36 'delete_thread': '{{ perms.boards.delete_thread }}' === 'True'
37 }
38 </script>
31
39
32 <header class="navigation_panel">
40 <header class="navigation_panel">
33 <a class="link" href="{% url 'landing' %}">{{ site_name|safe }}</a>
41 <a class="link" href="{% url 'landing' %}">{{ site_name|safe }}</a>
@@ -58,6 +58,16 b''
58 selector: '#{{ post.id }} .moderation-menu',
58 selector: '#{{ post.id }} .moderation-menu',
59 trigger: 'left',
59 trigger: 'left',
60 build: function($trigger, e) {
60 build: function($trigger, e) {
61 var body = $('body');
62
63 var canEditPost = PERMS['change_post'];
64 var canDeletePost = PERMS['delete_post'];
65 var canEditThread = PERMS['change_thread'];
66 var canDeleteThread = PERMS['delete_thread'];
67
68 var isOpening = '{{ is_opening }}' === 'True';
69 var hasIp = '{{ post.has_ip }}' === 'True';
70
61 return {
71 return {
62 items: {
72 items: {
63 edit: {
73 edit: {
@@ -65,35 +75,35 b''
65 callback: function(key, opt) {
75 callback: function(key, opt) {
66 window.location = '{% url 'admin:boards_post_change' post.id %}';
76 window.location = '{% url 'admin:boards_post_change' post.id %}';
67 },
77 },
68 visible: {% if perms.boards.change_post %}true{% else %}false{% endif %}
78 visible: canEditPost
69 },
79 },
70 deletePost: {
80 deletePost: {
71 name: '{% trans "Delete post" %}',
81 name: '{% trans "Delete post" %}',
72 callback: function(key, opt) {
82 callback: function(key, opt) {
73 window.location = '{% url 'admin:boards_post_delete' post.id %}';
83 window.location = '{% url 'admin:boards_post_delete' post.id %}';
74 },
84 },
75 visible: {% if not is_opening and perms.boards.delete_post %}true{% else %}false{% endif %}
85 visible: !isOpening && canDeletePost
76 },
86 },
77 editThread: {
87 editThread: {
78 name: '{% trans "Edit thread" %}',
88 name: '{% trans "Edit thread" %}',
79 callback: function(key, opt) {
89 callback: function(key, opt) {
80 window.location = '{% url 'admin:boards_thread_change' thread.id %}';
90 window.location = '{% url 'admin:boards_thread_change' thread.id %}';
81 },
91 },
82 visible: {% if is_opening and perms.boards.change_thread %}true{% else %}false{% endif %}
92 visible: isOpening && canEditThread
83 },
93 },
84 deleteThread: {
94 deleteThread: {
85 name: '{% trans "Delete thread" %}',
95 name: '{% trans "Delete thread" %}',
86 callback: function(key, opt) {
96 callback: function(key, opt) {
87 window.location = '{% url 'admin:boards_thread_delete' thread.id %}';
97 window.location = '{% url 'admin:boards_thread_delete' thread.id %}';
88 },
98 },
89 visible: {% if is_opening and perms.boards.delete_thread %}true{% else %}false{% endif %}
99 visible: isOpening && canDeleteThread
90 },
100 },
91 findByIp: {
101 findByIp: {
92 name: 'IP = {{ post.poster_ip }}',
102 name: 'IP = {{ post.poster_ip }}',
93 callback: function(key, opt) {
103 callback: function(key, opt) {
94 window.location = '{% url "feed" %}?ip={{ post.poster_ip }}';
104 window.location = '{% url "feed" %}?ip={{ post.poster_ip }}';
95 },
105 },
96 visible: {% if post.has_ip %}true{% else %}false{% endif %}
106 visible: hasIp
97 },
107 },
98 raw: {
108 raw: {
99 name: 'RAW',
109 name: 'RAW',
@@ -109,7 +119,7 b''
109 window.location = '{% url 'utils' %}?method=ban&post_id={{ post.id }}';
119 window.location = '{% url 'utils' %}?method=ban&post_id={{ post.id }}';
110 }
120 }
111 },
121 },
112 visible: {% if post.has_ip %}true{% else %}false{% endif %}
122 visible: hasIp
113 },
123 },
114 banAndDelete: {
124 banAndDelete: {
115 name: '{% trans "Ban and delete" %}',
125 name: '{% trans "Ban and delete" %}',
@@ -118,7 +128,7 b''
118 window.location = '{% url 'utils' %}?method=ban_and_delete&post_id={{ post.id }}';
128 window.location = '{% url 'utils' %}?method=ban_and_delete&post_id={{ post.id }}';
119 }
129 }
120 },
130 },
121 visible: {% if post.has_ip %}true{% else %}false{% endif %}
131 visible: hasIp && canDeletePost
122 }
132 }
123 }
133 }
124 };
134 };
General Comments 0
You need to be logged in to leave comments. Login now