Browse files

[bug 837851] Add permission to edit keywords field

  • Loading branch information...
1 parent 14583a6 commit 3a1d976be42af637922a5c7c958ec01fb22b8518 @rehandalal rehandalal committed Mar 6, 2013
Showing with 9 additions and 2 deletions.
  1. +2 −1 apps/wiki/models.py
  2. +3 −1 apps/wiki/templates/wiki/edit.html
  3. +4 −0 migrations/200-edit-keywords-permission.sql
View
3 apps/wiki/models.py
@@ -744,7 +744,8 @@ class Revision(ModelBase):
class Meta(object):
permissions = [('review_revision', 'Can review a revision'),
('mark_ready_for_l10n',
- 'Can mark revision as ready for localization')]
+ 'Can mark revision as ready for localization'),
+ ('edit_keywords', 'Can edit keywords')]
def _based_on_is_clean(self):
"""Return a tuple: (the correct value of based_on, whether the old
View
4 apps/wiki/templates/wiki/edit.html
@@ -60,7 +60,9 @@
{% for field in revision_form.visible_fields() %}
<li>
{% if field.name not in ['comment', 'content'] %}
- {{ field|label_with_help }}{{ field|safe }}
+ {% if not field.name == 'keywords' or user.has_perm('wiki.edit_keywords') %}
+ {{ field|label_with_help }}{{ field|safe }}
+ {% endif %}
{% elif field.name == 'content' %}
{{ revision_form.content.label_tag()|safe }}
{{ content_editor(revision_form.content) }}
View
4 migrations/200-edit-keywords-permission.sql
@@ -0,0 +1,4 @@
+SET @ct = (SELECT id from django_content_type WHERE name='revision' AND app_label='wiki');
+
+INSERT INTO auth_permission (`name`, `content_type_id`, `codename`) VALUES
+ ('Can edit keywords', @ct, 'edit_keywords');

0 comments on commit 3a1d976

Please sign in to comment.