From 80791e5fa7f24c73699a7763d4b0f485776c7b0e Mon Sep 17 00:00:00 2001 From: Faheed Date: Thu, 18 Dec 2025 19:59:27 +0300 Subject: [PATCH] fix few ui issues --- NorahUniversity/settings.py | 2 +- recruitment/forms.py | 5 +- recruitment/services/ollama_service.py | 44 ++++++++ recruitment/views.py | 4 +- templates/includes/search_form.html | 12 +- templates/interviews/interview_detail.html | 16 +-- templates/interviews/interview_list.html | 105 +++++++++++------- templates/people/person_list.html | 4 +- .../recruitment/agency_assignment_list.html | 43 ++++--- templates/recruitment/agency_detail.html | 1 + templates/recruitment/applications_list.html | 2 +- 11 files changed, 157 insertions(+), 81 deletions(-) create mode 100644 recruitment/services/ollama_service.py diff --git a/NorahUniversity/settings.py b/NorahUniversity/settings.py index 32eedda..ccb1a6a 100644 --- a/NorahUniversity/settings.py +++ b/NorahUniversity/settings.py @@ -320,7 +320,7 @@ Q_CLUSTER = { "name": "KAAUH_CLUSTER", "workers": 2, "recycle": 500, - "timeout": 120, + "timeout": 360, "max_attempts": 1, "compress": True, "save_limit": 250, diff --git a/recruitment/forms.py b/recruitment/forms.py index 565476d..db7989b 100644 --- a/recruitment/forms.py +++ b/recruitment/forms.py @@ -2220,7 +2220,10 @@ Job: {job.title} if interview.location_type == 'Remote': initial_message += f"Pease join using meeting link {interview.join_url} \n\n" else: - initial_message += "This is an onsite schedule. Please arrive 10 minutes early.\n\n" + initial_message += f""" +Location: {interview.physical_address} +Room No: {interview.room_number} +This is an onsite schedule. Please arrive 10 minutes early.\n\n""" diff --git a/recruitment/services/ollama_service.py b/recruitment/services/ollama_service.py new file mode 100644 index 0000000..62f1f2b --- /dev/null +++ b/recruitment/services/ollama_service.py @@ -0,0 +1,44 @@ +import ollama +import re +# def clean_json_response(raw_string): +# """ +# Removes Markdown code blocks and extra whitespace from AI responses. +# """ +# # Use regex to find content between ```json and ``` or just ``` +# match = re.search(r'```(?:json)?\s*([\s\S]*?)\s*```', raw_string) +# if match: +# return match.group(1).strip() +# return raw_string.strip() + +import json +import re + +def robust_json_parser(raw_output): + # 1. Strip Markdown blocks + clean = re.sub(r'```(?:json)?|```', '', raw_output).strip() + + # 2. Fix trailing commas before closing braces/brackets + clean = re.sub(r',\s*([\]}])', r'\1', clean) + + try: + return json.loads(clean) + except json.JSONDecodeError: + # 3. Last resort: try to find the first '{' and last '}' + start_idx = clean.find('{') + end_idx = clean.rfind('}') + if start_idx != -1 and end_idx != -1: + try: + return json.loads(clean[start_idx:end_idx+1]) + except: + pass + raise + +def get_model_reponse(prompt): + response=ollama.chat( + model='alibayram/smollm3:latest', + messages=[{'role': 'user', 'content': prompt}], + stream=False # Set to True for real-time streaming + ) + # print(response['message']['content']) + response=robust_json_parser(response['message']['content']) + return response diff --git a/recruitment/views.py b/recruitment/views.py index 51b8cff..0221b4a 100644 --- a/recruitment/views.py +++ b/recruitment/views.py @@ -337,7 +337,7 @@ def create_job(request): logger.error(f"Error creating job: {e}") messages.error(request, f"Error creating job: {e}") else: - messages.error(request, f"Please correct the errors below.{form.errors}") + messages.error(request, f"Please correct the errors below.") else: form = JobPostingForm() return render(request, "jobs/create_job.html", {"form": form}) @@ -4795,6 +4795,8 @@ def interview_list(request): "search_query": search_query, "interviews": page_obj, "jobs": jobs, + "interview_type":interview_type, + } return render(request, "interviews/interview_list.html", context) diff --git a/templates/includes/search_form.html b/templates/includes/search_form.html index cc2656e..9ecb020 100644 --- a/templates/includes/search_form.html +++ b/templates/includes/search_form.html @@ -1,18 +1,16 @@ {% load i18n %} -
- - - - - + +
+ diff --git a/templates/interviews/interview_detail.html b/templates/interviews/interview_detail.html index 741a42a..0fc3317 100644 --- a/templates/interviews/interview_detail.html +++ b/templates/interviews/interview_detail.html @@ -774,18 +774,18 @@
{% if interview.interview_result %} - {% trans 'Interview Result : ' %} +
{% trans 'Interview Result : ' %}
{% if interview.interview_result == 'passed' %} -
+
- + {{ interview.interview_result|upper }}
{% if interview.result_comments %} -
+
{% trans 'Result Comment:' %}

@@ -796,7 +796,7 @@

{% elif interview.interview_result == 'failed' %} -
+
@@ -816,16 +816,16 @@
{% else %} -
+
- + {{ interview.interview_result|upper }}
{% if interview.result_comments %} -
+
{% trans 'Result Comment:' %}

diff --git a/templates/interviews/interview_list.html b/templates/interviews/interview_list.html index 7837ef9..1b54cec 100644 --- a/templates/interviews/interview_list.html +++ b/templates/interviews/interview_list.html @@ -174,51 +174,70 @@

-
-
-
- - - -
-
- - +
+
+
+
+ +
+ + {% include 'includes/search_form.html' %} + +
+
+ +
+
+ {# Keep search query context when filtering #} + {% if request.GET.search %}{% endif %} + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ + {% if request.GET.search or request.GET.job or request.GET.status or request.GET.type %} + + {% trans 'Clear Filter' %} + + {% endif %} +
+
+
-
- - -
-
- - -
-
- - - {% trans "Clear" %} - -
- +
+
{% if interviews %}
diff --git a/templates/people/person_list.html b/templates/people/person_list.html index 56c8a82..8659c96 100644 --- a/templates/people/person_list.html +++ b/templates/people/person_list.html @@ -201,9 +201,9 @@ - {% if request.GET.q or request.GET.nationality or request.GET.gender %} + {% if search_query or nationality %} - {% trans "Clear" %} + {% trans "Clear Filter" %} {% endif %}
diff --git a/templates/recruitment/agency_assignment_list.html b/templates/recruitment/agency_assignment_list.html index 1aa0212..649a87d 100644 --- a/templates/recruitment/agency_assignment_list.html +++ b/templates/recruitment/agency_assignment_list.html @@ -71,18 +71,24 @@
-
-
-
- - + +
+ +
+ + + +
+
-
+
- @@ -91,15 +97,18 @@
-
-
- - - -
-
+
+
+ + {% if status_filter or search_query %} + + {% trans "Clear Filter" %} + + {% endif %} +
+
diff --git a/templates/recruitment/agency_detail.html b/templates/recruitment/agency_detail.html index 6e95740..f6706c9 100644 --- a/templates/recruitment/agency_detail.html +++ b/templates/recruitment/agency_detail.html @@ -584,6 +584,7 @@ {% if application.phone %} {{ application.phone }} {% endif %} + {{ application.job.title}}
diff --git a/templates/recruitment/applications_list.html b/templates/recruitment/applications_list.html index f372a58..c7b99aa 100644 --- a/templates/recruitment/applications_list.html +++ b/templates/recruitment/applications_list.html @@ -251,7 +251,7 @@ {% if job_filter or stage_filter or search_query %} - {% trans "Clear" %} + {% trans "Clear Filter" %} {% endif %}