-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1591 from BLSQ/POLIO-1657-chronogram-make-field-o…
…ptional POLIO-1657 Chronogram: make `user_in_charge` a `CharField` instead of a `ForeignKey`
- Loading branch information
Showing
14 changed files
with
96 additions
and
47 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
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
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
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
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
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
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
17 changes: 17 additions & 0 deletions
17
plugins/polio/migrations/0194_chronogramtask_user_in_charge_new.py
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,17 @@ | ||
# Generated by Django 4.2.14 on 2024-08-27 14:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("polio", "0193_alter_incidentreport_stock_correction"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="chronogramtask", | ||
name="user_in_charge_new", | ||
field=models.CharField(blank=True, max_length=255), | ||
), | ||
] |
30 changes: 30 additions & 0 deletions
30
plugins/polio/migrations/0195_migrate_chronogramtask_user_in_charge.py
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,30 @@ | ||
# Generated by Django 4.2.14 on 2024-08-27 14:49 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def migrate_data_forward(apps, schema_editor): | ||
ChronogramTask = apps.get_model("polio", "ChronogramTask") | ||
tasks = ChronogramTask.objects.filter(user_in_charge__isnull=False).select_related("user_in_charge") | ||
objs = [] | ||
for task in tasks: | ||
user = task.user_in_charge | ||
user_str = "" | ||
if user.first_name and user.last_name: | ||
user_str = f"{user.first_name} {user.last_name}" | ||
elif user.first_name or user.last_name: | ||
user_str = user.first_name or user.last_name | ||
elif user.username: | ||
user_str = user.username | ||
if user_str: | ||
task.user_in_charge_new = user_str | ||
objs.append(task) | ||
ChronogramTask.objects.bulk_update(objs, ["user_in_charge_new"]) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("polio", "0194_chronogramtask_user_in_charge_new"), | ||
] | ||
|
||
operations = [migrations.RunPython(migrate_data_forward, migrations.RunPython.noop, elidable=True)] |
21 changes: 21 additions & 0 deletions
21
plugins/polio/migrations/0196_remove_chronogramtask_user_in_charge_new_and_more.py
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,21 @@ | ||
# Generated by Django 4.2.14 on 2024-08-27 15:11 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("polio", "0195_migrate_chronogramtask_user_in_charge"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="chronogramtask", | ||
name="user_in_charge", | ||
), | ||
migrations.RenameField( | ||
model_name="chronogramtask", | ||
old_name="user_in_charge_new", | ||
new_name="user_in_charge", | ||
), | ||
] |
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
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
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
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