old_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.10.8 on 2018-06-13 16:48
  from __future__ import unicode_literals
  
  from django.db import migrations
  from collections import namedtuple
  
  criterion_fields = ["type", "name", "count", "weight", "option"]
  CriterionData = namedtuple("CriterionData", criterion_fields)
  criteria = {}
  criteria_specs = [
      ("reads", "reads", "4", "1", ""),
      ("matching", "industry", "1", "1", ""),
      ("matching", "program", "1", "1", ""),
      ("judge", "role", "2", "1", "Executive"),
      ("judge", "role", "1", "1", "Investor"),
      ("judge", "role", "1", "1", "Lawyer"),
      ("judge", "gender", "1", "1", "female"),
      ("judge", "gender", "1", "1", "male"),
  ]
  BOS_2017_JUDGING_ROUND_ID = 48
  
  
  def create_initial_criteria(apps, schema_editor):
      for spec in criteria_specs:
          handle_spec(spec, apps)
  
  
  def handle_spec(spec, apps):
      Criterion = apps.get_model('accelerator', 'Criterion')
      CriterionOptionSpec = apps.get_model('accelerator', 'CriterionOptionSpec')
      JudgingRound = apps.get_model('accelerator', 'JudgingRound')
  
      data = CriterionData(*spec)
      name = data.name
      jr_exists = JudgingRound.objects.filter(
          id=BOS_2017_JUDGING_ROUND_ID).exists()
      if name not in criteria and jr_exists:
          criteria[name] = Criterion.objects.create(
              name=name,
              type=data.type,
              judging_round_id=BOS_2017_JUDGING_ROUND_ID)
  
      criterion = criteria.get(name)
      if criterion:
          CriterionOptionSpec.objects.create(
              criterion=criterion,
              option=data.option,
              weight=float(data.weight),
              count=int(data.count))
  
  
  def destroy_all_criteria(apps, schema_editor):
      Criterion = apps.get_model('accelerator', 'Criterion')
      CriterionOptionSpec = apps.get_model('accelerator', 'CriterionOptionSpec')
      CriterionOptionSpec.objects.all().delete()
      Criterion.objects.all().delete()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('accelerator', '0008_add_criterion_and_option_spec'),
      ]
  
      operations = [
          migrations.RunPython(create_initial_criteria,
                               destroy_all_criteria)
      ]
  
new_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.10.8 on 2018-06-13 16:48
  from __future__ import unicode_literals
  
  from django.db import migrations
  from collections import namedtuple
  
  criterion_fields = ["type", "name", "count", "weight", "option"]
  CriterionData = namedtuple("CriterionData", criterion_fields)
  criteria = {}
  criteria_specs = [
      ("reads", "reads", "4", "1", ""),
      ("matching", "industry", "1", "1", ""),
      ("matching", "program", "1", "1", ""),
      ("judge", "role", "2", "1", "Executive"),
      ("judge", "role", "1", "1", "Investor"),
      ("judge", "role", "1", "1", "Lawyer"),
      ("judge", "gender", "1", "1", "female"),
      ("judge", "gender", "1", "1", "male"),
  ]
  BOS_2017_JUDGING_ROUND_ID = 48
  
  
  def create_initial_criteria(apps, schema_editor):
      for spec in criteria_specs:
          handle_spec(spec, apps)
  
  
  def handle_spec(spec, apps):
      Criterion = apps.get_model('accelerator', 'Criterion')
      CriterionOptionSpec = apps.get_model('accelerator', 'CriterionOptionSpec')
      JudgingRound = apps.get_model('accelerator', 'JudgingRound')
  
      data = CriterionData(*spec)
      name = data.name
      judging_round_exists = JudgingRound.objects.filter(
          id=BOS_2017_JUDGING_ROUND_ID).exists()
      if name not in criteria and judging_round_exists:
          criteria[name] = Criterion.objects.create(
              name=name,
              type=data.type,
              judging_round_id=BOS_2017_JUDGING_ROUND_ID)
  
      criterion = criteria.get(name)
      if criterion:
          CriterionOptionSpec.objects.create(
              criterion=criterion,
              option=data.option,
              weight=float(data.weight),
              count=int(data.count))
  
  
  def destroy_all_criteria(apps, schema_editor):
      Criterion = apps.get_model('accelerator', 'Criterion')
      CriterionOptionSpec = apps.get_model('accelerator', 'CriterionOptionSpec')
      CriterionOptionSpec.objects.all().delete()
      Criterion.objects.all().delete()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('accelerator', '0008_add_criterion_and_option_spec'),
      ]
  
      operations = [
          migrations.RunPython(create_initial_criteria,
                               destroy_all_criteria)
      ]
  
subject: rename variable per review