Skip to content

Commit

Permalink
QuestionBank attach in Questionnaire bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Sep 27, 2023
1 parent 90eedee commit 66af6d5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/qbank/base_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Category2(models.IntegerChoices):
LOCAL_INTEGRATION = 10307, 'Local integration'
# -- CASUALTIES
# -- -- CONTEXT - INTRODUCTION
CROSS = 10401, 'Dead'
CROSS = 10401, 'Cross'
DEAD = 10402, 'Dead'
INJURED = 10403, 'Injured'
MISSING = 10404, 'Missing'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='qbleafgroup',
name='category_2',
field=models.PositiveSmallIntegerField(choices=[(10101, 'Introduction'), (10102, 'Politics'), (10103, 'Economics'), (10104, 'Environment'), (10105, 'Socio-cultural'), (10106, 'Demographics'), (10107, 'Security and stability'), (10201, 'Type and characteristics'), (10202, 'Aggravating factors'), (10203, 'Mitigating factors'), (10204, 'Threats and hazards'), (10301, 'Introduction people arriving'), (10302, 'Introduction people leaving'), (10304, 'Pull factors'), (10305, 'Push factors'), (10306, 'Intentions'), (10307, 'Local integration'), (10401, 'Dead'), (10402, 'Dead'), (10403, 'Injured'), (10404, 'Missing'), (10501, 'Communication sources and means'), (10502, 'Challenges and barriers'), (10503, 'Knowledge and information gaps (population)'), (10504, 'Knowledge and information gaps (humanitarians)'), (10601, 'Introduction humanitarian actors barriers'), (10602, 'Introduction people affected barriers'), (10603, 'Population to relief'), (10604, 'Relief to population'), (10605, 'Physical and security constraints'), (10606, 'People facing humanitarian access constraints/Humanitarian access gaps'), (10701, 'Questionnaire characteristics'), (10702, 'Enumerator characteristics'), (10703, 'Respondent characteristics'), (10704, 'Area characteristics'), (10705, 'Affected group characteristics'), (10901, 'Food'), (10902, 'Wash'), (10903, 'Shelter and domestic items'), (20101, 'Drivers'), (20102, 'Impact on people'), (20103, 'Impact on systems, services and networks'), (20104, 'Number of people affected'), (20201, 'Living standards'), (20202, 'Coping mechanisms'), (20203, 'Physical and mental well being'), (20204, 'Number of people in need'), (20301, 'People at risk'), (20302, 'Number of people at risk'), (20401, 'Priority needs'), (20402, 'Priority interventions'), (20501, 'Government and local authorities'), (20502, 'International organizations'), (20503, 'National and local organizations'), (20504, 'Red cross Red Crescent'), (20505, 'Humanitarian coordination'), (20506, 'People reached and response gaps')]),
field=models.PositiveSmallIntegerField(choices=[(10101, 'Introduction'), (10102, 'Politics'), (10103, 'Economics'), (10104, 'Environment'), (10105, 'Socio-cultural'), (10106, 'Demographics'), (10107, 'Security and stability'), (10201, 'Type and characteristics'), (10202, 'Aggravating factors'), (10203, 'Mitigating factors'), (10204, 'Threats and hazards'), (10301, 'Introduction people arriving'), (10302, 'Introduction people leaving'), (10304, 'Pull factors'), (10305, 'Push factors'), (10306, 'Intentions'), (10307, 'Local integration'), (10401, 'Cross'), (10402, 'Dead'), (10403, 'Injured'), (10404, 'Missing'), (10501, 'Communication sources and means'), (10502, 'Challenges and barriers'), (10503, 'Knowledge and information gaps (population)'), (10504, 'Knowledge and information gaps (humanitarians)'), (10601, 'Introduction humanitarian actors barriers'), (10602, 'Introduction people affected barriers'), (10603, 'Population to relief'), (10604, 'Relief to population'), (10605, 'Physical and security constraints'), (10606, 'People facing humanitarian access constraints/Humanitarian access gaps'), (10701, 'Questionnaire characteristics'), (10702, 'Enumerator characteristics'), (10703, 'Respondent characteristics'), (10704, 'Area characteristics'), (10705, 'Affected group characteristics'), (10901, 'Food'), (10902, 'Wash'), (10903, 'Shelter and domestic items'), (20101, 'Drivers'), (20102, 'Impact on people'), (20103, 'Impact on systems, services and networks'), (20104, 'Number of people affected'), (20201, 'Living standards'), (20202, 'Coping mechanisms'), (20203, 'Physical and mental well being'), (20204, 'Number of people in need'), (20301, 'People at risk'), (20302, 'Number of people at risk'), (20401, 'Priority needs'), (20402, 'Priority interventions'), (20501, 'Government and local authorities'), (20502, 'International organizations'), (20503, 'National and local organizations'), (20504, 'Red cross Red Crescent'), (20505, 'Humanitarian coordination'), (20506, 'People reached and response gaps')]),
),
migrations.AlterField(
model_name='qbleafgroup',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='questionleafgroup',
name='category_2',
field=models.PositiveSmallIntegerField(choices=[(10101, 'Introduction'), (10102, 'Politics'), (10103, 'Economics'), (10104, 'Environment'), (10105, 'Socio-cultural'), (10106, 'Demographics'), (10107, 'Security and stability'), (10201, 'Type and characteristics'), (10202, 'Aggravating factors'), (10203, 'Mitigating factors'), (10204, 'Threats and hazards'), (10301, 'Introduction people arriving'), (10302, 'Introduction people leaving'), (10304, 'Pull factors'), (10305, 'Push factors'), (10306, 'Intentions'), (10307, 'Local integration'), (10401, 'Dead'), (10402, 'Dead'), (10403, 'Injured'), (10404, 'Missing'), (10501, 'Communication sources and means'), (10502, 'Challenges and barriers'), (10503, 'Knowledge and information gaps (population)'), (10504, 'Knowledge and information gaps (humanitarians)'), (10601, 'Introduction humanitarian actors barriers'), (10602, 'Introduction people affected barriers'), (10603, 'Population to relief'), (10604, 'Relief to population'), (10605, 'Physical and security constraints'), (10606, 'People facing humanitarian access constraints/Humanitarian access gaps'), (10701, 'Questionnaire characteristics'), (10702, 'Enumerator characteristics'), (10703, 'Respondent characteristics'), (10704, 'Area characteristics'), (10705, 'Affected group characteristics'), (10901, 'Food'), (10902, 'Wash'), (10903, 'Shelter and domestic items'), (20101, 'Drivers'), (20102, 'Impact on people'), (20103, 'Impact on systems, services and networks'), (20104, 'Number of people affected'), (20201, 'Living standards'), (20202, 'Coping mechanisms'), (20203, 'Physical and mental well being'), (20204, 'Number of people in need'), (20301, 'People at risk'), (20302, 'Number of people at risk'), (20401, 'Priority needs'), (20402, 'Priority interventions'), (20501, 'Government and local authorities'), (20502, 'International organizations'), (20503, 'National and local organizations'), (20504, 'Red cross Red Crescent'), (20505, 'Humanitarian coordination'), (20506, 'People reached and response gaps')]),
field=models.PositiveSmallIntegerField(choices=[(10101, 'Introduction'), (10102, 'Politics'), (10103, 'Economics'), (10104, 'Environment'), (10105, 'Socio-cultural'), (10106, 'Demographics'), (10107, 'Security and stability'), (10201, 'Type and characteristics'), (10202, 'Aggravating factors'), (10203, 'Mitigating factors'), (10204, 'Threats and hazards'), (10301, 'Introduction people arriving'), (10302, 'Introduction people leaving'), (10304, 'Pull factors'), (10305, 'Push factors'), (10306, 'Intentions'), (10307, 'Local integration'), (10401, 'Cross'), (10402, 'Dead'), (10403, 'Injured'), (10404, 'Missing'), (10501, 'Communication sources and means'), (10502, 'Challenges and barriers'), (10503, 'Knowledge and information gaps (population)'), (10504, 'Knowledge and information gaps (humanitarians)'), (10601, 'Introduction humanitarian actors barriers'), (10602, 'Introduction people affected barriers'), (10603, 'Population to relief'), (10604, 'Relief to population'), (10605, 'Physical and security constraints'), (10606, 'People facing humanitarian access constraints/Humanitarian access gaps'), (10701, 'Questionnaire characteristics'), (10702, 'Enumerator characteristics'), (10703, 'Respondent characteristics'), (10704, 'Area characteristics'), (10705, 'Affected group characteristics'), (10901, 'Food'), (10902, 'Wash'), (10903, 'Shelter and domestic items'), (20101, 'Drivers'), (20102, 'Impact on people'), (20103, 'Impact on systems, services and networks'), (20104, 'Number of people affected'), (20201, 'Living standards'), (20202, 'Coping mechanisms'), (20203, 'Physical and mental well being'), (20204, 'Number of people in need'), (20301, 'People at risk'), (20302, 'Number of people at risk'), (20401, 'Priority needs'), (20402, 'Priority interventions'), (20501, 'Government and local authorities'), (20502, 'International organizations'), (20503, 'National and local organizations'), (20504, 'Red cross Red Crescent'), (20505, 'Humanitarian coordination'), (20506, 'People reached and response gaps')]),
),
migrations.AlterField(
model_name='questionleafgroup',
Expand Down
10 changes: 6 additions & 4 deletions apps/questionnaire/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ class Meta:
instance: Questionnaire

def validate(self, data):
qbank = QuestionBank.get_active()
if qbank is None:
raise serializers.ValidationError('No available Question Bank. Please ask admin to add one.')
data['qbank'] = qbank
# For Create. Attach latest QuestionBank
if self.instance is None:
qbank = QuestionBank.get_active()
if qbank is None:
raise serializers.ValidationError('No available Question Bank. Please ask admin to add one.')
data['qbank'] = qbank
return data

def create(self, data):
Expand Down

0 comments on commit 66af6d5

Please sign in to comment.