Add new document app events: document type created and document type edited. Add link to document type events.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-08-15 03:18:46 -04:00
parent b3ef018d6c
commit cd76b1fd4a
5 changed files with 46 additions and 3 deletions

View File

@@ -31,6 +31,7 @@ from mimetype.api import get_mimetype
from .events import (
event_document_create, event_document_new_version,
event_document_properties_edit, event_document_type_change,
event_document_type_created, event_document_type_edited,
event_document_version_revert
)
from .literals import DEFAULT_DELETE_PERIOD, DEFAULT_DELETE_TIME_UNIT
@@ -148,6 +149,23 @@ class DocumentType(models.Model):
)
raise
def save(self, *args, **kwargs):
user = kwargs.pop('_user', None)
created = not self.pk
result = super(DocumentType, self).save(*args, **kwargs)
if created:
event_document_type_created.commit(
actor=user, target=self
)
else:
event_document_type_edited.commit(
actor=user, target=self
)
return result
@python_2_unicode_compatible
class Document(models.Model):