Skip to content

Commit

Permalink
rdi xlsx download template based on program.dct.type
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlo-mk committed Mar 5, 2024
1 parent 1dcdce1 commit 6be75ec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backend/hct_mis_api/apps/registration_datahub/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
from django.shortcuts import get_object_or_404

from hct_mis_api.apps.core.models import DataCollectingType
from hct_mis_api.apps.core.utils import get_program_id_from_headers
from hct_mis_api.apps.core.utils import decode_id_string
from hct_mis_api.apps.program.models import Program
from hct_mis_api.apps.registration_datahub.template_generator import (
TemplateFileGenerator,
)


def download_template(request: HttpRequest) -> HttpResponse:
program_id = get_program_id_from_headers(request.headers)
parse_result = urlparse(request.headers["Referer"])
business_area_slug = parse_result.path[1:].split("/")[0]
split_url = parse_result.path[1:].split("/")
program_id = decode_id_string(split_url[2])
business_area_slug = split_url[0]
if program_id:
program = get_object_or_404(Program, id=program_id)
is_program_for_social_worker = program.data_collecting_type.type == DataCollectingType.Type.SOCIAL
else:
# TODO change after FE update
is_program_for_social_worker = True
is_program_for_social_worker = False
mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
filename = (
"registration_data_import_template_social_worker.xlsx"
Expand Down

0 comments on commit 6be75ec

Please sign in to comment.