[UPDT] ONBOARDING: #906

This commit is contained in:
Horilla
2025-10-20 15:22:49 +05:30
parent d727acf654
commit 34f76f2642
3 changed files with 48 additions and 2 deletions

View File

@@ -1,7 +1,29 @@
<form hx-post="{% url 'add-to-rejected-candidates' %}?candidate_id={{form.instance.candidate_id.id}}">
{{form.as_p}}
{% load i18n %}
<form
hx-post="{% url 'add-to-rejected-candidates' %}?candidate_id={{ form.instance.candidate_id.id }}"
id="rejection_form"
>
{{ form.as_p }}
</form>
<script>
{
$("form[hx-post] .col-md-6").removeClass("col-md-6");
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>
`;
$('#rejection_form div.flex-row-reverse').append(button_container);
}
}
</script>

View File

@@ -142,6 +142,11 @@ urlpatterns = [
views.add_to_rejected_candidates,
name="add-to-rejected-candidates",
),
path(
"delete-candidate-rejection/<int:rej_id>/",
views.delete_candidate_rejection,
name="delete-candidate-rejection",
),
path(
"candidate-select-filter-onboarding",
views.candidate_select_filter,

View File

@@ -1802,6 +1802,25 @@ def add_to_rejected_candidates(request):
return render(request, "onboarding/rejection/form.html", {"form": form})
@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>")
@login_required
def candidate_select(request):
"""