Create change log entry on status updates

This commit is contained in:
2020-09-29 22:19:43 +02:00
parent 96d6dc72fb
commit 5237d81551
6 changed files with 102 additions and 56 deletions

View File

@@ -7,10 +7,6 @@ from django.utils.encoding import python_2_unicode_compatible
from . import get_ghost_user, get_system_user
CHANGE_OPERATIONS = (
('update', 'update'),
)
def get_system_user_id():
return get_system_user().id
@@ -18,6 +14,15 @@ def get_system_user_id():
@python_2_unicode_compatible
class EventChange(models.Model):
UPDATE = 'update'
RAISE_FLAG = 'set_flag'
LOWER_FLAG = 'unset_flag'
OPERATION_CHOICES = (
(UPDATE, 'Update'),
(RAISE_FLAG, 'Raise Flag'),
(LOWER_FLAG, 'Lower Flag'),
)
event = models.ForeignKey('dav_events.Event', related_name='changes')
timestamp = models.DateTimeField(default=timezone.now)
user = models.ForeignKey(settings.AUTH_USER_MODEL,
@@ -25,7 +30,7 @@ class EventChange(models.Model):
on_delete=models.SET(get_ghost_user),
related_name='+')
operation = models.CharField(max_length=20, choices=CHANGE_OPERATIONS)
operation = models.CharField(max_length=20, choices=OPERATION_CHOICES)
content = models.TextField()
class Meta: