Skip to content

Commit

Permalink
Minor changes in migrations file
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed Jun 10, 2024
1 parent a257ab4 commit fb5f848
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions apps/analysis_framework/migrations/0041_widget_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ def analysis_framework_widgets_mapping(apps, schema_editor):
AnalysisFramework = apps.get_model('analysis_framework', 'AnalysisFramework')
af_qs = AnalysisFramework.objects.filter(properties__isnull=False)
for af in af_qs:
if af.prop == {}:
if af.properties == {}:
continue
af_prop = af.properties
# Remove super legacy config
af_prop.pop('old_stats_config', None)

# For reassurance
af_prop = {
'old_stats_config': copy.deepcopy(af_prop),
}
old_stats_config = copy.deepcopy(af_prop)

# Migrate legacy config to latest
# -- Widget1D
Expand All @@ -35,18 +33,18 @@ def analysis_framework_widgets_mapping(apps, schema_editor):

# -- Organigram
af_prop['stats_config']['organigram_widgets'] = (
af_prop['stats_config'].get('affected_groups_widgets') or
af_prop['stats_config'].get('affected_groups_widget') or
af_prop['stats_config'].get('organigram_widgets') or
af_prop['stats_config'].get('organigram_widget') or
[]
)

# -- Multiselect
af_prop['stats_config']['multiselect_widgets'] = (
af_prop['stats_config'].get('specific_needs_groups_widgets') or
af_prop['stats_config'].get('specific_needs_groups_widget') or
af_prop['stats_config'].get('multiselect_widgets') or
af_prop['stats_config'].get('multiselect_widget') or
af_prop['stats_config'].get('demographic_group_widget') or
af_prop['stats_config'].get('demographic_groups_widget') or
[]
)

Expand All @@ -57,12 +55,14 @@ def analysis_framework_widgets_mapping(apps, schema_editor):
'specific_needs_groups_widgets',
'affected_groups_widget',
'specific_needs_groups_widget',
'demographic_group_widget',
'demographic_group_widgets',
'specificNeedsGroupsWidget',
]
for widget_key in legacy_widget_keys:
af_prop['stats_config'].pop(widget_key, None)

af.properties = af_prop
af.properties['old_stats_config'] = old_stats_config
af.save(update_fields=('properties',))


Expand Down

0 comments on commit fb5f848

Please sign in to comment.