From 68f19f2f285d98cb0a2d76ee902d9d179aa35c2b Mon Sep 17 00:00:00 2001
From: jkuensem <jkuensem@physik.uni-bielefeld.de>
Date: Mon, 30 Mar 2020 18:50:17 +0200
Subject: [PATCH] TMSS-162: make user nullable (for fixtures)

---
 SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py | 4 ++--
 SAS/TMSS/src/tmss/tmssapp/models/scheduling.py       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py b/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py
index eacf9174e25..054fee4f510 100644
--- a/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py
+++ b/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py
@@ -527,11 +527,11 @@ class Migration(migrations.Migration):
                 ('tags', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=128), blank=True, default=list, help_text='User-defined search keywords for object.', size=8)),
                 ('created_at', models.DateTimeField(auto_now_add=True, help_text='Moment of object creation.')),
                 ('updated_at', models.DateTimeField(auto_now=True, help_text='Moment of last object update.')),
-                ('user_identifier', models.CharField(editable=False, help_text='The ID of the user who changed the state of the subtask.', max_length=128)),
+                ('user_identifier', models.CharField(editable=False, help_text='The ID of the user who changed the state of the subtask.', null=True, max_length=128)),
                 ('new_state', models.ForeignKey(editable=False, help_text='Subtask state after update (see Subtask State Machine).', on_delete=django.db.models.deletion.PROTECT, related_name='is_new_state_of', to='tmssapp.SubtaskState')),
                 ('old_state', models.ForeignKey(editable=False, help_text='Subtask state before update (see Subtask State Machine).', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='is_old_state_of', to='tmssapp.SubtaskState')),
                 ('subtask', models.ForeignKey(editable=False, help_text='Subtask to which this state change refers.', on_delete=django.db.models.deletion.CASCADE, to='tmssapp.Subtask')),
-                ('user', models.ForeignKey(editable=False, help_text='The user who changed the state of the subtask.', on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
+                ('user', models.ForeignKey(editable=False, help_text='The user who changed the state of the subtask.', null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
             ],
             options={
                 'abstract': False,
diff --git a/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py b/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py
index 3b215fa8a86..3ff978a222e 100644
--- a/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py
+++ b/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py
@@ -205,8 +205,8 @@ class SubtaskStateLog(BasicCommon):
     available to keep track of changes more generally: https://djangopackages.org/grids/g/model-audit/
     This seems a bit overkill at the moment and we have to manage access to those logs etc., this needs tbd.
     """
-    user = ForeignKey(User, null=False, editable=False, on_delete=PROTECT, help_text='The user who changed the state of the subtask.')
-    user_identifier = CharField(null=False, editable=False, max_length=128, help_text='The ID of the user who changed the state of the subtask.')
+    user = ForeignKey(User, null=True, editable=False, on_delete=PROTECT, help_text='The user who changed the state of the subtask.')
+    user_identifier = CharField(null=True, editable=False, max_length=128, help_text='The ID of the user who changed the state of the subtask.')
     subtask = ForeignKey('Subtask', null=False,  editable=False, on_delete=CASCADE, help_text='Subtask to which this state change refers.')
     old_state = ForeignKey('SubtaskState', null=True,  editable=False, on_delete=PROTECT, related_name='is_old_state_of', help_text='Subtask state before update (see Subtask State Machine).')
     new_state = ForeignKey('SubtaskState', null=False, editable=False, on_delete=PROTECT, related_name='is_new_state_of', help_text='Subtask state after update (see Subtask State Machine).')
-- 
GitLab