update the interview reschedule
This commit is contained in:
parent
a3348e1199
commit
f168ab4ba8
@ -2787,3 +2787,38 @@ class OnsiteInterviewForm(forms.Form):
|
||||
# instance.save()
|
||||
|
||||
# return instance
|
||||
|
||||
class ScheduledInterviewForm(forms.Form):
|
||||
topic = forms.CharField(
|
||||
max_length=255,
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={
|
||||
'class': 'form-control',
|
||||
'placeholder': 'e.g., Interview Topic'
|
||||
}),
|
||||
label=_('Interview Topic')
|
||||
)
|
||||
start_time = forms.DateTimeField(
|
||||
widget=forms.DateTimeInput(attrs={
|
||||
'class': 'form-control',
|
||||
'type': 'datetime-local',
|
||||
'required': True
|
||||
}),
|
||||
label=_('Start Time')
|
||||
)
|
||||
duration = forms.IntegerField(
|
||||
min_value=1,
|
||||
required=False,
|
||||
widget=forms.NumberInput(attrs={
|
||||
'class': 'form-control',
|
||||
'placeholder': 'Duration in minutes'
|
||||
}),
|
||||
label=_('Duration (minutes)')
|
||||
)
|
||||
|
||||
def clean_start_time(self):
|
||||
"""Validate start time is not in the past"""
|
||||
start_time = self.cleaned_data.get('start_time')
|
||||
if start_time and start_time < timezone.now():
|
||||
raise forms.ValidationError(_('Start time cannot be in the past.'))
|
||||
return start_time
|
||||
@ -379,18 +379,18 @@ class JobPosting(Base):
|
||||
@property
|
||||
def all_applications(self):
|
||||
# 1. Define the safe JSON extraction and conversion expression
|
||||
safe_score_expression = Cast(
|
||||
safe_score_expression = Cast(
|
||||
Coalesce(
|
||||
# Extract the score explicitly as a text string (KeyTextTransform)
|
||||
KeyTextTransform(
|
||||
'match_score',
|
||||
'match_score',
|
||||
KeyTransform('analysis_data_en', 'ai_analysis_data')
|
||||
),
|
||||
Value('0'), # Replace SQL NULL (from missing score) with the string '0'
|
||||
),
|
||||
output_field=IntegerField() # Cast the resulting string ('90' or '0') to an integer
|
||||
)
|
||||
|
||||
|
||||
# 2. Annotate the score using the safe expression
|
||||
return self.applications.annotate(
|
||||
sortable_score=safe_score_expression
|
||||
@ -428,7 +428,7 @@ class JobPosting(Base):
|
||||
@property
|
||||
def all_applications_count(self):
|
||||
return self.all_applications.count()
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def screening_applications_count(self):
|
||||
@ -766,7 +766,7 @@ class Application(Base):
|
||||
@property
|
||||
def resume_data_en(self):
|
||||
return self.ai_analysis_data.get("resume_data_en", {})
|
||||
|
||||
|
||||
@property
|
||||
def resume_data_ar(self):
|
||||
return self.ai_analysis_data.get("resume_data_ar", {})
|
||||
@ -853,7 +853,7 @@ class Application(Base):
|
||||
def recommendation(self) -> str:
|
||||
"""9. Provide a detailed final recommendation for the candidate."""
|
||||
return self.analysis_data_en.get("recommendation", "")
|
||||
|
||||
|
||||
#for arabic
|
||||
|
||||
@property
|
||||
@ -910,7 +910,7 @@ class Application(Base):
|
||||
def recommendation_ar(self) -> str:
|
||||
"""9. Provide a detailed final recommendation for the candidate."""
|
||||
return self.analysis_data_ar.get("recommendation", "")
|
||||
|
||||
|
||||
|
||||
# ====================================================================
|
||||
# 🔄 HELPER METHODS
|
||||
@ -1305,6 +1305,7 @@ class Interview(Base):
|
||||
)
|
||||
password = models.CharField(max_length=20, blank=True, null=True)
|
||||
zoom_gateway_response = models.JSONField(blank=True, null=True)
|
||||
details_url = models.JSONField(blank=True, null=True)
|
||||
participant_video = models.BooleanField(default=True)
|
||||
join_before_host = models.BooleanField(default=False)
|
||||
host_email = models.CharField(max_length=255, blank=True, null=True)
|
||||
|
||||
@ -363,7 +363,7 @@ def safe_cast_to_float(value, default=0.0):
|
||||
# return
|
||||
# # Ensure the result is parsed as a Python dict (if ai_handler returns a JSON string)
|
||||
# data = result['data']
|
||||
|
||||
|
||||
# if isinstance(data, str):
|
||||
# data = json.loads(data)
|
||||
# print(data)
|
||||
@ -634,7 +634,7 @@ def handle_resume_parsing_and_scoring(pk: int):
|
||||
logger.error(f"AI handler returned error for candidate {instance.pk}")
|
||||
print(f"AI handler returned error for candidate {instance.pk}")
|
||||
return
|
||||
|
||||
|
||||
# Ensure the result is parsed as a Python dict
|
||||
data = result['data']
|
||||
if isinstance(data, str):
|
||||
@ -711,8 +711,8 @@ def create_interview_and_meeting(
|
||||
password=result["meeting_details"]["password"],
|
||||
location_type="Remote"
|
||||
)
|
||||
schedule.interviews = interview
|
||||
schedule.status = "Remote"
|
||||
schedule.interview = interview
|
||||
schedule.status = "scheduled"
|
||||
|
||||
schedule.save()
|
||||
|
||||
|
||||
@ -205,13 +205,11 @@ urlpatterns = [
|
||||
views_frontend.test_source_connection,
|
||||
name="test_source_connection",
|
||||
),
|
||||
|
||||
|
||||
# path(
|
||||
# "jobs/<slug:slug>/<int:application_id>/reschedule_meeting_for_application/<int:meeting_id>/",
|
||||
# views.reschedule_meeting_for_application,
|
||||
# name="reschedule_meeting_for_application",
|
||||
# ),
|
||||
path(
|
||||
"jobs/<slug:slug>/reschedule_meeting_for_application/",
|
||||
views.reschedule_meeting_for_application,
|
||||
name="reschedule_meeting_for_application",
|
||||
),
|
||||
path(
|
||||
"jobs/<slug:slug>/update_application_exam_status/",
|
||||
views.update_application_exam_status,
|
||||
|
||||
@ -586,7 +586,7 @@ def update_meeting(instance, updated_data):
|
||||
if result["status"] == "success":
|
||||
# Fetch the latest details from Zoom after successful update
|
||||
details_result = get_zoom_meeting_details(instance.meeting_id)
|
||||
|
||||
|
||||
if details_result["status"] == "success":
|
||||
zoom_details = details_result["meeting_details"]
|
||||
# Update instance with fetched details
|
||||
@ -594,7 +594,7 @@ def update_meeting(instance, updated_data):
|
||||
instance.topic = zoom_details.get("topic", instance.topic)
|
||||
|
||||
instance.duration = zoom_details.get("duration", instance.duration)
|
||||
instance.details_url = zoom_details.get("join_url", instance.details_url)
|
||||
# instance.details_url = zoom_details.get("join_url", instance.details_url)
|
||||
instance.password = zoom_details.get("password", instance.password)
|
||||
# Corrected status assignment: instance.status, not instance.password
|
||||
instance.status = zoom_details.get("status")
|
||||
|
||||
@ -78,6 +78,7 @@ from .forms import (
|
||||
PortalLoginForm,
|
||||
MessageForm,
|
||||
PersonForm,
|
||||
ScheduledInterviewForm
|
||||
# OnsiteLocationForm,
|
||||
# OnsiteReshuduleForm,
|
||||
# OnsiteScheduleForm,
|
||||
@ -131,8 +132,7 @@ from .models import (
|
||||
Source,
|
||||
Message,
|
||||
Document,
|
||||
# InterviewLocation,
|
||||
# InterviewNote,
|
||||
Interview
|
||||
)
|
||||
|
||||
|
||||
@ -2031,43 +2031,34 @@ def applications_document_review_view(request, slug):
|
||||
return render(request, "recruitment/applications_document_review_view.html", context)
|
||||
|
||||
|
||||
# @staff_user_required
|
||||
# def reschedule_meeting_for_application(request, slug, candidate_id, meeting_id):
|
||||
# job = get_object_or_404(JobPosting, slug=slug)
|
||||
# candidate = get_object_or_404(Application, pk=candidate_id)
|
||||
# meeting = get_object_or_404(ZoomMeetingDetails, pk=meeting_id)
|
||||
# form = ZoomMeetingForm(instance=meeting)
|
||||
@require_POST
|
||||
@staff_user_required
|
||||
def reschedule_meeting_for_application(request, slug):
|
||||
schedule_interview = get_object_or_404(ScheduledInterview, slug=slug)
|
||||
if request.method == "POST":
|
||||
form = ScheduledInterviewForm(request.POST)
|
||||
if form.is_valid():
|
||||
topic = form.cleaned_data.get("topic")
|
||||
start_time = form.cleaned_data.get("start_time")
|
||||
duration = form.cleaned_data.get("duration")
|
||||
updated_data = {
|
||||
"topic": topic,
|
||||
"start_time": start_time.isoformat() + "Z",
|
||||
"duration": duration,
|
||||
}
|
||||
result = update_meeting(schedule_interview.interview, updated_data)
|
||||
|
||||
# if request.method == "POST":
|
||||
# form = ZoomMeetingForm(request.POST, instance=meeting)
|
||||
# if form.is_valid():
|
||||
# instance = form.save(commit=False)
|
||||
# updated_data = {
|
||||
# "topic": instance.topic,
|
||||
# "start_time": instance.start_time.isoformat() + "Z",
|
||||
# "duration": instance.duration,
|
||||
# }
|
||||
# if instance.start_time < timezone.now():
|
||||
# messages.error(request, "Start time must be in the future.")
|
||||
# return redirect(
|
||||
# "reschedule_meeting_for_application",
|
||||
# slug=job.slug,
|
||||
# candidate_id=candidate_id,
|
||||
# meeting_id=meeting_id,
|
||||
# )
|
||||
if result["status"] == "success":
|
||||
messages.success(request, result["message"])
|
||||
else:
|
||||
messages.error(request, result["message"])
|
||||
else:
|
||||
print(form.errors)
|
||||
messages.error(request, "Invalid data submitted.")
|
||||
return redirect("interview_detail", slug=schedule_interview.slug)
|
||||
|
||||
# result = update_meeting(instance, updated_data)
|
||||
|
||||
# if result["status"] == "success":
|
||||
# messages.success(request, result["message"])
|
||||
# else:
|
||||
# messages.error(request, result["message"])
|
||||
# return redirect(
|
||||
# reverse("applications_interview_view", kwargs={"slug": job.slug})
|
||||
# )
|
||||
|
||||
# context = {"job": job, "candidate": candidate, "meeting": meeting, "form": form}
|
||||
# return render(request, "meetings/reschedule_meeting.html", context)
|
||||
# context = {"job": job, "application": application, "meeting": meeting, "form": form}
|
||||
# return render(request, "meetings/reschedule_meeting.html", context)
|
||||
|
||||
|
||||
# @staff_user_required
|
||||
@ -5872,8 +5863,11 @@ def interview_detail(request, slug):
|
||||
"""View details of a specific interview"""
|
||||
interview = get_object_or_404(ScheduledInterview, slug=slug)
|
||||
|
||||
reschedule_form = ScheduledInterviewForm()
|
||||
reschedule_form.initial['topic'] = interview.interview.topic
|
||||
context = {
|
||||
'interview': interview,
|
||||
'reschedule_form':reschedule_form
|
||||
}
|
||||
return render(request, 'interviews/interview_detail.html', context)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static i18n %}
|
||||
{% load static i18n crispy_forms_tags %}
|
||||
|
||||
{% block title %}{{ interview.application.name }} - {% trans "Interview Details" %} - ATS{% endblock %}
|
||||
|
||||
@ -245,7 +245,7 @@
|
||||
<button type="button" class="btn btn-outline-primary btn-sm"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#candidateModal"
|
||||
hx-get="{% url 'candidate_criteria_view_htmx' interview.application.pk %}"
|
||||
hx-get="#"
|
||||
hx-target="#candidateModalBody">
|
||||
<i class="fas fa-eye me-1"></i> {% trans "AI Scoring" %}
|
||||
</button>
|
||||
@ -643,21 +643,21 @@
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form method="post" action="#">
|
||||
<form method="post" action="{% url 'reschedule_meeting_for_application' interview.slug %}">
|
||||
{% csrf_token %}
|
||||
<div class="mb-3">
|
||||
<label for="new_date" class="form-label">{% trans "New Date" %}</label>
|
||||
<input type="date" class="form-control" id="new_date" name="new_date" required>
|
||||
{{reschedule_form|crispy}}
|
||||
{% comment %} <div class="mb-3">
|
||||
<label for="topic" class="form-label">{% trans "topic" %}</label>
|
||||
<input type="text" class="form-control" id="topic" name="topic" value="{{interview.interview.topic}}" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="new_time" class="form-label">{% trans "New Time" %}</label>
|
||||
<input type="time" class="form-control" id="new_time" name="new_time" required>
|
||||
<label for="start_time" class="form-label">{% trans "Start Time" %}</label>
|
||||
<input type="datetime-local" class="form-control" id="start_time" name="start_time" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="reschedule_reason" class="form-label">{% trans "Reason for Rescheduling" %}</label>
|
||||
<textarea class="form-control" id="reschedule_reason" name="reason" rows="3"
|
||||
placeholder="{% trans 'Optional: Provide reason for rescheduling' %}"></textarea>
|
||||
</div>
|
||||
<label for="duration" class="form-label">{% trans "Duration" %}</label>
|
||||
<input type="number" class="form-control" id="duration" name="duration" required>
|
||||
</div> {% endcomment %}
|
||||
<button type="submit" class="btn btn-main-action btn-sm">
|
||||
<i class="fas fa-redo-alt me-1"></i> {% trans "Reschedule" %}
|
||||
</button>
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
<table class="table candidate-table align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 40%;"><i class="fas fa-user me-1"></i> {% trans "Topic" %}</th>
|
||||
<th style="width: 35%;"><i class="fas fa-user me-1"></i> {% trans "Topic" %}</th>
|
||||
<th style="width: 15%;"><i class="fas fa-calendar-alt me-1"></i> {% trans "Date" %}</th>
|
||||
<th style="width: 5%;"><i class="fas fa-map-marker-alt me-1"></i> {% trans "Duration" %}</th>
|
||||
<th style="width: 10%;"><i class="fas fa-map-marker-alt me-1"></i> {% trans "Location" %}</th>
|
||||
<th style="width: 10%;"><i class="fas fa-hourglass-half me-1"></i> {% trans "Duration" %}</th>
|
||||
<th style="width: 10%;"><i class="fas fa-location-dot me-1"></i> {% trans "Location" %}</th>
|
||||
<th style="width: 10%;"><i class="fas fa-info-circle me-1"></i> {% trans "Status" %}</th>
|
||||
<th style="width: 10%;"><i class="fas fa-ellipsis-h me-1"></i> {% trans "Actions" %}</th>
|
||||
<th style="width: 10%;"> {% trans "Actions" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@ -266,12 +266,13 @@
|
||||
</th>
|
||||
<th style="width: 13%"><i class="fas fa-user me-1"></i> {% trans "Name" %}</th>
|
||||
<th style="width: 15%"><i class="fas fa-phone me-1"></i> {% trans "Contact" %}</th>
|
||||
<th style="width: 15%"><i class="fas fa-tag me-1"></i> {% trans "Topic" %}</th>
|
||||
{% comment %} <th style="width: 15%"><i class="fas fa-tag me-1"></i> {% trans "Topic" %}</th>
|
||||
<th style="width: 15%"><i class="fas fa-clock me-1"></i> {% trans "Duration" %}</th>
|
||||
<th style="width: 10%"><i class="fas fa-calendar me-1"></i> {% trans "Meeting Date" %}</th>
|
||||
<th style="width: 7%"><i class="fas fa-video me-1"></i> {% trans "Link" %}</th>
|
||||
<th style="width: 8%"><i class="fas fa-check-circle me-1"></i> {% trans "Meeting Status" %}</th>
|
||||
<th style="width: 5%"><i class="fas fa-check-circle me-1"></i> {% trans "Interview Result"%}</th>
|
||||
<th style="width: 8%"><i class="fas fa-check-circle me-1"></i> {% trans "Meeting Status" %}</th> {% endcomment %}
|
||||
<th style="width: 15%"><i class="fas fa-check-circle me-1"></i> {% trans "Interview Result"%}</th>
|
||||
<th style="width: 15%"><i class="fas fa-check-circle me-1"></i> {% trans "Interview List"%}</th>
|
||||
<th style="width: 10%"><i class="fas fa-cog me-1"></i> {% trans "Actions" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -301,7 +302,7 @@
|
||||
<i class="fas fa-phone me-1"></i> {{ application.phone }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="application-details text-muted">
|
||||
{% comment %} <td class="application-details text-muted">
|
||||
{% if application.get_latest_meeting %}
|
||||
{{ application.get_latest_meeting }}
|
||||
{% else %}
|
||||
@ -323,8 +324,8 @@
|
||||
<span class="text-muted">--</span>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
<td>
|
||||
</td> {% endcomment %}
|
||||
{% comment %} <td>
|
||||
{% with latest_meeting=application.get_latest_meeting %}
|
||||
{% if latest_meeting and latest_meeting.details_url %}
|
||||
<a href="{{ latest_meeting.details_url }}" target="_blank" class="btn btn-sm bg-primary-theme text-white" title="Join Interview"
|
||||
@ -336,8 +337,8 @@
|
||||
<span class="text-muted">--</span>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
<td>
|
||||
</td> {% endcomment %}
|
||||
{% comment %} <td>
|
||||
{{ latest_meeting.status }}
|
||||
{% with latest_meeting=application.get_latest_meeting %}
|
||||
{% if latest_meeting %}
|
||||
@ -351,7 +352,7 @@
|
||||
<span class="text-muted">--</span>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
</td> {% endcomment %}
|
||||
<td class="text-center" id="interview-result-{{ application.pk }}">
|
||||
{% if not application.interview_status %}
|
||||
<button type="button" class="btn btn-warning btn-sm"
|
||||
@ -377,6 +378,17 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#candidateviewModal"
|
||||
hx-get="{% url 'get_interview_list' application.slug %}"
|
||||
hx-target="#candidateviewModalBody">
|
||||
Interview List
|
||||
<i class="fas fa-list"></i>
|
||||
{{candidate.get_interviews}}
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
{% if application.get_latest_meeting %}
|
||||
@ -436,7 +448,7 @@
|
||||
hx-swap="innerHTML"
|
||||
hx-target="#candidateviewModalBody">
|
||||
<i class="fas fa-calendar-plus me-1"></i>
|
||||
Schedule
|
||||
Schedule Interview
|
||||
</button>
|
||||
{% comment %} <a href="{% url 'interview_create_type_selection' candidate_slug=candidate.slug %}"
|
||||
class="btn btn-main-action btn-sm"
|
||||
@ -445,14 +457,6 @@
|
||||
Schedule
|
||||
</a> {% endcomment %}
|
||||
{% endif %}
|
||||
<button type="button" class="btn btn-outline-primary btn-sm"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#candidateviewModal"
|
||||
hx-get="{% url 'get_interview_list' application.slug %}"
|
||||
hx-target="#candidateviewModalBody">
|
||||
<i class="fas fa-list"></i>
|
||||
</button>
|
||||
{{candidate.get_interviews}}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user