Skip to content

Commit bb0d891

Browse files
Change EnumChoiceField to IntegerChoice Field in EAP
1 parent b5b34bf commit bb0d891

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

eap/migrations/0001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Migration(migrations.Migration):
7676
name='EarlyAction',
7777
fields=[
7878
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
79-
('sector', enumfields.fields.EnumIntegerField(enum=deployments.models.Sectors, verbose_name='sector')),
79+
('sector', models.IntegerField(choices=[(0, 'Shelter, Housing And Settlements'), (1, 'Livelihoods'), (2, 'Multi-purpose Cash'), (3, 'Health And Care'), (4, 'Water, Sanitation And Hygiene'), (5, 'Protection, Gender And Inclusion'), (6, 'Education'), (7, 'Migration'), (8, 'Risk Reduction, Climate Adaptation And Recovery'), (9, 'Community Engagement And Accountability'), (10, 'Environment Sustainability'), (11, 'Shelter Cluster Coordination')], verbose_name='sector')),
8080
('budget_per_sector', models.IntegerField(blank=True, null=True, verbose_name='Budget per sector (CHF)')),
8181
('prioritized_risk', models.TextField(blank=True, null=True, verbose_name='Prioritized risk')),
8282
('targeted_people', models.IntegerField(blank=True, null=True, verbose_name='Targeted people')),

eap/models.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from main.enums import TextChoices
66
from deployments.models import Sectors
7-
from enumfields import EnumIntegerField
7+
from main.enums import IntegerChoices
88
from api.models import (
99
Country,
1010
District,
@@ -32,7 +32,23 @@ def __str__(self):
3232

3333

3434
class EarlyAction(models.Model):
35-
sector = EnumIntegerField(Sectors, verbose_name=_('sector'))
35+
class Sector(IntegerChoices):
36+
SHELTER_HOUSING_AND_SETTLEMENTS = 0, _('Shelter, Housing And Settlements')
37+
LIVELIHOODS = 1, _('Livelihoods')
38+
MULTI_PURPOSE_CASH = 2, _('Multi-purpose Cash')
39+
HEALTH_AND_CARE = 3, _('Health And Care')
40+
WATER_SANITATION_AND_HYGIENE = 4, _('Water, Sanitation And Hygiene')
41+
PROTECTION_GENDER_AND_INCLUSION = 5, _('Protection, Gender And Inclusion')
42+
EDUCATION = 6, _('Education')
43+
MIGRATION = 7, _('Migration')
44+
RISK_REDUCTION_CLIMATE_ADAPTATION_AND_RECOVERY = \
45+
8, _('Risk Reduction, Climate Adaptation And Recovery')
46+
COMMUNITY_ENGAGEMENT_AND_ACCOUNTABILITY = \
47+
9, _('Community Engagement And Accountability')
48+
ENVIRONMENT_SUSTAINABILITY = 10, _('Environment Sustainability')
49+
SHELTER_CLUSTER_COORDINATION = 11, _('Shelter Cluster Coordination')
50+
51+
sector = models.IntegerField(choices=Sector.choices, verbose_name=_('sector'))
3652
budget_per_sector = models.IntegerField(verbose_name=_('Budget per sector (CHF)'), null=True, blank=True)
3753
indicators = models.ManyToManyField(EarlyActionIndicator, verbose_name=_('Indicators'), blank=True)
3854

0 commit comments

Comments
 (0)