

def populate_flow(apps, schema_editor):
    FlowEvent = apps.get_model('periods', 'FlowEvent')
    Period = apps.get_model('periods', 'Period')
    for period in Period.objects.all():
        if period.start_time:
            start_time = period.start_time
        else:
            start_time = datetime.time()
        flow = FlowEvent(user=period.user, timestamp=datetime.datetime.combine(period.start_date, start_time), first_day=True)
        flow.save()
    Group = apps.get_model('auth', 'Group')
    Permission = apps.get_model('auth', 'Permission')
    app_config = apps.get_app_config('periods')
    app_config.models_module = periods.models
    auth.management.create_permissions(Group, verbosity=0)
    try:
        group = Group.objects.get(name='users')
    except Group.DoesNotExist:
        group = Group(name='users')
        group.save()
    group.permissions.remove(*Permission.objects.filter(codename__endswith='_period').all())
    group.permissions.add(*Permission.objects.filter(codename__endswith='_flowevent').all())
    group.save()

dataset/ETHPy150Open jessamynsmith/eggtimer-server/periods/migrations/0005_auto_20150222_1302.py populate_flow/VarMisuse@156/211 `app_config`->`Group`