[UPDT] Onboarding stage sequence

This commit is contained in:
Horilla
2023-09-15 11:13:26 +05:30
parent 4b0fdf8c19
commit 359b34641f
2 changed files with 65 additions and 20 deletions

View File

@@ -108,15 +108,16 @@
</div>
</section>
<div id = "stage-messages"></div>
<div class="oh-tabs">
<ul class="oh-tabs__tablist">
{% for rec in recruitments %}
<li class="oh-tabs__tab " data-target="#tab_{{rec.id}}" data-recruitment-id="{{rec.id}}">
{{rec.title}}
<button class="oh-btn oh-btn--sq-sm oh-btn--transparent oh-tabs__close-btn" title="{% trans "Close" %}">
<ion-icon name="close-outline"></ion-icon>
</button>
<span
class="oh-badge oh-badge--secondary oh-badge--small oh-badge--round ms-2 mr-2" title="{{rec.onboardingstage_set.all|length}} {% trans 'Stage' %}">
{{rec.onboardingstage_set.all|length}}
</span>
</li>
{% endfor %}
@@ -129,8 +130,18 @@
<div class="oh-kanban__section stage" id="b3a7bac2-2a16-40fe-9b7e-78a1101ee9d3" data-recruitment-id="{{rec.id}}" data-stage-id="{{stage.id}}" data-sequence="{{forloop.counter}}">
<div class="oh-kanban__section-head oh-kanban__section-head--white">
<div class="d-flex ">
<span class="oh-kanban__section-title" data-type="label">{{stage.stage_title}}</span>
<span class="oh-badge oh-badge--secondary oh-badge--small oh-badge--round ms-2 mr-2 stage_count">{{stage.candidate.count}}</span>
<span class="oh-kanban__section-title" data-type="label">
<input
class="oh-tabs__movable-title oh-table__editable-input"
value="{{stage}}"
hx-post="{% url 'stage-name-update' stage.id %}"
name='stage'
hx-target="#stage-messages"
style="width: 160px;"
readonly=""
/>
</span>
<span class="oh-badge oh-badge--secondary oh-badge--small oh-badge--round ms-2 mr-2 stage_count" title="{{stage.candidate.count}} {% trans 'Candidate' %}">{{stage.candidate.count}}</span>
</div>
<div class="oh-kanban__head-actions oh-kanban__dropdown">
<button

View File

@@ -30,6 +30,7 @@ from base.methods import get_key_instances
from recruitment.models import Candidate, Recruitment
from recruitment.filters import CandidateFilter
from employee.models import Employee, EmployeeWorkInformation, EmployeeBankDetails
from django.db.models import ProtectedError
from onboarding.forms import (
OnboardingCandidateForm,
UserCreationForm,
@@ -176,11 +177,13 @@ def stage_delete(request, stage_id):
Returns:
GET : return onboarding view
"""
onboarding_stage = OnboardingStage.objects.get(id=stage_id)
if not onboarding_stage.candidate.exists():
onboarding_stage.delete()
messages.success(request, _("the stage deleted successfully..."))
else:
try:
OnboardingStage.objects.get(id=stage_id).delete()
messages.success(request, _("The stage deleted successfully..."))
except OnboardingStage.DoesNotExist:
messages.error(request, _("Stage not found."))
except ProtectedError:
messages.error(request, _("There are candidates in this stage..."))
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
@@ -300,9 +303,13 @@ def task_delete(request, task_id):
Returns:
GET : return onboarding view
"""
onboarding_task = OnboardingTask.objects.get(id=task_id)
onboarding_task.delete()
messages.success(request, _("The task deleted successfully..."))
try:
OnboardingTask.objects.get(id=task_id).delete()
messages.success(request, _("The task deleted successfully..."))
except OnboardingTask.DoesNotExist:
messages.error(request, _("Task not found."))
except ProtectedError:
messages.error(request, _("Related entries exists"))
return redirect(onboarding_view)
@@ -369,8 +376,13 @@ def candidate_delete(request, obj_id):
Returns:
GET : return candidate view
"""
Candidate.objects.get(id=obj_id).delete()
messages.success(request, _("Candidate deleted successfully.."))
try:
Candidate.objects.get(id=obj_id).delete()
messages.success(request, _("Candidate deleted successfully.."))
except Candidate.DoesNotExist:
messages.error(request, _("Candidate not found."))
except ProtectedError:
messages.error(request, _("Related entries exists"))
return redirect(candidates_view)
@@ -471,7 +483,9 @@ def email_send(request):
candidates = request.POST.get("candidates")
json_mylist = json.loads(candidates)
if len(json_mylist) <= 0:
return JsonResponse({"message": _("No candidate choosed"), "tags": "danger"})
return JsonResponse(
{"message": _("No candidate has chosen."), "tags": "danger"}
)
for cand_id in json_mylist:
candidate = Candidate.objects.get(id=cand_id)
if candidate.start_onboard is False:
@@ -1039,7 +1053,9 @@ def update_joining(request):
return JsonResponse(
{
"type": "success",
"message": f"{candidate_obj.name}'s Date of joining updated sussefully",
"message": _("{candidate}'s Date of joining updated sussefully").format(
candidate=candidate_obj.name
),
}
)
@@ -1113,7 +1129,9 @@ def candidate_sequence_update(request):
cand.save()
updated = True
if updated:
return JsonResponse({"message": "Candidate sequence updated", "type": "info"})
return JsonResponse(
{"message": _("Candidate sequence updated"), "type": "info"}
)
return JsonResponse({"type": "fail"})
@@ -1134,10 +1152,26 @@ def stage_sequence_update(request):
updated = True
if updated:
return JsonResponse({"type": "success", "message": "Stage sequence updated"})
return JsonResponse({"type": "success", "message": _("Stage sequence updated")})
return JsonResponse({"type": "fail"})
@login_required
@require_http_methods(["POST"])
@hx_request_required
def stage_name_update(request, stage_id):
"""
This method is used to update the name of recruitment stage
"""
stage_obj = OnboardingStage.objects.get(id=stage_id)
stage_obj.stage_title = request.POST["stage"]
stage_obj.save()
message = _("The stage title has been updated successfully")
return HttpResponse(
f'<div class="oh-alert-container"><div class="oh-alert oh-alert--animated oh-alert--success">{message}</div></div>'
)
@login_required
@stage_manager_can_enter("recruitment.change_candidate")
def onboarding_send_mail(request, candidate_id):