Skip to content

Commit eaed8d2

Browse files
authored
Merge pull request #555 from Esmat-Farjad/feat/SafeSpace_for_womenGirls
safe spaces added to project monthly report for ESNFI
2 parents 1818265 + 39ff125 commit eaed8d2

File tree

7 files changed

+59
-8
lines changed

7 files changed

+59
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.4 on 2025-01-26 07:31
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('project_reports', '0024_remove_targetlocationreport_seasonal_retargeting'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='targetlocationreport',
15+
name='safe_space',
16+
field=models.BooleanField(default=False),
17+
),
18+
]

src/project_reports/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class TargetLocationReport(models.Model):
111111
location_type = models.ForeignKey(LocationType, on_delete=models.SET_NULL, null=True, blank=True)
112112

113113
prev_assisted_by = models.ForeignKey(Indicator, null=True, blank=True, on_delete=models.SET_NULL)
114+
safe_space = models.BooleanField(default=False)
114115
beneficiary_status = models.CharField(
115116
max_length=25,
116117
choices=[

src/project_reports/templates/project_reports/report_target_locations/report_target_location_form.html

+15-1
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,23 @@ <h4 class="text-white"><u>Description</u></h4>
146146
</div>
147147
</div>
148148
</div>
149+
{% if safe_space %}
150+
<div class="multiple-fields-row two-items py-2">
151+
<div class="field-col">
152+
{{ location_report_form.safe_space }}
153+
<label for="{{ location_report_form.safe_space.id_for_label }}">
154+
Distribution Undertaken with safe spaces
155+
</label>
156+
<p class="help-text ml-4">
157+
Was the distribution undertaken with safe spaces for women, girls and people with disabilities?
158+
</p>
159+
<div class="sign-up-field-error">{{ location_report_form.safe_space.errors }}</div>
160+
</div>
161+
</div>
162+
{% endif %}
149163
</div>
150164
</div>
151-
165+
152166
{% comment %} the TL info and Tabular Disaggregation Here {% endcomment %}
153167
<div id="target-location-info">
154168
{% if location_report %}

src/project_reports/utils.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def write_projects_reports_to_csv(monthly_progress_report, response):
9090
"currency",
9191
"updated_at",
9292
"created_at",
93+
"safe_spaces_for_women-girls",
9394
]
9495
disaggregation_cols = []
9596
disaggregations = Disaggregation.objects.all()
@@ -248,6 +249,7 @@ def write_projects_reports_to_csv(monthly_progress_report, response):
248249
plan_report.currency.name if plan_report.currency else None,
249250
project_reports.created_at.astimezone(datetime.timezone.utc).replace(tzinfo=None),
250251
project_reports.updated_at.astimezone(datetime.timezone.utc).replace(tzinfo=None),
252+
"Yes" if location_report.safe_space else None,
251253
]
252254

253255
# Iterate through disaggregation locations and get disaggregation values
@@ -311,6 +313,7 @@ def write_import_report_template_sheet(workbook, monthly_report):
311313
{"header": "facility_long", "type": "string", "width": 30},
312314
{"header": "non_hrp_beneficiary", "type": "string", "width": 30},
313315
{"header": "hrp_beneficiary", "type": "string", "width": 30},
316+
{"header": "with_safe_spaces", "type": "string", "width": 30},
314317
]
315318

