Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions dpr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions templates/resource-report.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,18 @@
<div class="container">
<h1>Resource and Demand Map Report</h1>
<div style="margin-top: 15px; font-size: 1.1em; opacity: 0.95;">
<div><strong>Plan Name:</strong> {{plan_name}}</div>
<div style="margin-top: 5px;"><strong>Plan ID:</strong> {{plan_id}}</div>
<div style="display: flex; gap: 40px; justify-content: center; margin-bottom: 10px;">
<div><strong>Plan Name:</strong> {{plan_name}}</div>
<div><strong>Plan ID:</strong> {{plan_id}}</div>
</div>
{% if plan_details %}
<div style="display: flex; gap: 40px; justify-content: center; font-size: 0.9em; opacity: 0.9;">
<div><strong>Village:</strong> {{plan_details.village_name}}</div>
<div><strong>Organization:</strong> {{plan_details.organization_name}}</div>
<div><strong>Project:</strong> {{plan_details.project_name}}</div>
<div><strong>Facilitator:</strong> {{plan_details.facilitator_name}}</div>
</div>
{% endif %}
</div>
<button class="print-button" onclick="printReport()">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
Expand Down