From b89d1caea493503eb948a23e40f73220efe0b625 Mon Sep 17 00:00:00 2001 From: jkuensem <jkuensem@physik.uni-bielefeld.de> Date: Fri, 27 Mar 2020 16:41:23 +0100 Subject: [PATCH] TMSS-162: process review comments --- SAS/TMSS/src/remakemigrations.py | 5 ++--- SAS/TMSS/src/tmss/tmssapp/models/scheduling.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/SAS/TMSS/src/remakemigrations.py b/SAS/TMSS/src/remakemigrations.py index c80a7b17b8e..9c7bd57ed55 100755 --- a/SAS/TMSS/src/remakemigrations.py +++ b/SAS/TMSS/src/remakemigrations.py @@ -38,15 +38,15 @@ def execute_and_log(cmd): if err is not None: logger.info("STDERR: %s" % err.decode('utf-8').strip()) -def delete_old_migrations(): +def delete_old_migrations(): logger.info('Removing old migrations...') files = glob_migrations() for f in [path for path in files if ("auto" in path or "populate" in path)]: logger.info('Deleting: %s' % f) os.remove(f) - #execute_and_log('git rm %s' % f) + def make_django_migrations(): @@ -92,7 +92,6 @@ def remake_migrations(): delete_old_migrations() make_django_migrations() make_populate_migration() - #put_migrations_under_version_control() if __name__ == "__main__": diff --git a/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py b/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py index 6643f4e7b15..3b215fa8a86 100644 --- a/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py +++ b/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py @@ -180,13 +180,18 @@ class Subtask(BasicCommon): '''override of normal save method, doing a validation of the specification against the schema first :raises SpecificationException in case the specification does not validate against the schema''' self.validate_specification_against_schema() - creating = self._state.adding + creating = self._state.adding # True on create, False on update super().save(force_insert, force_update, using, update_fields) + # log if either state update or new entry: if self.state != self.__original_state or creating is True: - state_update = SubtaskStateLog(subtask=self, old_state=self.__original_state, new_state=self.state, - user=self.created_or_updated_by_user, user_identifier=self.created_or_updated_by_user.email) - state_update.save() + if self.created_or_updated_by_user is None: + identifier = None + else: + identifier = self.created_or_updated_by_user.email + log_entry = SubtaskStateLog(subtask=self, old_state=self.__original_state, new_state=self.state, + user=self.created_or_updated_by_user, user_identifier=identifier) + log_entry.save() -- GitLab