Refactoring

* adds simple getter methods for UserActionLogEntry
* replaces manual creation of UserActionLogEntry with new methods
This commit is contained in:
2021-11-16 13:15:15 +01:00
parent 7f43f197d5
commit 96caebcae1
12 changed files with 108 additions and 152 deletions

View File

@@ -108,11 +108,7 @@ class BaseObject(BaseResource):
return
with transaction.atomic():
action = UserActionLogEntry.objects.create(
user=user,
action=UserAction.DELETED,
timestamp=timezone.now()
)
action = UserActionLogEntry.get_deleted_action(user)
self.deleted = action
self.log.add(action)
self.save()
@@ -207,10 +203,7 @@ class RecordableObjectMixin(models.Model):
Returns:
"""
action = UserActionLogEntry.objects.create(
user=user,
action=UserAction.UNRECORDED
)
action = UserActionLogEntry.get_unrecorded_action(user)
self.recorded = None
self.save()
self.log.add(action)
@@ -225,10 +218,7 @@ class RecordableObjectMixin(models.Model):
Returns:
"""
action = UserActionLogEntry.objects.create(
user=user,
action=UserAction.RECORDED
)
action = UserActionLogEntry.get_recorded_action(user)
self.recorded = action
self.save()
self.log.add(action)
@@ -287,10 +277,7 @@ class CheckableObjectMixin(models.Model):
Returns:
"""
action = UserActionLogEntry.objects.create(
user=user,
action=UserAction.CHECKED
)
action = UserActionLogEntry.get_checked_action(user)
self.checked = action
self.save()
self.log.add(action)