Rebalance tag permissions. Change the required permission to attach
and remove a tag from view to attach and remove respectively. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
- When changing document types, don't delete the old metadata that is
|
||||
also found in the new document type. GitLab issue #421.
|
||||
- Add tag attach and tag remove events.
|
||||
- Change the permission needed to attach and remove tags.
|
||||
|
||||
2.6.4 (2017-07-26)
|
||||
==================
|
||||
|
||||
@@ -17,6 +17,7 @@ logger = logging.getLogger(__name__)
|
||||
class TagMultipleSelectionForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
help_text = kwargs.pop('help_text', None)
|
||||
permission = kwargs.pop('permission', permission_tag_view)
|
||||
queryset = kwargs.pop('queryset', Tag.objects.all())
|
||||
user = kwargs.pop('user', None)
|
||||
|
||||
@@ -24,7 +25,7 @@ class TagMultipleSelectionForm(forms.Form):
|
||||
super(TagMultipleSelectionForm, self).__init__(*args, **kwargs)
|
||||
|
||||
queryset = AccessControlList.objects.filter_by_access(
|
||||
permission=permission_tag_view, queryset=queryset, user=user
|
||||
permission=permission, queryset=queryset, user=user
|
||||
)
|
||||
|
||||
self.fields['tags'] = forms.ModelMultipleChoiceField(
|
||||
|
||||
@@ -63,6 +63,7 @@ class TagAttachActionView(MultipleObjectFormActionView):
|
||||
queryset = self.get_queryset()
|
||||
result = {
|
||||
'help_text': _('Tags to be attached.'),
|
||||
'permission': permission_tag_attach,
|
||||
'user': self.request.user
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ class TagAttachActionView(MultipleObjectFormActionView):
|
||||
}
|
||||
)
|
||||
else:
|
||||
tag.attach_to(instance)
|
||||
tag.attach_to(document=instance, user=self.request.user)
|
||||
messages.success(
|
||||
self.request,
|
||||
_(
|
||||
@@ -269,6 +270,7 @@ class TagRemoveActionView(MultipleObjectFormActionView):
|
||||
queryset = self.get_queryset()
|
||||
result = {
|
||||
'help_text': _('Tags to be removed.'),
|
||||
'permission': permission_tag_remove,
|
||||
'user': self.request.user
|
||||
}
|
||||
|
||||
@@ -299,7 +301,7 @@ class TagRemoveActionView(MultipleObjectFormActionView):
|
||||
}
|
||||
)
|
||||
else:
|
||||
tag.remove_from(instance)
|
||||
tag.remove_from(document=instance, user=self.request.user)
|
||||
messages.success(
|
||||
self.request,
|
||||
_(
|
||||
|
||||
Reference in New Issue
Block a user