[FIX] EMPLOYEE: Fixed the employee field changing in document upload

This commit is contained in:
Horilla
2025-10-13 16:54:53 +05:30
parent f0f2ad1708
commit 7f56e4ed71
3 changed files with 11 additions and 6 deletions

View File

@@ -10,13 +10,10 @@
<form id="file-form" hx-post="{% url 'file-upload' document.id %}" hx-target="#objectCreateModalTarget"
hx-encoding="multipart/form-data" class="oh-profile-section pt-3">
{% csrf_token %}
{% if form.employee_id %}
<input type="hidden" name="employee_id" value="{{form.employee_id.value}}" />
{% elif form.candidate_id %}
{% if form.candidate_id %}
<input type="hidden" name="candidate_id" value="{{form.candidate_id.value}}" />
{% endif %}
{{ form.non_field_errors }}
<div class="row">
<div class="col-12 col-sm-12 col-md-4 col-lg-6">
<div class="oh-input__group">

View File

@@ -773,7 +773,8 @@ def file_upload(request, id):
except:
pass
return HttpResponse("<script>window.location.reload();</script>")
else:
logger.error(f"Document upload form errors: {form.errors}")
context = {"form": form, "document": document_item}
return render(request, "tabs/htmx/document_form.html", context=context)

View File

@@ -81,7 +81,14 @@ class DocumentUpdateForm(ModelForm):
class Meta:
model = Document
fields = "__all__"
exclude = ["is_active"]
exclude = [
"title",
"document_request_id",
"status",
"created_by",
"modified_by",
"employee_id",
]
widgets = {
"issue_date": forms.DateInput(
attrs={"type": "date", "class": "oh-input w-100"}