diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py index 92db963dfc9f342f59f329762bf3356b540b65cb..17e69794bfb819f7dcb1a72656eb55e2603ca493 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py @@ -164,6 +164,52 @@ class ProjectState(AbstractChoice): SUSPENDED = "suspended" +class SystemEventType(AbstractChoice): + """Defines the model and predefined list of possible issue_types of a SystemEvent. + The items in the Choices class below are automagically populated into the database via a data migration.""" + class Choices(Enum): + CEP = "cep" + COBALT = "cobalt" + ENVIRONMENT = "environment" + HUMAN ="human" + NETWORK = "network" + STATION = "station" + SYSTEM = "system" + OTHER = "other" + + +class SystemEventSubtype(AbstractChoice): + """Defines the model and predefined list of possible issue_subtypes of a SystemEvent. + The items in the Choices class below are automagically populated into the database via a data migration.""" + class Choices(Enum): + CRASH = "crash" + DATALOSS = "dataloss" + HARDWARE = "hardware" + NOISY = "noisy" + OSCILLATING = "oscillating" + RFI = "rfi" + SETUP = "setup" + TEMPERATURE = "temperature" + OTHER = "other" + + +class SystemEventSeverity(AbstractChoice): + """Defines the model and predefined list of possible severity levels of a SystemEvent. + The items in the Choices class below are automagically populated into the database via a data migration.""" + class Choices(Enum): + FAILURE = "failure" + MINOR = "minor" + MAJOR = "major" + + +class SystemEventStatus(AbstractChoice): + """Defines the model and predefined list of possible statuses of a SystemEvent. + The items in the Choices class below are automagically populated into the database via a data migration.""" + class Choices(Enum): + OPEN = "open" + ANALYSED = "analysed" + + # concrete models class Setting(BasicCommon): @@ -350,6 +396,9 @@ class ReservationStrategyTemplate(NamedCommon): class ReservationTemplate(Template): pass +class SystemEventTemplate(Template): + pass + # # Instance Objects @@ -1415,3 +1464,17 @@ class Reservation(NamedCommon, TemplateSchemaMixin): self.annotate_validate_add_defaults_to_doc_using_template('specifications_doc', 'specifications_template') super().save(force_insert, force_update, using, update_fields) + +class SystemEvent(NamedCommon): + created_by = ForeignKey('TMSSUser', null=False, on_delete=PROTECT, help_text='User who created this entry.') + start = DateTimeField(help_text='When this event started.') + stop = DateTimeField(null=True, help_text='When this event stopped (NULLable).') + issue_type = ForeignKey('SystemEventType', on_delete=PROTECT, help_text='The main type that classifies this issue') + issue_subtype = ForeignKey('SystemEventSubtype', on_delete=PROTECT, help_text='The subtype that classifies this issue') + severity = ForeignKey('SystemEventSeverity', on_delete=PROTECT, help_text='The subtype that classifies this issue') + notes = CharField(max_length=255, help_text='Any additional information') + status = ForeignKey('SystemEventStatus', on_delete=PROTECT, help_text='The current status of this issue') + affected_hardware_doc = JSONField(help_text='Properties of this event, e.g. station list and other hardware affected') + affected_hardware_template = ForeignKey('SystemEventTemplate', on_delete=PROTECT, help_text='Template for the affected_hardware_doc.') + affected_tasks = ManyToManyField('TaskBlueprint', related_name='system_events', null=False, help_text='The task blueprints that are affected by this issue') + jira_url = CharField(max_length=255, help_text='Link to JIRA issue (if any)') \ No newline at end of file