Skip to content

Commit

Permalink
Add validation for question in admin side.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rup-Narayan-Rajbanshi committed Aug 9, 2023
1 parent 4f79377 commit 8c82b33
Show file tree
Hide file tree
Showing 15 changed files with 531 additions and 172 deletions.
59 changes: 48 additions & 11 deletions apps/assessment_registry/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
MethodologyAttribute,
Question,
Answer,
SummaryIssue,
ScoreRating,
ScoreAnalyticalDensity,
Summary,
SummarySubPillarIssue,
SummaryFocus,
SummarySubDimmensionIssue,
)


Expand All @@ -24,12 +27,6 @@ def save_model(self, request, obj, form, change):
super().save_model(request, obj, form, change)


@admin.register(Answer)
class AnswerAdmin(admin.ModelAdmin):
list_display = ('id', 'question')
readonly_fields = ('created_by', 'modified_by', 'client_id',)


class MethodologyAttributeInline(admin.TabularInline):
model = MethodologyAttribute
extra = 0
Expand All @@ -54,16 +51,56 @@ class AnalyticalDensityInline(admin.TabularInline):
exclude = ('created_by', 'modified_by', 'client_id')


class SummaryInline(admin.TabularInline):
model = Summary
extra = 0
exclude = ('created_by', 'modified_by', 'client_id')


class SummarySubPillarIssueInline(admin.TabularInline):
model = SummarySubPillarIssue
extra = 0
exclude = ('created_by', 'modified_by', 'client_id')


class SummaryFocusInline(admin.TabularInline):
model = SummaryFocus
extra = 0
exclude = ('created_by', 'modified_by', 'client_id')


class SummarySubDimmensionIssueInline(admin.TabularInline):
model = SummarySubDimmensionIssue
extra = 0
exclude = ('created_by', 'modified_by', 'client_id')


@admin.register(AssessmentRegistry)
class AssessmentRegistryAdmin(admin.ModelAdmin):
list_display = ('id', 'lead', 'project')

list_display = ('id', 'project', 'lead')

autocomplete_fields = (
'created_by',
'modified_by',
'project',
'bg_countries',
'lead_organizations',
'international_partners',
'donors',
'national_partners',
'governments',
'locations',
)
inlines = [
MethodologyAttributeInline,
ScoreInline,
AnalyticalDensityInline,
AnswerInline,
SummaryInline,
SummarySubPillarIssueInline,
SummaryFocusInline,
SummarySubDimmensionIssueInline,
]


admin.site.register(SummaryIssue)
def get_queryset(self, request):
return super().get_queryset(request).prefetch_related('project', 'lead')
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.17 on 2023-08-08 05:15

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('assessment_registry', '0019_auto_20230804_0944'),
]

operations = [
migrations.AlterModelOptions(
name='summaryfocus',
options={'verbose_name': 'SummaryDimmension'},
),
]
154 changes: 154 additions & 0 deletions apps/assessment_registry/migrations/0021_auto_20230808_1125.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Generated by Django 3.2.17 on 2023-08-08 11:25

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('assessment_registry', '0020_alter_summaryfocus_options'),
]