316319
disaggregation_cols = []
@@ -344,6 +347,8 @@ def write_import_report_template_sheet(workbook, monthly_report):
344347
"transfer_mc_type": ["N"],
345348
"transfer_category": ["L"],
346349
"currency": ["M"],
350+
"safe_space": ["AG", "True", "False"],
351+
"facilitySiteTypeList": ["Z"],
347352
}
348353
plain_dictionary_lists = {
349354
"indicatorList": ["B"],
@@ -355,7 +360,6 @@ def write_import_report_template_sheet(workbook, monthly_report):
355360
"admin1nameList": ["U"],
356361
"admin2pcodeList": ["V"],
357362
"admin2nameList": ["W"],
358-
"facilitySiteTypeList": ["Z"],
359363
"implementing_partner_list": ["F"],
360364
"non_hrp_beneficiary": ["AE"],
361365
"hrp_beneficiary": ["AF"],
@@ -370,11 +374,14 @@ def write_import_report_template_sheet(workbook, monthly_report):
370374
container_dictionary["transfer_mc_type"].extend(list(TransferMechanismType.objects.values_list("name", flat=True)))
371375
container_dictionary["transfer_category"].extend(list(TransferCategory.objects.values_list("name", flat=True)))
372376
container_dictionary["currency"].extend(list(Currency.objects.values_list("name", flat=True)))
373-
facility = list(FacilitySiteType.objects.values_list("name", flat=True))
377+
facility = list(FacilitySiteType.objects.filter(cluster__code="health").values_list("name", flat=True))
374378
responseType = list(ResponseType.objects.values_list("name", flat=True))
375379
num_rows = 2
380+
381+
cluster_code = []
376382
project_code = project.code
377383
for plan in project.activityplan_set.all():
384+
cluster_code.extend(plan.activity_domain.clusters.values_list("code", flat=True))
378385
for location in plan.targetlocation_set.all():
379386
plain_dictionary_lists["indicatorList"].append(str(plan.indicator.name))
380387
plain_dictionary_lists["activityDomainList"].append(str(plan.activity_domain.name))
@@ -389,8 +396,10 @@ def write_import_report_template_sheet(workbook, monthly_report):
389396
plain_dictionary_lists["non_hrp_beneficiary"].append(str(plan.beneficiary))
390397
plain_dictionary_lists["hrp_beneficiary"].append(str(plan.hrp_beneficiary))
391398
num_rows += 1
392-
plain_dictionary_lists["facilitySiteTypeList"].extend(facility)
399+
393400
container_dictionary["reponseTypeList"].extend(responseType)
401+
if "health" in cluster_code:
402+
container_dictionary["facilitySiteTypeList"].extend(facility)
394403

395404
for key, value in container_dictionary.items():
396405
column = value[0]

src/project_reports/views/report_target_locations.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def create_report_target_location(request, plan):
153153
plan_report = get_object_or_404(
154154
ActivityPlanReport.objects.select_related("monthly_report", "activity_plan"), pk=plan
155155
)
156-
156+
safe_space = False
157+
cluster_codes = plan_report.activity_plan.activity_domain.clusters.values_list("code", flat=True)
158+
if "esnfi" in cluster_codes:
159+
safe_space = True
157160
if request.method == "POST":
158161
target_location_id = request.POST.get("target_location", None)
159162
target_location = get_object_or_404(TargetLocation, pk=target_location_id)
@@ -222,6 +225,7 @@ def create_report_target_location(request, plan):
222225
"report_plan": plan_report,
223226
"monthly_report": plan_report.monthly_report,
224227
"project": plan_report.monthly_report.project,
228+
"safe_space": safe_space,
225229
}
226230

227231
return render(request, "project_reports/report_target_locations/report_target_location_form.html", context)
@@ -235,6 +239,7 @@ def update_report_target_locations(request, project, plan, location):
235239

236240
# Get the existing location report to be updated
237241
location_report = get_object_or_404(TargetLocationReport.objects.select_related("target_location"), pk=location)
242+
safe_space = location_report.safe_space
238243

239244
DisaggregationReportFormSet = inlineformset_factory(
240245
parent_model=TargetLocationReport,
@@ -316,6 +321,7 @@ def update_report_target_locations(request, project, plan, location):
316321
"report_plan": plan_report,
317322
"monthly_report": monthly_report,
318323
"project": monthly_report.project,
324+
"safe_space": safe_space,
319325
},
320326
)
321327

src/project_reports/views/views.py

+2
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,14 @@ def import_report_activities(request, pk):
252252
district=district,
253253
zone=zone,
254254
).first()
255+
safe_space = row.get("with_safe_spaces").strip().upper() == "TRUE"
255256

256257
target_location = TargetLocationReport(
257258
activity_plan_report=activity_plan_report,
258259
target_location=project_target_location,
259260
location_type=location_type,
260261
beneficiary_status=beneficiary_status,
262+
safe_space=safe_space,
261263
# add previously_targeted_by and
262264
)
263265
report_target_locations.append(target_location)

src/rh/views/target_locations.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ def create_target_location(request, activity_plan):
123123
related_disaggregations = Disaggregation.objects.filter(indicators=activity_plan.indicator)
124124

125125
cluster_code = activity_plan.activity_domain.clusters.values_list("code", flat=True)
126-
cluster_facility = True
127-
if "fsac" in cluster_code:
128-
cluster_facility = False
126+
cluster_facility = False
127+
128+
if "health" in cluster_code:
129+
cluster_facility = True
129130

130131
DisaggregationFormSet = inlineformset_factory(
131132
parent_model=TargetLocation,

0 commit comments

Comments
 (0)