Refactoring
* adds simple getter methods for UserActionLogEntry * replaces manual creation of UserActionLogEntry with new methods
This commit is contained in:
+5
-15
@@ -25,7 +25,7 @@ from konova.contexts import BaseContext
|
||||
from konova.models import BaseObject, Geometry, RecordableObjectMixin
|
||||
from konova.settings import DEFAULT_SRID
|
||||
from konova.utils.message_templates import FORM_INVALID
|
||||
from user.models import UserActionLogEntry, UserAction
|
||||
from user.models import UserActionLogEntry
|
||||
|
||||
|
||||
class BaseForm(forms.Form):
|
||||
@@ -168,11 +168,7 @@ class RemoveForm(BaseForm):
|
||||
if self.object_to_remove is not None and self.is_checked():
|
||||
with transaction.atomic():
|
||||
self.object_to_remove.is_active = False
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=user,
|
||||
timestamp=timezone.now(),
|
||||
action=UserAction.DELETED
|
||||
)
|
||||
action = UserActionLogEntry.get_deleted_action(user)
|
||||
self.object_to_remove.deleted = action
|
||||
self.object_to_remove.save()
|
||||
return self.object_to_remove
|
||||
@@ -397,10 +393,9 @@ class NewDocumentForm(BaseModalForm):
|
||||
|
||||
def save(self):
|
||||
with transaction.atomic():
|
||||
action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.CREATED,
|
||||
)
|
||||
action = UserActionLogEntry.get_created_action(self.user)
|
||||
edited_action = UserActionLogEntry.get_edited_action(self.user, _("Added document"))
|
||||
|
||||
doc = self.document_model.objects.create(
|
||||
created=action,
|
||||
title=self.cleaned_data["title"],
|
||||
@@ -410,11 +405,6 @@ class NewDocumentForm(BaseModalForm):
|
||||
instance=self.instance,
|
||||
)
|
||||
|
||||
edited_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.EDITED,
|
||||
comment=_("Added document"),
|
||||
)
|
||||
self.instance.log.add(edited_action)
|
||||
self.instance.modified = edited_action
|
||||
self.instance.save()
|
||||
|
||||
Reference in New Issue
Block a user