diff --git a/SAS/TMSS/src/remakemigrations.py b/SAS/TMSS/src/remakemigrations.py index c80a7b17b8ebe97127ed522bde9ba97ac3e402f9..9c7bd57ed55088d90c08f8277525114811a3938e 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 6643f4e7b15f4a74b3a45aed699f2894b3ba783a..3b215fa8a8699e0452a04ff3d1e595d8770016ae 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()