-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OSDEV-1084] Claims. Update logic for number of workers. (#231)
[OSDEV-1084](https://opensupplyhub.atlassian.net/browse/OSDEV-1084) Claims. Update logic for number of workers. The implementation of this issue makes it possible to add a range for the number of workers during the claiming process, either after pressing the “I want to claim this production location” link or on the Claimed Facility Details page. To change the type of the `facility_workers_count` field in the `FacilityClaim` table from `IntegerField` to `CharField`, there were added migrations with the next sequence: * 0146_add_facility_workers_count_new_field_to_facilityclaim - adds the facility_workers_count_new field to the FacilityClaim model. * 0147_copy_facility_workers_count_to_facility_workers_count_new - copies the data from the facility_workers_count field to the facility_workers_count_new field. * 0148_remove_facility_workers_count_field_from_facilityclaim - removes the facility_workers_count field from the FacilityClaim model. * 0149_rename_facility_workers_count_new_to_facility_workers_count - renames the facility_workers_count_new field to facility_workers_count.
- Loading branch information
1 parent
6ec6ec9
commit d12b03f
Showing
15 changed files
with
210 additions
and
57 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
37 changes: 37 additions & 0 deletions
37
src/django/api/migrations/0146_add_facility_workers_count_new_field_to_facilityclaim.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,37 @@ | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
''' | ||
This migration adds the facility_workers_count_new field | ||
to the FacilityClaim model. | ||
''' | ||
|
||
dependencies = [ | ||
('api', '0145_new_functions_for_clean_facilitylistitems_command'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='facilityclaim', | ||
name='facility_workers_count_new', | ||
field=models.CharField( | ||
blank=True, | ||
help_text='The editable facility workers count for this claim', | ||
max_length=200, | ||
null=True, | ||
verbose_name='facility workers count', | ||
), | ||
), | ||
migrations.AddField( | ||
model_name='historicalfacilityclaim', | ||
name='facility_workers_count_new', | ||
field=models.CharField( | ||
blank=True, | ||
help_text='The editable facility workers count for this claim', | ||
max_length=200, | ||
null=True, | ||
verbose_name='facility workers count', | ||
), | ||
), | ||
] |
26 changes: 26 additions & 0 deletions
26
src/django/api/migrations/0147_copy_facility_workers_count_to_facility_workers_count_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,26 @@ | ||
from django.db import migrations | ||
|
||
|
||
def copy_integer_to_char(apps, schema_editor): | ||
FacilityClaim = apps.get_model('api', 'FacilityClaim') | ||
for instance in FacilityClaim.objects.all(): | ||
if instance.facility_workers_count: | ||
instance.facility_workers_count_new = str( | ||
instance.facility_workers_count | ||
) | ||
instance.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
''' | ||
This migration copies the data from the facility_workers_count field | ||
to the facility_workers_count_new field. | ||
''' | ||
|
||
dependencies = [ | ||
('api', '0146_add_facility_workers_count_new_field_to_facilityclaim'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(copy_integer_to_char), | ||
] |
26 changes: 26 additions & 0 deletions
26
src/django/api/migrations/0148_remove_facility_workers_count_field_from_facilityclaim.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,26 @@ | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
''' | ||
This migration removes the facility_workers_count field | ||
from the FacilityClaim model. | ||
''' | ||
|
||
dependencies = [ | ||
( | ||
'api', | ||
'0147_copy_facility_workers_count_to_facility_workers_count_new', | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='facilityclaim', | ||
name='facility_workers_count', | ||
), | ||
migrations.RemoveField( | ||
model_name='historicalfacilityclaim', | ||
name='facility_workers_count', | ||
), | ||
] |
25 changes: 25 additions & 0 deletions
25
...django/api/migrations/0149_rename_facility_workers_count_new_to_facility_workers_count.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,25 @@ | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
''' | ||
This migration renames the facility_workers_count_new field | ||
to facility_workers_count. | ||
''' | ||
|
||
dependencies = [ | ||
('api', '0148_remove_facility_workers_count_field_from_facilityclaim'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='facilityclaim', | ||
old_name='facility_workers_count_new', | ||
new_name='facility_workers_count', | ||
), | ||
migrations.RenameField( | ||
model_name='historicalfacilityclaim', | ||
old_name='facility_workers_count_new', | ||
new_name='facility_workers_count', | ||
), | ||
] |
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
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
Oops, something went wrong.