diff --git a/docs/user_docs/source/labels.rst b/docs/user_docs/source/labels.rst index 46a68af3c0dd9656e7a5f9bcdb224cb5902859c1..b4b19086565e4d5ef696ff34f5b03ebf5aadf556 100644 --- a/docs/user_docs/source/labels.rst +++ b/docs/user_docs/source/labels.rst @@ -51,6 +51,12 @@ Here is a table showing the currently available labels and their meanings. +-----------------+----------------------------------------------------------------------------------------------------------------------------------------+ | H1OPS | H1 operator signoff requested. | +-----------------+----------------------------------------------------------------------------------------------------------------------------------------+ +| HWINJNO | There were problems with the hardware injection. | ++-----------------+----------------------------------------------------------------------------------------------------------------------------------------+ +| HWINJOK | A hardware injection was successfully performed. | ++-----------------+----------------------------------------------------------------------------------------------------------------------------------------+ +| HWINJREQ | A hardware injection is scheduled. | ++-----------------+----------------------------------------------------------------------------------------------------------------------------------------+ | INJ | Injection occured near this time. | +-----------------+----------------------------------------------------------------------------------------------------------------------------------------+ | L1NO | L1 operator says event is not okay. | diff --git a/gracedb/events/migrations/0031_hwinj_labels.py b/gracedb/events/migrations/0031_hwinj_labels.py new file mode 100644 index 0000000000000000000000000000000000000000..12974169db1aa2965cc10107654621b525ce6cea --- /dev/null +++ b/gracedb/events/migrations/0031_hwinj_labels.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-01-16 20:07:23 +from __future__ import unicode_literals + +from django.db import migrations + +# List of label names, default colors, and descriptions +LABELS = [ + { + 'name': 'HWINJREQ', + 'defaultColor': 'black', + 'description': 'A hardware injection is scheduled.', + }, + { + 'name': 'HWINJOK', + 'defaultColor': 'green', + 'description': 'A hardware injection was successfully performed.', + }, + { + 'name': 'HWINJNO', + 'defaultColor': 'red', + 'description': 'There were problems with the hardware injection.', + }, +] + +def add_labels(apps, schema_editor): + Label = apps.get_model('events', 'Label') + + # Create labels + for label_dict in LABELS: + l, created = Label.objects.get_or_create(name=label_dict['name']) + l.defaultColor = label_dict['defaultColor'] + l.description = label_dict['description'] + l.save() + + +def remove_labels(apps, schema_editor): + Label = apps.get_model('events', 'Label') + + # Delete labels + for label_dict in LABELS: + try: + l = Label.objects.get(name=label_dict['name']) + except Label.DoesNotExist: + print('Label {0} not found to be deleted, skipping.' \ + .format(label_dict['name'])) + break + l.delete() + + +class Migration(migrations.Migration): + + dependencies = [ + ('events', '0030_siminspiral_source_and_destination_channels_null'), + ] + + operations = [ + migrations.RunPython(add_labels, remove_labels), + ]