Reorganize and sort models and managers according to Mayan's best practices.

Signed-off-by: Michael Price <loneviking72@gmail.com>
This commit is contained in:
Michael Price
2018-03-13 15:56:40 -04:00
committed by Roberto Rosario
parent a172538dfc
commit 28aa0b913c
21 changed files with 418 additions and 418 deletions

View File

@@ -33,9 +33,25 @@ class Comment(models.Model):
verbose_name=_('Date time submitted')
)
class Meta:
get_latest_by = 'submit_date'
ordering = ('-submit_date',)
verbose_name = _('Comment')
verbose_name_plural = _('Comments')
def __str__(self):
return self.comment
def delete(self, *args, **kwargs):
user = kwargs.pop('_user', None)
super(Comment, self).delete(*args, **kwargs)
if user:
event_document_comment_delete.commit(
actor=user, target=self.document
)
else:
event_document_comment_delete.commit(target=self.document)
def save(self, *args, **kwargs):
user = kwargs.pop('_user', None) or self.user
is_new = not self.pk
@@ -55,19 +71,3 @@ class Comment(models.Model):
'Comment "%s" added to document "%s"', self.comment,
self.document
)
def delete(self, *args, **kwargs):
user = kwargs.pop('_user', None)
super(Comment, self).delete(*args, **kwargs)
if user:
event_document_comment_delete.commit(
actor=user, target=self.document
)
else:
event_document_comment_delete.commit(target=self.document)
class Meta:
get_latest_by = 'submit_date'
ordering = ('-submit_date',)
verbose_name = _('Comment')
verbose_name_plural = _('Comments')