Skip to content

Commit 907219a

Browse files
authoredFeb 7, 2024
Merge pull request #147 from iMMAP/feat/facility_monitoring
[ADDED] - Facility/Sites Monitoring
2 parents 14086b9 + 87360b9 commit 907219a

16 files changed

+515
-32
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.0.6 on 2024-02-06 07:26
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("rh", "0024_targetlocation_facility_id_and_more"),
10+
("project_reports", "0006_targetlocationreport_facility_site_type"),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name="targetlocationreport",
16+
name="facility_site_type",
17+
field=models.ForeignKey(
18+
blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="rh.facilitysitetype"
19+
),
20+
),
21+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Generated by Django 4.0.6 on 2024-02-06 07:33
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("project_reports", "0007_alter_targetlocationreport_facility_site_type"),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name="targetlocationreport",
14+
name="facility_id",
15+
field=models.CharField(blank=True, max_length=200, null=True),
16+
),
17+
migrations.AddField(
18+
model_name="targetlocationreport",
19+
name="facility_lat",
20+
field=models.CharField(blank=True, max_length=200, null=True),
21+
),
22+
migrations.AddField(
23+
model_name="targetlocationreport",
24+
name="facility_long",
25+
field=models.CharField(blank=True, max_length=200, null=True),
26+
),
27+
migrations.AddField(
28+
model_name="targetlocationreport",
29+
name="facility_monitoring",
30+
field=models.BooleanField(default=False),
31+
),
32+
migrations.AddField(
33+
model_name="targetlocationreport",
34+
name="facility_name",
35+
field=models.CharField(blank=True, max_length=200, null=True),
36+
),
37+
]

‎src/project_reports/models.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from django.db import models
2-
32
from rh.models import (
43
ActivityPlan,
54
Disaggregation,
5+
FacilitySiteType,
66
Indicator,
77
Location,
88
LocationType,
99
Project,
1010
ReportType,
11-
FacilitySiteType,
1211
)
1312

1413
# ##############################################
@@ -98,7 +97,22 @@ class TargetLocationReport(models.Model):
9897
blank=True,
9998
)
10099
location_type = models.ForeignKey(LocationType, on_delete=models.SET_NULL, null=True, blank=True)
101-
facility_site_type = models.ForeignKey(FacilitySiteType, on_delete=models.SET_NULL, null=True)
100+
facility_site_type = models.ForeignKey(FacilitySiteType, on_delete=models.SET_NULL, null=True, blank=True)
101+
102+
# Facility Monitoring
103+
facility_monitoring = models.BooleanField(default=False)
104+
facility_name = models.CharField(
105+
max_length=200,
106+
blank=True,
107+
null=True,
108+
)
109+
facility_id = models.CharField(
110+
max_length=200,
111+
blank=True,
112+
null=True,
113+
)
114+
facility_lat = models.CharField(max_length=200, null=True, blank=True)
115+
facility_long = models.CharField(max_length=200, null=True, blank=True)
102116

103117
def __str__(self):
104118
return f"{self.activity_plan_report}, {self.province}, {self.district}"

‎src/project_reports/templates/project_reports/forms/location_report_empty_form.html

