diff --git a/django/website/hid/migrations/0003_rename_question_type_terms.py b/django/website/hid/migrations/0003_rename_question_type_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..e0ffc91838a82eb8de2d5a8ca41f732d799f9c41 --- /dev/null +++ b/django/website/hid/migrations/0003_rename_question_type_terms.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + +QUESTION_TYPES = ( + ('Ebola updates', 'What are the current updates on Ebola.'), + ('Ebola authenticity', 'Is Ebola a real disease.'), + ('Ebola prevention', 'What measures could be put in place to end Ebola.'), + ('Ebola origins', 'What is the origin of Ebola.'), + ('Non-Ebola concerns', 'All other non-Ebola related concerns.'), + ('Ebola symptoms', 'What are the symptoms of Ebola.'), + ('Ebola vaccine', 'What is the status of the Ebola vaccine.'), + ('Liberia Ebola-free', 'Can Liberia be Ebola free.'), + ('Unknown', 'Unknown.'), +) + + +def rename_question_type_terms(apps, schema_editor): + Taxonomy = apps.get_model('taxonomies', 'Taxonomy') + Term = apps.get_model('taxonomies', 'Term') + (taxonomy, _) = Taxonomy.objects.get_or_create( + slug="ebola-questions", + name="Ebola Questions", + ) + Term.objects.filter(taxonomy=taxonomy).delete() + new_terms = [ + Term(name=qt[0], long_name=qt[1], taxonomy=taxonomy) + for qt in QUESTION_TYPES + ] + + Term.objects.bulk_create(new_terms) + + +class Migration(migrations.Migration): + + dependencies = [ + ('hid', '0002_rename_question_type_terms'), + ] + + operations = [ + migrations.RunPython(rename_question_type_terms) + ]