Refactoring
* adds simple getter methods for UserActionLogEntry * replaces manual creation of UserActionLogEntry with new methods
This commit is contained in:
@@ -67,3 +67,57 @@ class UserActionLogEntry(models.Model):
|
||||
if choice[0] == self.action:
|
||||
return choice[1]
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def get_created_action(cls, user: User, comment: str = None):
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=user,
|
||||
action=UserAction.CREATED,
|
||||
comment=comment,
|
||||
)
|
||||
return action
|
||||
|
||||
@classmethod
|
||||
def get_edited_action(cls, user: User, comment: str = None):
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=user,
|
||||
action=UserAction.EDITED,
|
||||
comment=comment,
|
||||
)
|
||||
return action
|
||||
|
||||
@classmethod
|
||||
def get_deleted_action(cls, user: User, comment: str = None):
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=user,
|
||||
action=UserAction.DELETED,
|
||||
comment=comment,
|
||||
)
|
||||
return action
|
||||
|
||||
@classmethod
|
||||
def get_checked_action(cls, user: User, comment: str = None):
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=user,
|
||||
action=UserAction.CHECKED,
|
||||
comment=comment,
|
||||
)
|
||||
return action
|
||||
|
||||
@classmethod
|
||||
def get_recorded_action(cls, user: User, comment: str = None):
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=user,
|
||||
action=UserAction.RECORDED,
|
||||
comment=comment,
|
||||
)
|
||||
return action
|
||||
|
||||
@classmethod
|
||||
def get_unrecorded_action(cls, user: User, comment: str = None):
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=user,
|
||||
action=UserAction.UNRECORDED,
|
||||
comment=comment,
|
||||
)
|
||||
return action
|
||||
|
||||
Reference in New Issue
Block a user