+57
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,63 @@
5353
</div>
5454
</div>
5555
</div>
56+
57+
<div class="row mtb20">
58+
<div class="col">
59+
<div class="field-col">
60+
<div class="input-check-holder">
61+
{{ location_report_form.facility_monitoring }}
62+
<label for="{{ location_report_form.facility_monitoring.id_for_label }}">
63+
<span class="input"></span>
64+
<span class="text">Facility Monitoring</span>
65+
</label>
66+
</div>
67+
</div>
68+
</div>
69+
</div>
70+
71+
<div class="row mtb20" id="facility_details_{{ location_report_form.prefix }}">
72+
<div class="col col-lg">
73+
<div class="multiple-fields-row two-items mtb20">
74+
<div class="field-col">
75+
<div class="input-field">
76+
<label for="{{ location_report_form.facility_name.id_for_label }}">
77+
Facility / Site Name
78+
</label>
79+
<div class="input-holder">{{ location_report_form.facility_name }}</div>
80+
</div>
81+
</div>
82+
<div class="field-col">
83+
<div class="input-field">
84+
<label for="{{ location_report_form.facility_id.id_for_label }}">
85+
Facility / Site ID
86+
</label>
87+
<div class="input-holder">{{ location_report_form.facility_id }}</div>
88+
</div>
89+
</div>
90+
</div>
91+
<div class="multiple-fields-row two-items">
92+
<div class="field-col">
93+
<div class="input-field">
94+
<label for="{{ location_report_form.facility_lat.id_for_label }}">
95+
Facility / Site Latitude
96+
</label>
97+
<div class="input-holder">{{ location_report_form.facility_lat }}</div>
98+
</div>
99+
</div>
100+
<div class="field-col">
101+
<div class="input-field">
102+
<label for="{{ location_report_form.facility_long.id_for_label }}">
103+
Facility / Site Longitude
104+
</label>
105+
<div class="input-holder">{{ location_report_form.facility_long }}</div>
106+
</div>
107+
</div>
108+
</div>
109+
</div>
110+
</div>
111+
112+
56113
<div class="disaggregation-block disaggregation-accordion">
57114
<div class="inner-holder">
58115
<div class="block-top disaggregation-accordion-opener">

‎src/project_reports/templates/project_reports/forms/monthly_report_progress_form.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
<div class="col">
147147
<div class="field-col">
148148
<div class="select-field">
149-
<label>Report Type</label>
149+
<label>Report Types</label>
150150
{{ activity_report_form.report_types }}
151151
</div>
152152
</div>

‎src/project_reports/templates/project_reports/views/monthly_report_view.html

+83-1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,18 @@
212212
</div>
213213
</div>
214214
</div>
215+
<div class="col">
216+
<div class="field-col">
217+
<div class="select-field">
218+
<label>Report Types</label>
219+
<span class="text-read-only m2m-badges">
220+
{% for report_type in activity_report.report_types.all %}
221+
<span class="btn btn-red"> {{ report_type.name }}</span>
222+
{% endfor %}
223+
</span>
224+
</div>
225+
</div>
226+
</div>
215227
</div>
216228
<div class="target_location-block target-location-accordion">
217229
<div class="inner-holder">
@@ -265,15 +277,85 @@
265277
</div>
266278
</div>
267279
</div>
280+
{% if location_report.zone %}
281+
<div class="field-col">
282+
<div class="input-field">
283+
<span class="label">Zone</span>
284+
<div class="input-holder">
285+
<span class="text-read-only">{{ location_report.district }}</span>
286+
</div>
287+
</div>
288+
</div>
289+
{% endif %}
290+
</div>
291+
</div>
292+
<div class="col">
293+
<div class="multiple-fields-row two-items">
268294
<div class="field-col">
269295
<div class="select-field ">
270296
<span class="label">Location Type</span>
271297
<span class="text-read-only">{{ location_report.location_type }}</span>
272298
</div>
273299
</div>
300+
<div class="field-col">
301+
<div class="input-field">
302+
<span class="label">Facility Monitoring</span>
303+
<div class="input-holder">
304+
<span class="text-read-only">
305+
{% if location_report.facility_monitoring %}
306+
Yes
307+
{% else %}
308+
No
309+
{% endif %}
310+
</span>
311+
</div>
312+
</div>
313+
</div>
274314
</div>
275315
</div>
276-
<br/>
316+
</div>
317+
<br/>
318+
<div class="row">
319+
{% if location_report.facility_monitoring %}
320+
<div class="col">
321+
<div class="multiple-fields-row two-items">
322+
<div class="field-col">
323+
<div class="select-field">
324+
<span class="label">Facility / Site Name</span>
325+
<span class="text-read-only">{{ location_report.facility_name }}</span>
326+
</div>
327+
</div>
328+
<div class="field-col">
329+
<div class="input-field">
330+
<span class="label">Facility / Site ID</span>
331+
<div class="input-holder">
332+
<span class="text-read-only">{{ location_report.facility_id }}</span>
333+
</div>
334+
</div>
335+
</div>
336+
</div>
337+
</div>
338+
<div class="col">
339+
<div class="multiple-fields-row two-items">
340+
<div class="field-col">
341+
<div class="input-field">
342+
<span class="label">Facility / Site Latitude</span>
343+
<div class="input-holder">
344+
<span class="text-read-only">{{ location_report.facility_lat }}</span>
345+
</div>
346+
</div>
347+
</div>
348+
<div class="field-col">
349+
<div class="input-field">
350+
<span class="label">Facility / Site Longitude</span>
351+
<div class="input-holder">
352+
<span class="text-read-only">{{ location_report.facility_long }}</span>
353+
</div>
354+
</div>
355+
</div>
356+
</div>
357+
</div>
358+
{% endif %}
277359
</div>
278360
<br/>
279361
<div class="disaggregation-block disaggregation-accordion">

