From 49e09475c45aead4f6a99f6904261635a346a79d Mon Sep 17 00:00:00 2001 From: Tanner Prestegard <tanner.prestegard@ligo.org> Date: Fri, 28 Sep 2018 09:25:02 -0500 Subject: [PATCH] Explicitly create 'lvem' and 'public' tags --- .../0025_explicitly_create_access_tags.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 gracedb/events/migrations/0025_explicitly_create_access_tags.py diff --git a/gracedb/events/migrations/0025_explicitly_create_access_tags.py b/gracedb/events/migrations/0025_explicitly_create_access_tags.py new file mode 100644 index 000000000..e514db588 --- /dev/null +++ b/gracedb/events/migrations/0025_explicitly_create_access_tags.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.14 on 2018-09-28 14:21:20 +from __future__ import unicode_literals + +from django.db import migrations + +# Create Tag instances for current list of "blessed" tags. +# Based on current list in settings (26 Oct 2017) + +# List of tag names and display names +TAGS = [ + {'name': 'lvem', 'displayName': 'LV-EM'}, + {'name': 'public', 'displayName': 'Public'}, +] + +def add_tags(apps, schema_editor): + Tag = apps.get_model('events', 'Tag') + + # Create tags + for tag_dict in TAGS: + tag, created = Tag.objects.get_or_create(name=tag_dict['name']) + tag.displayName = tag_dict['displayName'] + tag.save() + +# Note there is no reverse migration since we don't want to remove these tags, +# because they existed already, at least in production. + +class Migration(migrations.Migration): + + dependencies = [ + ('events', '0024_add_labels'), + ] + + operations = [ + migrations.RunPython(add_tags, migrations.RunPython.noop), + ] -- GitLab