From 1a9feeb2c1b58cd5030d491baf63f6c59b994c48 Mon Sep 17 00:00:00 2001 From: AKSHARVAGHASIYA Date: Sun, 12 Apr 2026 17:04:00 +0530 Subject: [PATCH] Fix #322: Add comprehensive plan details to resource map report --- dpr/api.py | 29 ++++++++++++++++++++++------- templates/resource-report.html | 14 ++++++++++++-- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/dpr/api.py b/dpr/api.py index 6250ba2a..0aeac157 100644 --- a/dpr/api.py +++ b/dpr/api.py @@ -14,6 +14,7 @@ from utilities.auth_check_decorator import api_security_check from utilities.auth_utils import auth_free from utilities.logger import setup_logger +from plans.models import PlanApp from .gen_dpr import ( get_plan_details, @@ -412,12 +413,28 @@ def generate_resource_report(request): for key, value in params.items(): result[key] = value + + plan_id = result.get("plan_id") + plan_details = None + if plan_id: + try: + plan = PlanApp.objects.get(id=plan_id) + plan_details = { + "organization_name": plan.organization.name if plan.organization else "NA", + "project_name": plan.project.name if plan.project else "NA", + "plan_name": plan.plan, + "facilitator_name": plan.facilitator_name, + "village_name": plan.village_name, + } + except PlanApp.DoesNotExist: + pass context = { - "district": result["district"], - "block": result["block"], - "plan_id": result["plan_id"], - "plan_name": result["plan_name"], + "district": result.get("district"), + "block": result.get("block"), + "plan_id": plan_id, + "plan_name": result.get("plan_name", ""), + "plan_details": plan_details, } return render(request, "resource-report.html", context) @@ -448,10 +465,8 @@ def download_mws_report(request): return resp -@api_view(["GET"]) -@auth_free -@schema(None) @api_security_check(auth_type="Auth_free") +@schema(None) def generate_tehsil_report(request): try: # ? district, block, mwsId diff --git a/templates/resource-report.html b/templates/resource-report.html index c32066ea..8507bbb3 100644 --- a/templates/resource-report.html +++ b/templates/resource-report.html @@ -267,8 +267,18 @@

Resource and Demand Map Report

-
Plan Name: {{plan_name}}
-
Plan ID: {{plan_id}}
+
+
Plan Name: {{plan_name}}
+
Plan ID: {{plan_id}}
+
+ {% if plan_details %} +
+
Village: {{plan_details.village_name}}
+
Organization: {{plan_details.organization_name}}
+
Project: {{plan_details.project_name}}
+
Facilitator: {{plan_details.facilitator_name}}
+
+ {% endif %}