diff --git a/src/project_reports/models.py b/src/project_reports/models.py
index ec1905a2..2f591d6a 100644
--- a/src/project_reports/models.py
+++ b/src/project_reports/models.py
@@ -1,6 +1,15 @@
from django.db import models
-from rh.models import ActivityPlan, Disaggregation, Indicator, Location, LocationType, Project, ReportType
+from rh.models import (
+ ActivityPlan,
+ Disaggregation,
+ Indicator,
+ Location,
+ LocationType,
+ Project,
+ ReportType,
+ FacilitySiteType,
+)
# ##############################################
# ############# Project Reporting ##############
@@ -89,6 +98,7 @@ class TargetLocationReport(models.Model):
blank=True,
)
location_type = models.ForeignKey(LocationType, on_delete=models.SET_NULL, null=True, blank=True)
+ facility_site_type = models.ForeignKey(FacilitySiteType, on_delete=models.SET_NULL, null=True)
def __str__(self):
return f"{self.activity_plan_report}, {self.province}, {self.district}"
diff --git a/src/project_reports/templates/project_reports/forms/location_report_empty_form.html b/src/project_reports/templates/project_reports/forms/location_report_empty_form.html
index f539a215..a32251bc 100644
--- a/src/project_reports/templates/project_reports/forms/location_report_empty_form.html
+++ b/src/project_reports/templates/project_reports/forms/location_report_empty_form.html
@@ -27,11 +27,19 @@
{{ location_report_form.district }}
+ {% if location_report_form.zone.choices %}
{{ location_report_form.zone }}
+
+ {% endif %}
+
+
+
+ {{ location_report_form.facility_site_type }}
+
diff --git a/src/rh/forms.py b/src/rh/forms.py
index a38fc124..3e7e8956 100644
--- a/src/rh/forms.py
+++ b/src/rh/forms.py
@@ -12,6 +12,7 @@
Organization,
Project,
TargetLocation,
+ FacilitySiteType,
)
@@ -222,6 +223,8 @@ def __init__(self, *args, **kwargs):
)
self.fields["province"].queryset = self.fields["province"].queryset.filter(type="Province")
self.fields["district"].queryset = self.fields["district"].queryset.filter(type="District")
+ # Get only the relevant facility types - related to cluster
+ self.fields["facility_site_type"].queryset = FacilitySiteType.objects.all()
self.fields["zone"].queryset = self.fields["zone"].queryset.filter(type="Zone")
self.fields["province"].widget.attrs.update(
{
@@ -295,9 +298,6 @@ def __init__(self, *args, project, **kwargs):
{"onchange": f"updateActivityTitle('{prefix}', 'id_{prefix}-activity_detail');"}
)
self.fields["indicators"].widget.attrs.update({"style": "height: 128px;"})
- # self.fields["facility_type"].queryset = self.fields[
- # "facility_type"
- # ].queryset.filter(cluster__in=cluster_ids)
ActivityPlanFormSet = inlineformset_factory(
diff --git a/src/rh/migrations/0013_targetlocation_facility_site_type.py b/src/rh/migrations/0013_targetlocation_facility_site_type.py
new file mode 100644
index 00000000..36df3f82
--- /dev/null
+++ b/src/rh/migrations/0013_targetlocation_facility_site_type.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.0.6 on 2024-01-03 05:08
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("rh", "0012_merge_20231220_0933"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="targetlocation",
+ name="facility_site_type",
+ field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to="rh.facilitysitetype"),
+ ),
+ ]
diff --git a/src/rh/models.py b/src/rh/models.py
index 9a6c9f09..c69a82b7 100644
--- a/src/rh/models.py
+++ b/src/rh/models.py
@@ -174,7 +174,7 @@ class Meta:
class FacilitySiteType(models.Model):
cluster = models.ForeignKey(Cluster, on_delete=models.SET_NULL, blank=True, null=True)
- name = models.fields.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
+ name = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
def __str__(self):
return self.name
@@ -186,7 +186,7 @@ class Meta:
class ImplementationModalityType(models.Model):
code = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
- name = models.fields.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
+ name = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
def __str__(self):
return self.name
@@ -199,7 +199,7 @@ class Meta:
class TransferMechanismType(models.Model):
modality_id = models.ForeignKey(ImplementationModalityType, on_delete=models.SET_NULL, blank=True, null=True)
code = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
- name = models.fields.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
+ name = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
def __str__(self):
return self.name
@@ -211,7 +211,7 @@ class Meta:
class PackageType(models.Model):
code = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
- name = models.fields.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
+ name = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
def __str__(self):
return self.name
@@ -223,7 +223,7 @@ class Meta:
class TransferCategory(models.Model):
code = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
- name = models.fields.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
+ name = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
def __str__(self):
return self.name
@@ -235,7 +235,7 @@ class Meta:
class GrantType(models.Model):
code = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
- name = models.fields.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
+ name = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
def __str__(self):
return self.name
@@ -247,7 +247,7 @@ class Meta:
class UnitType(models.Model):
code = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
- name = models.fields.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
+ name = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
def __str__(self):
return self.name
@@ -259,7 +259,7 @@ class Meta:
class ReportType(models.Model):
code = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
- name = models.fields.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
+ name = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
def __str__(self):
return self.name
@@ -557,14 +557,16 @@ class TargetLocation(models.Model):
blank=True,
)
location_type = models.ForeignKey(LocationType, on_delete=models.SET_NULL, null=True, blank=True)
+ classification = models.CharField(max_length=15, choices=TARGET_CLASSIFICATION, blank=True, null=True)
implementing_partner = models.ForeignKey(Organization, on_delete=models.SET_NULL, null=True, blank=True)
+ facility_site_type = models.ForeignKey(FacilitySiteType, on_delete=models.SET_NULL, null=True)
+
site_monitoring = models.BooleanField(default=False)
site_name = models.CharField(max_length=255, blank=True, null=True)
site_lat = models.CharField(max_length=255, blank=True, null=True)
site_long = models.CharField(max_length=255, blank=True, null=True)
- classification = models.CharField(max_length=15, choices=TARGET_CLASSIFICATION, blank=True, null=True)
old_id = models.CharField(max_length=NAME_MAX_LENGTH, blank=True, null=True)
def __str__(self):
diff --git a/src/rh/templates/rh/projects/forms/target_location_empty_form.html b/src/rh/templates/rh/projects/forms/target_location_empty_form.html
index 3b1544a9..43568c9d 100644
--- a/src/rh/templates/rh/projects/forms/target_location_empty_form.html
+++ b/src/rh/templates/rh/projects/forms/target_location_empty_form.html
@@ -45,12 +45,20 @@
{{ target_location_form.district }}
-
+ {% if target_location_form.zone.choices %}
+
{{ target_location_form.zone }}
+ {% endif %}
+
+
+
+ {{ target_location_form.facility_site_type }}
+
+
diff --git a/src/rh/views.py b/src/rh/views.py
index 13712408..2c8dc953 100644
--- a/src/rh/views.py
+++ b/src/rh/views.py
@@ -524,7 +524,7 @@ def get_activity_empty_form(request):
# Prepare context for rendering the activity empty form template
context = {
- "form": activity_plan_formset.empty_form,
+ "form": activity_plan_formset,
"target_location_formset": target_location_formset,
"project": project,
}
diff --git a/src/static/rh/js/activity_planning.js b/src/static/rh/js/activity_planning.js
index 2a40edc8..10f4a8db 100644
--- a/src/static/rh/js/activity_planning.js
+++ b/src/static/rh/js/activity_planning.js
@@ -377,11 +377,11 @@ function getLocations(locationPrefix, locationType, parentType, clearZone=null)
$(`select#id_${locationPrefix}-${locationType}`).val(selectedLocations);
}
- if(locationType == 'zone' && data === ''){
- $(`#id_${locationPrefix}-${locationType}`).parent().hide();
- }else{
- $(`#id_${locationPrefix}-${locationType}`).parent().show();
- }
+ // if(locationType == 'zone' && data === ''){
+ // $(`#id_${locationPrefix}-${locationType}`).parent().hide();
+ // }else{
+ // $(`#id_${locationPrefix}-${locationType}`).parent().show();
+ // }
},
error: function (error) {