old_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.11.9 on 2018-03-02 17:45
  from __future__ import unicode_literals
  from waffle.models import Flag
  from django.db import migrations, IntegrityError, transaction
  
  EMBER_WAFFLE_PAGES = [
      'dashboard',
      'create_draft_registration',
      'edit_draft_registration'
      'file_detail',
      'home',
      'meeting_detail',
      'meetings',
      'my_projects',
      'project_analytics',
      'project_contributors',
      'project_detail',
      'project_files',
      'project_forks',
      'project_registrations',
      'project_settings',
      'project_wiki',
      'registration_form_detail',
      'search',
      'support',
      'user_profile',
      'user_settings'
  ]
  
  def reverse_func(state, schema):
      pages = [format_ember_waffle_flag_name(page) for page in EMBER_WAFFLE_PAGES]
      Flag.objects.filter(name__in=pages).delete()
      return
  
  def format_ember_waffle_flag_name(page):
      return '{}{}{}'.format('ember_', page, '_page')
  
  def add_ember_waffle_flags(state, schema):
      """
      This migration adds some waffle flags for pages that are being emberized.
      Waffle flags are used for feature flipping, for example, showing an
      emberized page to one set of users, and the existing osf page for another set.
  
      By default, flags are given an everyone=False value, which overrides all other settings,
      making the flag False for everyone.  Flag settings can be changed in the Django admin app.
      """
      for page in EMBER_WAFFLE_PAGES:
          try:
              with transaction.atomic():
                  Flag.objects.create(name=format_ember_waffle_flag_name(page), everyone=False)
          except IntegrityError as e:
              # just in case someone has already added a flag with this name to the db
              pass
      return
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('osf', '0082_merge_20180213_1502'),
      ]
  
      operations = [
          migrations.RunPython(add_ember_waffle_flags, reverse_func)
      ]
  
new_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.11.9 on 2018-03-02 17:45
  from __future__ import unicode_literals
  from waffle.models import Flag
  from django.db import migrations, IntegrityError, transaction
  
  EMBER_WAFFLE_PAGES = [
      'create_draft_registration',
      'dashboard',
      'edit_draft_registration'
      'file_detail',
      'home',
      'meeting_detail',
      'meetings',
      'my_projects',
      'project_analytics',
      'project_contributors',
      'project_detail',
      'project_files',
      'project_forks',
      'project_registrations',
      'project_settings',
      'project_wiki',
      'registration_form_detail',
      'search',
      'support',
      'user_profile',
      'user_settings'
  ]
  
  def reverse_func(state, schema):
      pages = [format_ember_waffle_flag_name(page) for page in EMBER_WAFFLE_PAGES]
      Flag.objects.filter(name__in=pages).delete()
      return
  
  def format_ember_waffle_flag_name(page):
      return '{}{}{}'.format('ember_', page, '_page')
  
  def add_ember_waffle_flags(state, schema):
      """
      This migration adds some waffle flags for pages that are being emberized.
      Waffle flags are used for feature flipping, for example, showing an
      emberized page to one set of users, and the existing osf page for another set.
  
      By default, flags are given an everyone=False value, which overrides all other settings,
      making the flag False for everyone.  Flag settings can be changed in the Django admin app.
      """
      for page in EMBER_WAFFLE_PAGES:
          try:
              with transaction.atomic():
                  Flag.objects.create(name=format_ember_waffle_flag_name(page), everyone=False)
          except IntegrityError as e:
              # just in case someone has already added a flag with this name to the db
              pass
      return
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('waffle', '0002_auto_20161201_0958'),
      ]
  
      operations = [
          migrations.RunPython(add_ember_waffle_flags, reverse_func)
      ]
  
subject: Make waffle data migration depend on waffle schema migration.