|
25 | 25 | import openwisp_utils.fields |
26 | 26 | import openwisp_utils.utils |
27 | 27 | from openwisp_radius import settings as app_settings |
28 | | -from openwisp_utils.fields import FallbackMixin |
29 | | - |
30 | | - |
31 | | -# Copied verbatim from 0038_clean_fallbackfields and 0042_set_existing_batches_completed |
32 | | -# because squashmigrations cannot import functions from modules whose names start |
33 | | -# with a digit. Keep these in sync if the originals ever change. |
34 | | -def clean_fallback_fields(apps, schema_editor): |
35 | | - OrganizationRadiusSettings = openwisp_radius.migrations.get_swapped_model( |
36 | | - apps, "openwisp_radius", "organizationradiussettings" |
37 | | - ) |
38 | | - fallback_fields = [] |
39 | | - for field in OrganizationRadiusSettings._meta.get_fields(): |
40 | | - if isinstance(field, FallbackMixin): |
41 | | - fallback_fields.append(field) |
42 | | - updated_settings = [] |
43 | | - for radius_settings in OrganizationRadiusSettings.objects.iterator(): |
44 | | - changed = False |
45 | | - for field in fallback_fields: |
46 | | - if getattr(radius_settings, field.name) == field.fallback: |
47 | | - setattr(radius_settings, field.name, None) |
48 | | - changed = True |
49 | | - if changed: |
50 | | - updated_settings.append(radius_settings) |
51 | | - if len(updated_settings) > 100: |
52 | | - OrganizationRadiusSettings.objects.bulk_update( |
53 | | - updated_settings, fields=[f.name for f in fallback_fields] |
54 | | - ) |
55 | | - updated_settings = [] |
56 | | - if updated_settings: |
57 | | - OrganizationRadiusSettings.objects.bulk_update( |
58 | | - updated_settings, fields=[f.name for f in fallback_fields] |
59 | | - ) |
60 | | - |
61 | | - |
62 | | -def set_existing_batches_completed(apps, schema_editor): |
63 | | - RadiusBatch = apps.get_model("openwisp_radius", "RadiusBatch") |
64 | | - RadiusBatch.objects.all().update(status="completed") |
65 | 28 |
|
66 | 29 |
|
67 | 30 | class Migration(migrations.Migration): |
@@ -1339,10 +1302,6 @@ class Migration(migrations.Migration): |
1339 | 1302 | code=openwisp_radius.migrations.add_default_groups, |
1340 | 1303 | reverse_code=django.db.migrations.operations.special.RunPython.noop, |
1341 | 1304 | ), |
1342 | | - migrations.RunPython( |
1343 | | - code=openwisp_radius.migrations.add_default_group_to_existing_users, |
1344 | | - reverse_code=django.db.migrations.operations.special.RunPython.noop, |
1345 | | - ), |
1346 | 1305 | migrations.RunPython( |
1347 | 1306 | code=openwisp_radius.migrations.assign_permissions_to_groups, |
1348 | 1307 | reverse_code=django.db.migrations.operations.special.RunPython.noop, |
@@ -1573,10 +1532,6 @@ class Migration(migrations.Migration): |
1573 | 1532 | verbose_name="CSV", |
1574 | 1533 | ), |
1575 | 1534 | ), |
1576 | | - migrations.RunPython( |
1577 | | - code=openwisp_radius.migrations.delete_old_radius_token, |
1578 | | - reverse_code=django.db.migrations.operations.special.RunPython.noop, |
1579 | | - ), |
1580 | 1535 | migrations.AddField( |
1581 | 1536 | model_name="radiustoken", |
1582 | 1537 | name="can_auth", |
@@ -1628,10 +1583,6 @@ class Migration(migrations.Migration): |
1628 | 1583 | blank=True, max_length=128, null=True, region=None |
1629 | 1584 | ), |
1630 | 1585 | ), |
1631 | | - migrations.RunPython( |
1632 | | - code=openwisp_radius.migrations.populate_phonetoken_phone_number, |
1633 | | - reverse_code=django.db.migrations.operations.special.RunPython.noop, |
1634 | | - ), |
1635 | 1586 | migrations.AlterField( |
1636 | 1587 | model_name="phonetoken", |
1637 | 1588 | name="phone_number", |
@@ -1996,10 +1947,6 @@ class Migration(migrations.Migration): |
1996 | 1947 | verbose_name="Password reset URL", |
1997 | 1948 | ), |
1998 | 1949 | ), |
1999 | | - migrations.RunPython( |
2000 | | - code=clean_fallback_fields, |
2001 | | - reverse_code=django.db.migrations.operations.special.RunPython.noop, |
2002 | | - ), |
2003 | 1950 | migrations.AlterField( |
2004 | 1951 | model_name="radiusaccounting", |
2005 | 1952 | name="called_station_id", |
@@ -2071,7 +2018,4 @@ class Migration(migrations.Migration): |
2071 | 2018 | max_length=16, |
2072 | 2019 | ), |
2073 | 2020 | ), |
2074 | | - migrations.RunPython( |
2075 | | - code=set_existing_batches_completed, |
2076 | | - ), |
2077 | 2021 | ] |
0 commit comments