-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #352 from stveit/event_type_stateless
Add new Event type stateless
- Loading branch information
Showing
6 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 3.2.11 on 2022-03-01 12:34 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def add_stateless_event_type(apps, schema_editor): | ||
# Change INCIDENT_START events for stateless incidents to STATELESS | ||
Event = apps.get_model('argus_incident', 'Event') | ||
for event in Event.objects.all(): | ||
if event.type == "STA" and event.incident.end_time == None: | ||
event.type="LES" | ||
event.save() | ||
|
||
def remove_stateless_event_type(apps, schema_editor): | ||
# undo changes made by add_stateless_event_type | ||
Event = apps.get_model('argus_incident', 'Event') | ||
for event in Event.objects.all(): | ||
if event.type == "LES": | ||
event.type = "STA" | ||
event.save() | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('argus_incident', '0004_add_ChangeEvent_proxy'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='event', | ||
name='type', | ||
field=models.CharField(choices=[('STA', 'Incident start'), ('END', 'Incident end'), ('CHI', 'Incident change'), ('CLO', 'Close'), ('REO', 'Reopen'), ('ACK', 'Acknowledge'), ('OTH', 'Other'), ('LES', 'Stateless')], max_length=3), | ||
), | ||
migrations.RunPython(add_stateless_event_type, remove_stateless_event_type), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters