[FIX] RECRUITMENT: Fixed recruitment view showing archived recruitments
This commit is contained in:
@@ -186,6 +186,14 @@ class RecruitmentFilter(FilterSet):
|
||||
initial="no",
|
||||
empty_label="No",
|
||||
)
|
||||
is_active = django_filters.ChoiceFilter(
|
||||
choices=[
|
||||
(True, "Yes"),
|
||||
(False, "No"),
|
||||
],
|
||||
initial="Yes",
|
||||
empty_label="Yes",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
"""
|
||||
|
||||
@@ -232,6 +232,7 @@ class RecruitmentCreationForm(ModelForm):
|
||||
|
||||
model = Recruitment
|
||||
fields = "__all__"
|
||||
exclude = ["is_active"]
|
||||
widgets = {
|
||||
"start_date": forms.DateInput(attrs={"type": "date"}),
|
||||
"end_date": forms.DateInput(attrs={"type": "date"}),
|
||||
|
||||
@@ -41,7 +41,7 @@ x-data="{searchShow: false}"
|
||||
<div class="oh-main__titlebar-button-container">
|
||||
|
||||
<div class="oh-dropdown" x-data="{open: false}">
|
||||
<button class="oh-btn ml-2" @click="open = !open">
|
||||
<button class="oh-btn ml-2" @click="open = !open" type="button">
|
||||
<ion-icon name="filter" class="mr-1"></ion-icon>{% trans "Filter" %}<div id="filterCount"></div>
|
||||
</button>
|
||||
<div
|
||||
|
||||
@@ -177,6 +177,13 @@
|
||||
<a hx-get="{% url 'recruitment-update' rec.id %}" hx-target='#updateFormContainer' hx-swap='innerHTML' data-toggle='oh-modal-toggle' data-target='#updateRecruitmentModal' class="oh-btn oh-btn--light-bkg w-100" title="Edit"><ion-icon name="create-outline"></ion-icon></a>
|
||||
{% endif %}
|
||||
<a hx-get="{% url 'recruitment-duplicate' rec.id %}" hx-target='#duplicateFormContainer' hx-swap='innerHTML' data-toggle='oh-modal-toggle' data-target='#duplicateRecruitmentModal' class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Duplicate' %}"><ion-icon name="copy-outline"></ion-icon></a>
|
||||
{% if perms.recruitment.delete_recruitment %}
|
||||
{% if rec.is_active %}
|
||||
<a href="{% url 'recruitment-archive' rec.id %}" class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Archive' %}"><ion-icon name="archive"></ion-icon></a>
|
||||
{% else %}
|
||||
<a href="{% url 'recruitment-archive' rec.id %}" class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Unarchive' %}"><ion-icon name="archive"></ion-icon></a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if perms.recruitment.delete_recruitment %}
|
||||
<form
|
||||
action="{% url 'recruitment-delete' rec.id %}"
|
||||
|
||||
@@ -82,6 +82,7 @@ urlpatterns = [
|
||||
),
|
||||
path("pipeline/", views.recruitment_pipeline, name="pipeline"),
|
||||
path("pipeline-card", views.recruitment_pipeline_card, name="pipeline-card"),
|
||||
path("recruitment-archive/<int:rec_id>", views.recruitment_archive, name="recruitment-archive"),
|
||||
path(
|
||||
"pipeline-search-candidate",
|
||||
recruitment.views.search.pipeline_candidate_search,
|
||||
|
||||
@@ -34,6 +34,18 @@ def recruitment_search(request):
|
||||
previous_data = request.GET.urlencode()
|
||||
recruitment_obj = sortby(request, filter_obj.qs, "orderby")
|
||||
data_dict = parse_qs(previous_data)
|
||||
if not request.GET.get("is_active"):
|
||||
filter_obj.form.initial["is_active"] = True
|
||||
data_dict["is_active"] = request.GET.get("is_active")
|
||||
recruitment_obj = recruitment_obj.filter(is_active=True)
|
||||
|
||||
for key, val in data_dict.copy().items():
|
||||
try:
|
||||
if val[0] != "False" or key == "view":
|
||||
del data_dict[key]
|
||||
except:
|
||||
del data_dict[key]
|
||||
|
||||
get_key_instances(Recruitment, data_dict)
|
||||
|
||||
return render(
|
||||
|
||||
@@ -194,7 +194,21 @@ def recruitment_view(request):
|
||||
template = "recruitment/recruitment_view.html"
|
||||
else:
|
||||
template = "recruitment/recruitment_empty.html"
|
||||
|
||||
filter_obj = RecruitmentFilter(request.GET, queryset)
|
||||
|
||||
filter_dict = parse_qs(request.GET.urlencode())
|
||||
if not request.GET.get("is_active"):
|
||||
print("]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]")
|
||||
filter_obj.form.initial["is_active"] = True
|
||||
filter_dict["is_active"] = ["true"]
|
||||
for key, val in filter_dict.copy().items():
|
||||
try:
|
||||
if val[0] != "false" or key == "view":
|
||||
del filter_dict[key]
|
||||
except:
|
||||
del filter_dict[key]
|
||||
|
||||
return render(
|
||||
request,
|
||||
template,
|
||||
@@ -202,6 +216,7 @@ def recruitment_view(request):
|
||||
"data": paginator_qry(filter_obj.qs, request.GET.get("page")),
|
||||
"f": filter_obj,
|
||||
"form": form,
|
||||
"filter_dict":filter_dict,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -434,6 +449,24 @@ def recruitment_pipeline_card(request):
|
||||
{"recruitment": recruitment_obj, "candidates": candidates, "stages": stages},
|
||||
)
|
||||
|
||||
@login_required
|
||||
@permission_required(perm="recruitment.delete_recruitment")
|
||||
def recruitment_archive(request,rec_id):
|
||||
"""
|
||||
This method is used to archive and unarchive the recruitment
|
||||
args:
|
||||
rec_id: The id of the Recruitment
|
||||
"""
|
||||
|
||||
recruitment = Recruitment.objects.get(id=rec_id)
|
||||
if recruitment.is_active:
|
||||
recruitment.is_active = False
|
||||
else:
|
||||
recruitment.is_active = True
|
||||
recruitment.save()
|
||||
|
||||
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
|
||||
|
||||
|
||||
@login_required
|
||||
@recruitment_manager_can_enter(perm="recruitment.change_stage")
|
||||
|
||||
Reference in New Issue
Block a user