[UPDT] RECRUITMENT: Revert rejected candidates

This commit is contained in:
Horilla
2025-10-21 15:43:27 +05:30
parent deabaf5c5b
commit d402040b20
4 changed files with 49 additions and 0 deletions

View File

@@ -989,6 +989,7 @@ class RejectReasonFormView(HorillaFormView):
form_class = RejectedCandidateForm
new_display_title = "Rejected Candidate"
dynamic_create_fields = [("reject_reason_id", DynamicRejectReasonFormView)]
template_name = "candidate/candidate_rejection_form.html"
def get_initial(self) -> dict:
initial = super().get_initial()

View File

@@ -0,0 +1,23 @@
{% load i18n %}
{% include "generic/horilla_form.html" %}
<script>
{
const rejId = "{{ form.instance.id|default:'' }}";
if (rejId) {
// Build dynamic URL for deletion
const deleteUrlBase = "{% url 'delete-candidate-rejection' 0 %}";
const deleteUrl = deleteUrlBase.replace('0', rejId);
const button_container = `
<button class="oh-btn oh-btn--info mt-2 mr-2 pl-4 pr-5 oh-btn--w-100-resp"
hx-post="${deleteUrl}"
hx-confirm="Are you sure you want to cancel this rejection?"
onclick="event.preventDefault(); event.stopPropagation();">
{% trans 'Cancel Rejection' %}
</button>
`;
// Append the button to the form
$('#{{ view_id }}Form div.flex-row-reverse').append(button_container);
}
}
</script>

View File

@@ -660,6 +660,11 @@ urlpatterns = [
candidates.RejectReasonFormView.as_view(),
name="add-to-rejected-candidates",
),
path(
"delete-candidate-rejection/<int:rej_id>/",
views.delete_candidate_rejection,
name="delete-candidate-rejection",
),
path(
"skill-zone-cand-delete/<int:sz_cand_id>",
views.skill_zone_cand_delete,

View File

@@ -111,6 +111,7 @@ from recruitment.models import (
Recruitment,
RecruitmentGeneralSetting,
RecruitmentSurvey,
RejectedCandidate,
RejectReason,
Resume,
Skill,
@@ -3861,3 +3862,22 @@ def employee_profile_interview_tab(request):
).order_by("is_today", "-interview_date", "interview_time")
return render(request, "tabs/scheduled_interview.html", {"interviews": interviews})
@login_required
@hx_request_required
@permission_required("recruitment.delete_rejectedcandidate")
def delete_candidate_rejection(request, rej_id):
"""
This method is used to delete candidate rejection
"""
try:
instance = RejectedCandidate.objects.filter(id=rej_id).first()
if instance:
instance.delete()
messages.success(request, "Candidate rejection deleted successfully")
else:
messages.error(request, "Candidate rejection not found")
except Exception as e:
messages.error(request, "Error occurred while deleting candidate rejection")
return HttpResponse("<script>window.location.reload()</script>")