This will remove imports from __future__ that are no longer needed. https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
|
def backfill_refundability(apps, schema_editor):
|
|
CourseEntitlementSupportDetail = apps.get_model('entitlements', 'CourseEntitlementSupportDetail')
|
|
for support_detail in CourseEntitlementSupportDetail.objects.all().select_related('entitlement'):
|
|
support_detail.entitlement.refund_locked = True
|
|
support_detail.entitlement.save()
|
|
|
|
|
|
def revert_backfill(apps, schema_editor):
|
|
CourseEntitlementSupportDetail = apps.get_model('entitlements', 'CourseEntitlementSupportDetail')
|
|
for support_detail in CourseEntitlementSupportDetail.objects.all().select_related('entitlement'):
|
|
support_detail.entitlement.refund_locked = False
|
|
support_detail.entitlement.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('entitlements', '0009_courseentitlement_refund_locked'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(backfill_refundability, revert_backfill),
|
|
]
|