‎src/project_reports/views.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from django.urls import reverse
1515
from django.utils import timezone
1616
from django.views.decorators.cache import cache_control
17+
1718
from rh.models import (
1819
ActivityDetail,
1920
ActivityDomain,
@@ -630,6 +631,7 @@ def update_project_monthly_report_progress_view(request, project, report):
630631
activity_report = activity_report_form.save(commit=False)
631632
activity_report.monthly_report = monthly_report_instance
632633
activity_report.save()
634+
activity_report_form.save_m2m()
633635

634636
# Process target location forms and their disaggregation forms
635637
activity_report_target = 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Generated by Django 4.0.6 on 2024-02-06 06:21
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("rh", "0023_targetlocation_disaggregations"),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name="targetlocation",
14+
name="facility_id",
15+
field=models.CharField(blank=True, max_length=200, null=True),
16+
),
17+
migrations.AddField(
18+
model_name="targetlocation",
19+
name="facility_lat",
20+
field=models.CharField(blank=True, max_length=200, null=True),
21+
),
22+
migrations.AddField(
23+
model_name="targetlocation",
24+
name="facility_long",
25+
field=models.CharField(blank=True, max_length=200, null=True),
26+
),
27+
migrations.AddField(
28+
model_name="targetlocation",
29+
name="facility_monitoring",
30+
field=models.BooleanField(default=False),
31+
),
32+
migrations.AddField(
33+
model_name="targetlocation",
34+
name="facility_name",
35+
field=models.CharField(blank=True, max_length=200, null=True),
36+
),
37+
]

‎src/rh/models.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,6 @@ class ActivityPlan(models.Model):
484484
max_length=15, choices=CATEGORY_TYPES, default="non-disabled", null=True, blank=True
485485
)
486486

487-
# Facility Monitoring
488-
# facility_monitoring = models.BooleanField(default=False)
489-
# facility_name = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True, )
490-
# facility_id = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True, )
491-
# facility_type = models.ForeignKey(FacilitySiteType, on_delete=models.SET_NULL, null=True, blank=True)
492-
# facility_lat = models.CharField(max_length=NAME_MAX_LENGTH, null=True, blank=True)
493-
# facility_long = models.CharField(max_length=NAME_MAX_LENGTH, null=True, blank=True)
494-
495487
total_target = models.IntegerField(default=0, blank=True, null=True)
496488
description = models.TextField(blank=True, null=True)
497489
# old_id = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
@@ -578,6 +570,21 @@ class TargetLocation(models.Model):
578570
site_long = models.CharField(max_length=255, blank=True, null=True)
579571
old_id = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
580572

573+
# Facility Monitoring
574+
facility_monitoring = models.BooleanField(default=False)
575+
facility_name = models.CharField(
576+
max_length=NAME_MAX_LENGTH,
577+
blank=True,
578+
null=True,
579+
)
580+
facility_id = models.CharField(
581+
max_length=NAME_MAX_LENGTH,
582+
blank=True,
583+
null=True,
584+
)
585+
facility_lat = models.CharField(max_length=NAME_MAX_LENGTH, null=True, blank=True)
586+
facility_long = models.CharField(max_length=NAME_MAX_LENGTH, null=True, blank=True)
587+
581588
disaggregations = models.ManyToManyField(
582589
"Disaggregation", through="DisaggregationLocation", related_name="disaggregations"
583590
)

0 commit comments

Comments
 (0)