[UPDT] RECRUITMENT: Changed signals to signals.py
This commit is contained in:
@@ -25,6 +25,7 @@ class RecruitmentConfig(AppConfig):
|
||||
|
||||
from horilla.horilla_settings import APPS
|
||||
from horilla.urls import urlpatterns
|
||||
from recruitment import signals
|
||||
|
||||
APPS.append("recruitment")
|
||||
urlpatterns.append(
|
||||
|
||||
@@ -246,27 +246,6 @@ class Recruitment(HorillaModel):
|
||||
return True
|
||||
|
||||
|
||||
@receiver(post_save, sender=Recruitment)
|
||||
def create_initial_stage(sender, instance, created, **kwargs):
|
||||
"""
|
||||
This is post save method, used to create initial stage for the recruitment
|
||||
"""
|
||||
if created:
|
||||
applied_stage = Stage()
|
||||
applied_stage.sequence = 0
|
||||
applied_stage.recruitment_id = instance
|
||||
applied_stage.stage = "Applied"
|
||||
applied_stage.stage_type = "applied"
|
||||
applied_stage.save()
|
||||
|
||||
initial_stage = Stage()
|
||||
initial_stage.sequence = 1
|
||||
initial_stage.recruitment_id = instance
|
||||
initial_stage.stage = "Initial"
|
||||
initial_stage.stage_type = "initial"
|
||||
initial_stage.save()
|
||||
|
||||
|
||||
class Stage(HorillaModel):
|
||||
"""
|
||||
Stage model
|
||||
@@ -617,9 +596,6 @@ class Candidate(HorillaModel):
|
||||
ordering = ["sequence"]
|
||||
|
||||
|
||||
from horilla.signals import pre_bulk_update
|
||||
|
||||
|
||||
class RejectReason(HorillaModel):
|
||||
"""
|
||||
RejectReason
|
||||
@@ -820,21 +796,6 @@ class RecruitmentSurveyAnswer(HorillaModel):
|
||||
return f"{self.candidate_id.name}-{self.recruitment_id}"
|
||||
|
||||
|
||||
class RecruitmentMailTemplate(HorillaModel):
|
||||
title = models.CharField(max_length=25, unique=True)
|
||||
body = models.TextField()
|
||||
company_id = models.ForeignKey(
|
||||
Company,
|
||||
null=True,
|
||||
blank=True,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_("Company"),
|
||||
)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.title}"
|
||||
|
||||
|
||||
class SkillZone(HorillaModel):
|
||||
""" "
|
||||
Model for talent pool
|
||||
@@ -1054,24 +1015,3 @@ class CandidateDocument(HorillaModel):
|
||||
raise ValidationError(
|
||||
{"document": _("Please upload {} file only.").format(format)}
|
||||
)
|
||||
|
||||
|
||||
@receiver(m2m_changed, sender=CandidateDocumentRequest.candidate_id.through)
|
||||
def document_request_m2m_changed(sender, instance, action, **kwargs):
|
||||
if action == "post_add":
|
||||
candidate_document_create(instance)
|
||||
|
||||
elif action == "post_remove":
|
||||
candidate_document_create(instance)
|
||||
|
||||
|
||||
def candidate_document_create(instance):
|
||||
candidates = instance.candidate_id.all()
|
||||
for candidate in candidates:
|
||||
document, created = CandidateDocument.objects.get_or_create(
|
||||
candidate_id=candidate,
|
||||
document_request_id=instance,
|
||||
defaults={"title": f"Upload {instance.title}"},
|
||||
)
|
||||
document.title = f"Upload {instance.title}"
|
||||
document.save()
|
||||
|
||||
47
recruitment/signals.py
Normal file
47
recruitment/signals.py
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
from django.dispatch import receiver
|
||||
from django.db.models.signals import post_save, m2m_changed
|
||||
from recruitment.models import CandidateDocument, CandidateDocumentRequest, Recruitment, Stage
|
||||
|
||||
|
||||
@receiver(post_save, sender=Recruitment)
|
||||
def create_initial_stage(sender, instance, created, **kwargs):
|
||||
"""
|
||||
This is post save method, used to create initial stage for the recruitment
|
||||
"""
|
||||
if created:
|
||||
applied_stage = Stage()
|
||||
applied_stage.sequence = 0
|
||||
applied_stage.recruitment_id = instance
|
||||
applied_stage.stage = "Applied"
|
||||
applied_stage.stage_type = "applied"
|
||||
applied_stage.save()
|
||||
|
||||
initial_stage = Stage()
|
||||
initial_stage.sequence = 1
|
||||
initial_stage.recruitment_id = instance
|
||||
initial_stage.stage = "Initial"
|
||||
initial_stage.stage_type = "initial"
|
||||
initial_stage.save()
|
||||
|
||||
|
||||
@receiver(m2m_changed, sender=CandidateDocumentRequest.candidate_id.through)
|
||||
def document_request_m2m_changed(sender, instance, action, **kwargs):
|
||||
if action == "post_add":
|
||||
candidate_document_create(instance)
|
||||
|
||||
elif action == "post_remove":
|
||||
candidate_document_create(instance)
|
||||
|
||||
|
||||
def candidate_document_create(instance):
|
||||
candidates = instance.candidate_id.all()
|
||||
for candidate in candidates:
|
||||
document, created = CandidateDocument.objects.get_or_create(
|
||||
candidate_id=candidate,
|
||||
document_request_id=instance,
|
||||
defaults={"title": f"Upload {instance.title}"},
|
||||
)
|
||||
document.title = f"Upload {instance.title}"
|
||||
document.save()
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
{% extends 'index.html' %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
<style>
|
||||
.truncated-text {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.truncated-text::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 80%);
|
||||
pointer-events: none;
|
||||
/* Allow interaction with the text beneath the overlay */
|
||||
}
|
||||
</style>
|
||||
|
||||
<section class="oh-wrapper oh-main__topbar">
|
||||
<div class="oh-main__titlebar oh-main__titlebar--left oh-d-flex-column--resp oh-mb-3--small">
|
||||
<h1 class="oh-main__titlebar-title fw-bold">{% trans "Mail Templates" %}</h1>
|
||||
</div>
|
||||
{% if perms.recruitment.add_recruitmentmailtemplate %}
|
||||
<div class="oh-main__titlebar oh-main__titlebar--right oh-d-flex-column--resp oh-mb-3--small">
|
||||
<a href="#" data-toggle="oh-modal-toggle" data-target="#addTemplateModal" class="oh-btn oh-btn--secondary ml-2"><ion-icon name="add" class="mr-1 md hydrated" role="img" aria-label="add"></ion-icon>{% trans "Add" %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
<main :class="sidebarOpen ? 'oh-main__sidebar-visible' : ''">
|
||||
|
||||
<div class="oh-wrapper">
|
||||
<div class="oh-404">
|
||||
<img style=" width: 150px;height: 150px;" src="{% static 'images/ui/email.png' %}" class="oh-404__image mb-4" alt="Page not found. 404."/>
|
||||
<h5 class="oh-404__subtitle">{% trans "There are currently no email templates." %}</h5>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="oh-modal" id="viewTemplateModal" role="dialog" aria-labelledby="viewTemplateModal" aria-hidden="true">
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<span class="oh-modal__dialog-title" id="viewTemplateModalLabel"></span>
|
||||
<button class="oh-modal__close" aria-label="Close"><ion-icon name="close-outline"></ion-icon></button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id="viewTemplateModalBody"></div>
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<button type="submit" onclick="$('#submitFormButton')[0].click()" class="oh-btn oh-btn--secondary oh-btn--shadow">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-modal" id="addTemplateModal" role="dialog" aria-labelledby="addTemplateModal" aria-hidden="true">
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<span class="oh-modal__dialog-title" id="addTemplateModalLabel">{% trans "Add Template" %}</span>
|
||||
<button class="oh-modal__close" aria-label="Close"><ion-icon name="close-outline"></ion-icon></button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id="addTemplateModalBody">
|
||||
{% include 'offerletter/htmx/form.html' %}
|
||||
</div>
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<button type="submit" onclick="$('#submitFormButton')[0].click()" class="oh-btn oh-btn--secondary oh-btn--shadow">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-modal" id="duplicateTemplateModal" role="dialog" aria-labelledby="duplicateTemplateModal" aria-hidden="true">
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<span class="oh-modal__dialog-title" id="duplicateTemplateModalLabel">{% trans "Duplicate Template" %}</span>
|
||||
<button class="oh-modal__close" aria-label="Close"><ion-icon name="close-outline"></ion-icon></button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id="duplicateTemplateFormModal"></div>
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<button type="submit" onclick="$('#submitFormButton')[0].click()" class="oh-btn oh-btn--secondary oh-btn--shadow">{% trans "Save Duplicate" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function setModalLabel(label, modalTarget) {
|
||||
$(modalTarget).html(label)
|
||||
}
|
||||
</script>
|
||||
{% endblock content %}
|
||||
@@ -1,109 +0,0 @@
|
||||
{% extends 'index.html' %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
<style>
|
||||
.truncated-text {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.truncated-text::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 80%);
|
||||
pointer-events: none;
|
||||
/* Allow interaction with the text beneath the overlay */
|
||||
}
|
||||
</style>
|
||||
|
||||
<section class="oh-wrapper oh-main__topbar">
|
||||
<div class="oh-main__titlebar oh-main__titlebar--left oh-d-flex-column--resp oh-mb-3--small">
|
||||
<h1 class="oh-main__titlebar-title fw-bold">{% trans "Mail Templates" %}</h1>
|
||||
</div>
|
||||
{% if perms.recruitment.add_recruitmentmailtemplate %}
|
||||
<div class="oh-main__titlebar oh-main__titlebar--right oh-d-flex-column--resp oh-mb-3--small">
|
||||
<a href="#" data-toggle="oh-modal-toggle" data-target="#addTemplateModal" class="oh-btn oh-btn--secondary ml-2"><ion-icon name="add" class="mr-1 md hydrated" role="img" aria-label="add"></ion-icon>{% trans "Create" %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<div class="oh-wrapper oh-faq-cards">
|
||||
{% for template in templates %}
|
||||
<div class="oh-faq-card">
|
||||
{% if perms.recruitment.delete_recruitmentmailtemplate %}
|
||||
<h3 class="oh-faq-card__title d-flex justify-content-between "><span>{{ template.title }}</span>
|
||||
<div>
|
||||
<a hx-get="{% url 'duplicate-mail-template' template.id %}" hx-target="#duplicateTemplateFormModal" data-toggle="oh-modal-toggle"
|
||||
data-target="#duplicateTemplateModal" title="{% trans 'Duplicate' %}" style= "cursor: pointer;">
|
||||
<ion-icon name="copy-outline"></ion-icon>
|
||||
</a>
|
||||
<a href="{% url "delete-mail-template" %}?ids={{template.id}}" class="text-danger" style="cursor: pointer;"
|
||||
onclick="return confirm('Do you want to delete this template?')" title="{% trans 'Edit' %}" >
|
||||
<ion-icon name="trash-outline"></ion-icon>
|
||||
</a>
|
||||
</div>
|
||||
</h3>
|
||||
{% endif %}
|
||||
{% if perms.recruitment.change_recruitmentmailtemplate %}
|
||||
|
||||
{% endif %}
|
||||
<div class="oh-faq-card__desc" style="max-height: 500px; padding-top: 10px;">
|
||||
<div style="max-height: 350px;overflow: hidden;" class="truncated-text">{{ template.body|safe }}</div>
|
||||
</div>
|
||||
{% if perms.recruitment.change_recruitmentmailtemplate %}
|
||||
<a hx-get="{% url 'view-mail-template' template.id %}" hx-target="#viewTemplateModalBody" data-toggle="oh-modal-toggle" data-target="#viewTemplateModal" class="oh-btn oh-btn--secondary oh-btn--block">{% trans "View Template" %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="oh-modal" id="viewTemplateModal" role="dialog" aria-labelledby="viewTemplateModal" aria-hidden="true">
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<span class="oh-modal__dialog-title" id="viewTemplateModalLabel"></span>
|
||||
<button class="oh-modal__close" aria-label="Close"><ion-icon name="close-outline"></ion-icon></button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id="viewTemplateModalBody"></div>
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<button type="submit" onclick="$('#submitFormButton')[0].click()" class="oh-btn oh-btn--secondary oh-btn--shadow">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-modal" id="addTemplateModal" role="dialog" aria-labelledby="addTemplateModal" aria-hidden="true">
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<span class="oh-modal__dialog-title" id="addTemplateModalLabel">{% trans "Add Template" %}</span>
|
||||
<button class="oh-modal__close" aria-label="Close"><ion-icon name="close-outline"></ion-icon></button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id="addTemplateModalBody">
|
||||
{% include 'offerletter/htmx/form.html' %}
|
||||
</div>
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<button type="submit" onclick="$('#submitFormButton')[0].click()" class="oh-btn oh-btn--secondary oh-btn--shadow">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-modal" id="duplicateTemplateModal" role="dialog" aria-labelledby="duplicateTemplateModal" aria-hidden="true">
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<span class="oh-modal__dialog-title" id="duplicateTemplateModalLabel">{% trans "Duplicate Template" %}</span>
|
||||
<button class="oh-modal__close" aria-label="Close"><ion-icon name="close-outline"></ion-icon></button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id="duplicateTemplateFormModal"></div>
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<button type="submit" onclick="$('#submitFormButton')[0].click()" class="oh-btn oh-btn--secondary oh-btn--shadow">{% trans "Save Duplicate" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function setModalLabel(label, modalTarget) {
|
||||
$(modalTarget).html(label)
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user