diff --git a/mayan/apps/tags/models.py b/mayan/apps/tags/models.py index 6a363bd5aa..7fd109d290 100644 --- a/mayan/apps/tags/models.py +++ b/mayan/apps/tags/models.py @@ -44,15 +44,26 @@ class Tag(models.Model): def __str__(self): return self.label - def attach_to(self, document, user=None): + def documents_attach(self, queryset, _user=None): """ Attach a tag to a document and commit the corresponding event. """ with transaction.atomic(): - for document in documents: + for document in queryset: self.documents.add(document) event_tag_attach.commit( - action_object=self, actor=user, target=document + action_object=self, actor=_user, target=document + ) + + def documents_remove(self, queryset, _user=None): + """ + Remove a tag from a document and commit the corresponding event. + """ + with transaction.atomic(): + for document in queryset: + self.documents.remove(document) + event_tag_remove.commit( + action_object=self, actor=_user, target=document ) def get_absolute_url(self): @@ -74,17 +85,6 @@ class Tag(models.Model): def get_document_count(self, user): return self.get_documents(user=user).count() - def remove_from(self, documents, _user=None): - """ - Remove a tag from a document and commit the corresponding event. - """ - with transaction.atomic(): - for document in documents: - self.documents.remove(document) - event_tag_remove.commit( - action_object=self, actor=user, target=document - ) - def save(self, *args, **kwargs): user = kwargs.pop('_user', None) created = not self.pk