-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In addition to updating the study type field, I am removing the configuration field. Forms have replaced the need for this field.
- Loading branch information
Showing
2 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Generated by Django 3.2.11 on 2023-08-05 15:27 | ||
|
||
from django.db import migrations | ||
|
||
NAMES = { | ||
"external": { | ||
"old": "External", | ||
"new": "External Study (Choose this if you are posting a study link rather using an experiment builder)", | ||
}, | ||
"efp": { | ||
"old": "Ember Frame Player (default)", | ||
"new": "Lookit/Ember Frame Player (Default experiment builder)", | ||
}, | ||
} | ||
|
||
|
||
def study_type_names(apps, from_key, to_key): | ||
study_type = apps.get_model("studies", "StudyType") | ||
|
||
# EFP name field | ||
efp = study_type.objects.get(name=NAMES["efp"][from_key]) | ||
efp.name = NAMES["efp"][to_key] | ||
efp.save() | ||
|
||
# External name field | ||
external = study_type.objects.get(name=NAMES["external"][from_key]) | ||
external.name = NAMES["external"][to_key] | ||
external.save() | ||
|
||
|
||
def update_study_type_names(apps, schema_editor): | ||
"""Update the display names for study types.""" | ||
study_type_names(apps, "old", "new") | ||
|
||
|
||
def revert_study_type_names(apps, schema_editor): | ||
"""Update the display names for study types.""" | ||
study_type_names(apps, "new", "old") | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("studies", "0090_alter_study_preview_summary"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="studytype", | ||
name="configuration", | ||
), | ||
migrations.RunPython( | ||
update_study_type_names, reverse_code=revert_study_type_names | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters