Skip to content

Commit 0724d71

Browse files
authored
Merge pull request #559 from Esmat-Farjad/fix/impot_template
import activty plan template and import report template fixed with ne…
2 parents 6848418 + f502219 commit 0724d71

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

src/project_reports/utils.py

+23-21
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010

1111
from project_reports.models import ActivityPlanReport, ProjectMonthlyReport, ResponseType
1212
from rh.models import (
13-
Currency,
1413
Disaggregation,
1514
FacilitySiteType,
1615
GrantType,
1716
ImplementationModalityType,
1817
PackageType,
18+
RationSize,
19+
RationType,
1920
TransferCategory,
2021
TransferMechanismType,
2122
UnitType,
@@ -288,12 +289,13 @@ def write_import_report_template_sheet(workbook, monthly_report):
288289
{"header": "response_types", "type": "string", "width": 30},
289290
{"header": "implementing_partners", "type": "string", "width": 30},
290291
{"header": "package_type", "type": "string", "width": 30},
292+
{"header": "ration_type", "type": "string", "width": 30},
293+
{"header": "ration_size", "type": "string", "width": 30},
291294
{"header": "unit_type", "type": "string", "width": 30},
292-
{"header": "units", "type": "string", "width": 30},
295+
{"header": "units/transfer_value", "type": "string", "width": 30},
293296
{"header": "no_of_transfers", "type": "string", "width": 30},
294297
{"header": "grant_type", "type": "string", "width": 30},
295298
{"header": "transfer_category", "type": "string", "width": 30},
296-
{"header": "currency", "type": "string", "width": 30},
297299
{"header": "transfer_mechanism_type", "type": "string", "width": 30},
298300
{"header": "implement_modility_type", "type": "string", "width": 30},
299301
{"header": "beneficiary_status", "type": "string", "width": 30},
@@ -311,7 +313,6 @@ def write_import_report_template_sheet(workbook, monthly_report):
311313
{"header": "facility_name", "type": "string", "width": 30},
312314
{"header": "facility_lat", "type": "string", "width": 30},
313315
{"header": "facility_long", "type": "string", "width": 30},
314-
{"header": "non_hrp_beneficiary", "type": "string", "width": 30},
315316
{"header": "hrp_beneficiary", "type": "string", "width": 30},
316317
{"header": "with_safe_spaces", "type": "string", "width": 30},
317318
]
@@ -338,30 +339,30 @@ def write_import_report_template_sheet(workbook, monthly_report):
338339
sheet.column_dimensions[column_letter].width = column["width"]
339340
# write the rows with report data
340341
container_dictionary = {
341-
"beneficiary_status_list": ["P", "New Beneficiary", "Existing Beneficiaries"],
342342
"reponseTypeList": ["E"],
343343
"package_type": ["G"],
344-
"unit_type": ["H"],
345-
"grant_type": ["K"],
346-
"im_modility_type": ["O"],
347-
"transfer_mc_type": ["N"],
348-
"transfer_category": ["L"],
349-
"currency": ["M"],
344+
"ration_type": ["H"],
345+
"ration_size": ["I"],
346+
"unit_type": ["J"],
347+
"grant_type": ["M"],
348+
"transfer_category": ["N"],
349+
"transfer_mc_type": ["O"],
350+
"im_modility_type": ["P"],
351+
"beneficiary_status_list": ["Q", "New Beneficiary", "Existing Beneficiaries"],
350352
"safe_space": ["AG", "True", "False"],
351-
"facilitySiteTypeList": ["Z"],
353+
"facilitySiteTypeList": ["AA"],
352354
}
353355
plain_dictionary_lists = {
354356
"indicatorList": ["B"],
355357
"activityDomainList": ["C"],
356358
"activityTypeList": ["D"],
357-
"admin0nameList": ["R"],
358-
"admin0pcodeList": ["S"],
359-
"admin1pcodeList": ["T"],
360-
"admin1nameList": ["U"],
361-
"admin2pcodeList": ["V"],
362-
"admin2nameList": ["W"],
359+
"admin0nameList": ["S"],
360+
"admin0pcodeList": ["T"],
361+
"admin1pcodeList": ["U"],
362+
"admin1nameList": ["V"],
363+
"admin2pcodeList": ["W"],
364+
"admin2nameList": ["X"],
363365
"implementing_partner_list": ["F"],
364-
"non_hrp_beneficiary": ["AE"],
365366
"hrp_beneficiary": ["AF"],
366367
}
367368
project = monthly_report.project
@@ -371,9 +372,11 @@ def write_import_report_template_sheet(workbook, monthly_report):
371372
container_dictionary["im_modility_type"].extend(
372373
list(ImplementationModalityType.objects.values_list("name", flat=True))
373374
)
375+
container_dictionary["ration_size"].extend(list(RationSize.objects.values_list("name", flat=True).order_by("-id")))
376+
container_dictionary["ration_type"].extend(list(RationType.objects.values_list("name", flat=True)))
374377
container_dictionary["transfer_mc_type"].extend(list(TransferMechanismType.objects.values_list("name", flat=True)))
375378
container_dictionary["transfer_category"].extend(list(TransferCategory.objects.values_list("name", flat=True)))
376-
container_dictionary["currency"].extend(list(Currency.objects.values_list("name", flat=True)))
379+
377380
facility = list(FacilitySiteType.objects.filter(cluster__code="health").values_list("name", flat=True))
378381
responseType = list(ResponseType.objects.values_list("name", flat=True))
379382
num_rows = 2
@@ -399,7 +402,6 @@ def write_import_report_template_sheet(workbook, monthly_report):
399402
plain_dictionary_lists["implementing_partner_list"].append(
400403
str(location.implementing_partner.code if location.implementing_partner else "")
401404
)
402-
plain_dictionary_lists["non_hrp_beneficiary"].append(str(plan.beneficiary if plan.beneficiary else ""))
403405
plain_dictionary_lists["hrp_beneficiary"].append(str(plan.hrp_beneficiary if plan.hrp_beneficiary else ""))
404406
num_rows += 1
405407

src/rh/templates/rh/activity_plans/import_activity_plans.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
<div class="activity-title">
2424
<span>Import Project Activity Plans and Target Locations</span>
2525
</div>
26-
<a href="{% url 'projects-ap-import-template' project.pk %}?csrfmiddlewaretoken={{ csrf_token }}" class="btn btn-grey" onclick="return confirm('Download template?');">Download template</a>
26+
<a href="{% url 'projects-ap-import-template' project.pk %}?csrfmiddlewaretoken={{ csrf_token }}"
27+
class="btn btn-gray" onclick="return confirm('Download template?');">Download template
28+
</a>
2729
</div>
2830

2931
<p class="pb-2">Import Activity Plans and Target Locations from a CSV file</p>
@@ -57,6 +59,10 @@
5759
<li> <span class="icon-info mr-2"></span>
5860
<a class="underline" href="{% url 'guides-detail' 'project-and-activity-planning' %}">Project and planning guide</a>
5961
</li>
62+
<li class="text-red my-3"><strong>Important Note: </strong>
63+
The first row of the template is populated with demo data for your guidance.
64+
Please replace it with your accurate project activity plan data before uploading.
65+
</li>
6066
</ul>
6167

6268
{% if errors %}

src/rh/views/projects.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,18 @@ def export_activity_plans_import_template(request, pk):
258258
"activity_type",
259259
"activity_detail",
260260
"indicator",
261-
"beneficiary",
262261
"hrp_beneficiary",
263262
"description",
264263
"package_type",
265264
"unit_type",
266-
"units",
265+
"ration_type",
266+
"ration_size",
267+
"units/transfer_value",
267268
"no_of_transfers",
268269
"grant_type",
269270
"transfer_category",
270-
"currency",
271271
"transfer_mechanism_type",
272-
"implement_modility_type",
272+
"implement_modality_type",
273273
"admin0name",
274274
"admin0pcode",
275275
"admin1name",
@@ -313,18 +313,18 @@ def export_activity_plans_import_template(request, pk):
313313
at.name,
314314
adt.name if adt else None,
315315
ind.name,
316-
BeneficiaryType.objects.filter(type="non-hrp").values_list("name", flat=True).first(),
317316
BeneficiaryType.objects.filter(type="hrp").values_list("name", flat=True).first(),
318317
"[input any note or description]",
319-
"75%",
318+
"Standard",
319+
"",
320320
"KG",
321-
"1",
322-
"200",
323-
"Conditional, Unrestricted",
321+
"100%",
322+
"500",
323+
"4",
324+
"Conditional and Unrestricted",
324325
"Individual",
325-
"AFN",
326-
"Bank",
327-
"Cash",
326+
"Distribution",
327+
"In Kind",
328328
"Afghanistan",
329329
"AF",
330330
"Kabul",

0 commit comments

Comments
 (0)