From 04bf99cdc7765d60fb6a352b945b7e7cc552d6db Mon Sep 17 00:00:00 2001
From: Tanner Prestegard <tanner.prestegard@ligo.org>
Date: Wed, 18 Jan 2017 09:00:14 -0600
Subject: [PATCH] adding many MOU groups as EMGroup objects

---
 .../migrations/0014_add_many_MOU_EMGroups.py  | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 gracedb/migrations/0014_add_many_MOU_EMGroups.py

diff --git a/gracedb/migrations/0014_add_many_MOU_EMGroups.py b/gracedb/migrations/0014_add_many_MOU_EMGroups.py
new file mode 100644
index 000000000..ee233594f
--- /dev/null
+++ b/gracedb/migrations/0014_add_many_MOU_EMGroups.py
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+new_EMGroups = [
+    '1M2H',
+    'AAOGW',
+    'AGILE',
+    'ANTARES',
+    'Apertif-EVN',
+    'AST3',
+    'Auger',
+    'AZTEC-GW',
+    'BlackGEM',
+    'COSI',
+    'CTA ',
+    'CZTI-IUCAA',
+    'DLT40',
+    'DWF',
+    'FAST',
+    'GROND',
+    'Huntsman',
+    'HXMT',
+    'IceCube',
+    'IKI_GRB',
+    'IPN',
+    'MeerKAT',
+    'NenuFAR',
+    'NRAO',
+    'NTE',
+    'OGWARTS',
+    'RIMAS',
+    'SRG-eROSITA',
+    'TLC X-ray Imaging',
+    'UNC-LFP',
+]
+
+def add_MOU_EMGroups(apps, schema_editor):
+    EMGroup = apps.get_model('gracedb','EMGroup')
+    for g_name in new_EMGroups:
+        grp, created = EMGroup.objects.get_or_create(name=g_name)
+        if created:
+            grp.save()
+
+def remove_MOU_EMGroups(apps, schema_editor):
+    EMGroup = apps.get_model('gracedb','EMGroup')
+    for g_name in new_EMGroups:
+        try:
+            EMGroup.objects.get(name=g_name).delete()
+        except:
+            pass
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('gracedb', '0013_add_ATLAS_to_EMGroups'),
+    ]
+
+    operations = [
+        migrations.RunPython(add_MOU_EMGroups, remove_MOU_EMGroups),
+    ]
-- 
GitLab