operations = [
migrations.AlterField(
model_name='additionaldocument',
name='document_type',
field=models.IntegerField(choices=[(1, 'Assessment database'), (2, 'Questionnaire'), (3, 'Miscellaneous')]),
),
migrations.AlterField(
model_name='assessmentregistry',
name='affected_groups',
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(choices=[(100, 'All'), (1, 'All/Affected'), (2, 'All/Not Affected'), (3, 'All/Affected/Not Displaced'), (4, 'All/Affected/Displaced'), (5, 'All/Affected/Displaced/In Transit'), (6, 'All/Affected/Displaced/Migrants'), (7, 'All/Affected/Displaced/IDPs'), (8, 'All/Affected/Displced/Asylum Seeker'), (9, 'All/Affected/Displaced/Other of concerns'), (10, 'All/Affected/Displaced/Returnees'), (11, 'All/Affected/Displaced/Refugees'), (12, 'All/Affected/Displaced/Migrants/In transit'), (13, 'All/Affected/Displaced/Migrants/Permanents'), (14, 'All/Affected/Displaced/Migrants/Pendular'), (15, 'All/Affected/Not Displaced/No Host'), (16, 'All/Affected/Not Displaced/Host')]), default=list, size=None),
),
migrations.AlterField(
model_name='assessmentregistry',
name='bg_crisis_type',
field=models.IntegerField(choices=[(100, 'Earth Quake'), (1, 'Ground Shaking'), (2, 'Tsunami'), (3, 'Volcano'), (4, 'Volcanic Eruption'), (5, 'Mass Movement (Dry)'), (6, 'Rockfall'), (7, 'Avalance'), (8, 'Landslide'), (9, 'Subsidence'), (10, 'Extra Tropical Cyclone'), (11, 'Tropical Cyclone'), (12, 'Local/Convective Strom'), (13, 'Flood/Rain'), (14, 'General River Flood'), (15, 'Flash flood'), (16, 'Strom Surge/Coastal Flood'), (17, 'Mass Movement (Wet)'), (18, 'Extreme Temperature'), (19, 'Heat Wave'), (20, 'Cold Wave'), (21, 'Extreme Weather Condition'), (22, 'Drought'), (23, 'Wildfire'), (24, 'Population Displacement'), (25, 'Conflict')]),
),
migrations.AlterField(
model_name='assessmentregistry',
name='bg_preparedness',
field=models.IntegerField(choices=[(1, 'With Preparedness'), (2, 'Without Preparedness')]),
),
migrations.AlterField(
model_name='assessmentregistry',
name='confidentiality',
field=models.IntegerField(choices=[(1, 'Unprotected'), (2, 'Confidential')]),
),
migrations.AlterField(
model_name='assessmentregistry',
name='coordinated_joint',
field=models.IntegerField(choices=[(1, 'Coordinated Joint'), (2, 'Coordinated Harmonized'), (3, 'Uncoordinated')]),
),
migrations.AlterField(
model_name='assessmentregistry',
name='details_type',
field=models.IntegerField(choices=[(1, 'Initial'), (2, 'Rapid'), (3, 'In depth'), (4, 'Monitoring'), (5, 'Other')]),
),
migrations.AlterField(
model_name='assessmentregistry',
name='external_support',
field=models.IntegerField(choices=[(1, 'External Support Received'), (2, 'No External Support Received')]),
),
migrations.AlterField(
model_name='assessmentregistry',
name='family',
field=models.IntegerField(choices=[(100, 'Displacement Traking Matrix'), (1, 'Multi Cluster Initial and Rapid Assessment (MIRA)'), (2, 'Multi sectorial Needs Assessment (MSNA)'), (3, 'Emergency Food Security Assessment (EFSA)'), (4, 'Comprehensive Food Security and Vulnerability Analysis(CFSVA)'), (5, 'Protection Monitoring'), (6, 'Humanitarian Needs Overview (HNO)'), (7, 'Briefing note'), (8, 'Registration'), (9, 'IDPs profiling exercise'), (10, 'Census'), (11, 'Refugee and Migrant Response Plan (RMRP)'), (12, 'Refugee Response Plan (RRP)'), (13, 'Smart Nutrition Survey'), (14, 'Other')]),
),
migrations.AlterField(
model_name='assessmentregistry',
name='focuses',
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(choices=[(100, 'Context'), (1, 'Shock/Event'), (2, 'Displacement'), (3, 'Casualties'), (4, 'Information and Communication'), (5, 'Humaniterian Access'), (6, 'Impact'), (7, 'Humanitarian Conditions'), (8, 'People at risk'), (9, 'Priorities & Preferences'), (10, 'Response and Capacities')]), default=list, size=None),
),
migrations.AlterField(
model_name='assessmentregistry',
name='frequency',
field=models.IntegerField(choices=[(1, 'One off'), (2, 'Regular')]),
),
migrations.AlterField(
model_name='assessmentregistry',
name='language',
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(choices=[(1, 'English'), (2, 'French'), (3, 'Spanish'), (4, 'Portugese'), (5, 'Arabic')]), size=None),
),
migrations.AlterField(
model_name='assessmentregistry',
name='protection_info_mgmts',
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(choices=[(100, 'Protection Monitoring'), (1, 'Protection Needs Assessment'), (2, 'Case Management'), (3, 'Population Data'), (4, 'Protection Response M&E'), (5, 'Communicating with(in) Affected Communities'), (6, 'Security & Situational Awareness'), (7, 'Sectoral System/Other')]), blank=True, null=True, size=None),
),
migrations.AlterField(
model_name='assessmentregistry',
name='sectors',
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(choices=[(100, 'Food Security'), (1, 'Heath'), (2, 'Shelter'), (3, 'Wash'), (4, 'Protection'), (5, 'Nutrition'), (6, 'Livelihood'), (7, 'Education'), (8, 'Logistics'), (9, 'Inter/Cross Sector')]), default=list, size=None),
),
migrations.AlterField(
model_name='methodologyattribute',
name='data_collection_technique',
field=models.IntegerField(blank=True, choices=[(100, 'Secondary Data Review'), (1, 'Key Informant Interview'), (2, 'Direct Observation'), (3, 'Community Group Discussion'), (4, 'Focus Group Discussion'), (5, 'Household Interview'), (6, 'Individual Interview'), (7, 'Satellite Imagery')], null=True),
),
migrations.AlterField(
model_name='methodologyattribute',
name='proximity',
field=models.IntegerField(blank=True, choices=[(1, 'Face-to-Face'), (2, 'Remote'), (3, 'Mixed')], null=True),
),
migrations.AlterField(
model_name='methodologyattribute',
name='sampling_approach',
field=models.IntegerField(blank=True, choices=[(1, 'Non-Random Selection'), (2, 'Random Selection'), (3, 'Full Enumeration')], null=True),
),
migrations.AlterField(
model_name='methodologyattribute',
name='unit_of_analysis',
field=models.IntegerField(blank=True, choices=[(100, 'Crisis'), (1, 'Country'), (2, 'Region'), (3, 'Province/governorate/prefecture'), (4, 'Department/District'), (5, 'Sub-District/Country'), (6, 'Municipality'), (7, 'Neighborhood/Quartier'), (8, 'Community/Site'), (9, 'Affected group'), (10, 'Household'), (11, 'Individual')], null=True),
),
migrations.AlterField(
model_name='methodologyattribute',
name='unit_of_reporting',
field=models.IntegerField(blank=True, choices=[(100, 'Crisis'), (1, 'Country'), (2, 'Region'), (3, 'Province/governorate/prefecture'), (4, 'Department/District'), (5, 'Sub-District/Country'), (6, 'Municipality'), (7, 'Neighborhood/Quartier'), (8, 'Community/Site'), (9, 'Affected group'), (10, 'Household'), (11, 'Individual')], null=True),
),
migrations.AlterField(
model_name='question',
name='sector',
field=models.IntegerField(choices=[(100, 'Relevance'), (1, 'Comprehensiveness'), (2, 'Ethics'), (3, 'Methodological rigor'), (4, 'Analytical value'), (5, 'Timeliness'), (6, 'Effective Communication'), (7, 'Use'), (8, 'People-centered and inclusive'), (9, 'Accountability to affected populations'), (10, 'Do not harm'), (11, 'Designed with a purpose'), (12, 'Competency and capacity'), (13, 'Impartiality'), (14, 'Coordination and data minimization'), (15, 'Joint Analysis'), (16, 'Acknowledge dissenting voices in joint needs analysis'), (17, 'Informed consent, confidentiality and data security'), (18, 'Sharing results (data and analysis)'), (19, 'Tranparency between actors'), (20, 'Minimum technical standards')]),
),
migrations.AlterField(
model_name='question',
name='sub_sector',
field=models.IntegerField(choices=[(100, 'Relevance'), (1, 'Geographic comprehensiveness'), (2, 'Sectoral comprehensiveness'), (3, 'Affected and vulnerabel groups comprehensiveness'), (4, 'Safety and protection'), (5, 'Humanitarian Principles'), (6, 'Contribution'), (7, 'Transparency'), (8, 'Mitigating Bias'), (9, 'Participation'), (10, 'Context specificity'), (11, 'Ananlytical standards'), (12, 'Descriptions'), (13, 'Explanation'), (14, 'Interpretation'), (15, 'Anticipation'), (16, 'Timeliness'), (17, 'User-friendly presentation'), (18, 'Active dissemination'), (19, 'Use for collective planning'), (20, 'Buy-in and use by humanitarian clusters/sectors'), (21, 'Buy-in and use by UN agencies'), (22, 'Buy-in and use by international non-governmental organizations (NGOs)'), (23, 'Buy-in and use by local non-governmental organization (local NGOs)'), (24, 'Buy-in and use by member of Red Cross/Red Cresent Movement'), (25, 'Buy-in and use by donors'), (26, 'Buy-in and use by naional and local government agencies'), (27, 'Buy-in and use by development and stabilization actors')]),
),
migrations.AlterField(
model_name='scoreanalyticaldensity',
name='analysis_level_covered',
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(choices=[(100, 'Issues/unmet needs are detailed'), (1, 'Issues/unmet needs are priotized/ranked'), (2, 'Causes or underlying mechanisms behind issues/unmet needs are detailed'), (3, 'Causes or underlying mechanisms behind issues/unmet needs are priotized/ranked'), (4, 'Severity of some/all issues/unmet_needs_is_detailed'), (5, 'Future issues/unmet needs are detailed'), (6, 'Future issues/unmet needs are priotized/ranked'), (7, 'Severity of some/all future issues/unmet_needs_is_detailed'), (8, 'Recommnedations/interventions are detailed'), (9, 'Recommnedations/interventions are priotized/ranked')]), default=list, size=None),
),
migrations.AlterField(
model_name='scoreanalyticaldensity',
name='figure_provided',
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(choices=[(100, 'Total population in the assessed areas'), (1, 'Total population exposed to the shock/event'), (2, 'Total populaiton affected/living in the affected area'), (3, 'Total population facing humanitarian access constraints'), (4, 'Total populaiton in need'), (5, 'Total population in critical need'), (6, 'Total population in severe need'), (7, 'Total population in moderate need'), (9, 'Total population at risk/vulnerable'), (10, 'Total population reached by assistance')]), default=list, size=None),
),
migrations.AlterField(
model_name='scoreanalyticaldensity',
name='sector',
field=models.IntegerField(choices=[(100, 'Food Security'), (1, 'Heath'), (2, 'Shelter'), (3, 'Wash'), (4, 'Protection'), (5, 'Nutrition'), (6, 'Livelihood'), (7, 'Education'), (8, 'Logistics'), (9, 'Inter/Cross Sector')]),
),
migrations.AlterField(
model_name='scorerating',
name='score_type',
field=models.IntegerField(choices=[(100, 'Relevance'), (1, 'Comprehensiveness'), (2, 'Timeliness'), (3, 'Granularity'), (4, 'Comparability'), (5, 'Source reability'), (6, 'Methods'), (7, 'Triangulation'), (8, 'Plausibility'), (9, 'Inclusiveness'), (10, 'Assumptions'), (11, 'Corroboration'), (12, 'Structured Ananlytical Technique'), (13, 'Consensus'), (14, 'Reproducibility'), (15, 'Clearly Articulated Result'), (16, 'Level Of Confidence'), (17, 'Illustration'), (18, 'Sourced data and evidence'), (19, 'Clearly stated outliers')]),
),
migrations.AlterField(
model_name='summaryissue',
name='sub_dimmension',
field=models.IntegerField(blank=True, choices=[(100, 'Drivers'), (1, 'Impact on People'), (2, 'Impact On System, Network And Services'), (3, 'Living Standards'), (4, 'Coping Mechanisms'), (5, 'Physical And Mental Well Being'), (6, 'Needs (Population)'), (7, 'Needs (Humanitarian)'), (8, 'Interventions (Population)'), (9, 'Interventions (Humanitarian)'), (10, 'Demographic Groups'), (11, 'Groups With Specific Needs'), (12, 'Geographical Areas'), (13, 'People At Risks'), (14, 'Focal Issues')], null=True),
),
migrations.AlterField(
model_name='summaryissue',
name='sub_pillar',
field=models.IntegerField(blank=True, choices=[(100, 'Politics'), (1, 'Demography'), (2, 'Socio-Cultural'), (3, 'Environment'), (4, 'Security & Stability'), (5, 'Economics'), (6, 'Characteristics'), (7, 'Drivers and Aggravating Factors'), (8, 'Mitigating Factors'), (9, 'Hazards & Threats'), (10, 'Characteristics'), (11, 'Push Factors'), (12, 'Pull Factors'), (13, 'Intentions'), (14, 'Local Integrations'), (15, 'Source & Means'), (16, 'Challanges & Barriers'), (17, 'Knowledge & Info Gaps (Humanitarian)'), (18, 'Knowledge & Info Gaps (Population)'), (19, 'Population To Relief'), (20, 'Relief To Population'), (21, 'Physical & Security')], null=True),
),
migrations.AlterField(
model_name='summarysubdimmensionissue',
name='focus',
field=models.IntegerField(choices=[(100, 'Food Security'), (1, 'Heath'), (2, 'Shelter'), (3, 'Wash'), (4, 'Protection'), (5, 'Nutrition'), (6, 'Livelihood'), (7, 'Education'), (8, 'Logistics'), (9, 'Inter/Cross Sector')]),
),
]
21 changes: 21 additions & 0 deletions apps/assessment_registry/migrations/0022_auto_20230809_0512.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.17 on 2023-08-09 05:12

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('assessment_registry', '0021_auto_20230808_1125'),
]

operations = [
migrations.RemoveField(
model_name='assessmentregistry',
name='final_score',
),
migrations.RemoveField(
model_name='assessmentregistry',
name='matrix_score',
),
]
Loading

0 comments on commit 8c82b33

Please sign in to comment.