From c3de2f3c752ed22ffd780455346bfcc7318eaae7 Mon Sep 17 00:00:00 2001 From: Horilla Date: Thu, 1 Jan 2026 13:36:24 +0530 Subject: [PATCH] [FIX] EMPLOYEE: Fix screen appears blank and the document is not displayed --- employee/templates/tabs/htmx/view_file.html | 64 +++++++++++---------- employee/views.py | 44 +++++++------- 2 files changed, 57 insertions(+), 51 deletions(-) diff --git a/employee/templates/tabs/htmx/view_file.html b/employee/templates/tabs/htmx/view_file.html index ff73f0197..5383bace3 100644 --- a/employee/templates/tabs/htmx/view_file.html +++ b/employee/templates/tabs/htmx/view_file.html @@ -60,40 +60,46 @@ {% if document.document %} {% if document.status == 'rejected' %} -

{% trans "Reject Reason: " %}

-

{{document.reject_reason}}

+

{% trans "Reject Reason: " %}

+

{{document.reject_reason}}

{% endif %} {% else %} -
- Page not found. 404. -

- {% trans "No Document to view." %} -

-
+
+ Page not found. 404. +

+ {% trans "No Document to view." %} +

+
{% endif %} diff --git a/employee/views.py b/employee/views.py index d932c1b2d..4d243f8f5 100755 --- a/employee/views.py +++ b/employee/views.py @@ -870,6 +870,28 @@ def file_upload(request, id): return render(request, "tabs/htmx/document_form.html", context=context) +def get_content_type(file_extension): + """ + This function retuns the content type of a file + parameters: + + file_extension: The file extension of the file + """ + + content_types = { + "pdf": "application/pdf", + "txt": "text/plain", + "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "jpg": "image/jpeg", + "png": "image/png", + "jpeg": "image/jpeg", + } + + # Default to application/octet-stream if the file extension is not recognized + return content_types.get(file_extension, "application/octet-stream") + + @login_required @hx_request_required def view_file(request, id): @@ -908,28 +930,6 @@ def view_file(request, id): return render(request, "tabs/htmx/view_file.html", context) -def get_content_type(file_extension): - """ - This function retuns the content type of a file - parameters: - - file_extension: The file extension of the file - """ - - content_types = { - "pdf": "application/pdf", - "txt": "text/plain", - "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - "jpg": "image/jpeg", - "png": "image/png", - "jpeg": "image/jpeg", - } - - # Default to application/octet-stream if the file extension is not recognized - return content_types.get(file_extension, "application/octet-stream") - - @login_required @hx_request_required @manager_can_enter("horilla_documents.add_document")