[UPDT] ATTENDANCE: Updated hour account year field validation
This commit is contained in:
@@ -674,6 +674,15 @@ class AttendanceOverTime(models.Model):
|
||||
unique_together = [("employee_id"), ("month"), ("year")]
|
||||
ordering = ["-year", "-month_sequence"]
|
||||
|
||||
def clean(self):
|
||||
try:
|
||||
year = int(self.year)
|
||||
if not (1900 <= year <= 2100):
|
||||
raise ValidationError({"year": _("Year must be an integer value between 1900 and 2100")})
|
||||
except (ValueError, TypeError):
|
||||
raise ValidationError({"year": _("Year must be an integer value between 1900 and 2100")})
|
||||
|
||||
|
||||
def month_days(self):
|
||||
"""
|
||||
this method is used to create new AttendanceOvertime's instance if there
|
||||
|
||||
@@ -1,8 +1,28 @@
|
||||
{% load i18n %}
|
||||
<form id="add-form"
|
||||
hx-post="{% url 'attendance-overtime-create' %}" hx-target = "#addAttendanceOtModalBody"hx-target="#attendanceAddMessage" hx-swap = 'innerHTML' method='post'>
|
||||
{{form.as_p}}
|
||||
</div>
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h2 class="oh-modal__dialog-title" id="objectCreateModalLabel">
|
||||
{% trans "Hour Account" %}
|
||||
</h2>
|
||||
<button class="oh-modal__close" aria-label="Close">
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="oh-modal__dialog-body">
|
||||
<form
|
||||
id="add-form"
|
||||
hx-post="{% url 'attendance-overtime-create' %}"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
hx-swap="innerHTML"
|
||||
>
|
||||
{{form.as_p}}
|
||||
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<input type="submit" value='{% trans "Save" %}' class="oh-btn oh-btn--secondary oh-btn--shadow mt-4 pl-5 pr-5">
|
||||
</form>
|
||||
<input
|
||||
type="submit"
|
||||
value="{% trans 'Save' %}"
|
||||
class="oh-btn oh-btn--secondary oh-btn--shadow mt-4 pl-5 pr-5"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<div class="oh-sticky-table__td">
|
||||
<div class="oh-btn-group">
|
||||
{% if perms.recruitment.change_attendanceovertime or request.user|is_reportingmanager %}
|
||||
<a hx-get="{% url 'attendance-overtime-update' ot.id %}" hx-target='#updateAttendanceOTModalBody' data-toggle='oh-modal-toggle' data-target='#updateOtModal' class="oh-btn oh-btn--light-bkg w-50" title="{% trans 'Edit' %}"><ion-icon name="create-outline"></ion-icon></a>
|
||||
<a hx-get="{% url 'attendance-overtime-update' ot.id %}" hx-target='#objectUpdateModalTarget' data-toggle='oh-modal-toggle' data-target='#objectUpdateModal' class="oh-btn oh-btn--light-bkg w-50" title="{% trans 'Edit' %}"><ion-icon name="create-outline"></ion-icon></a>
|
||||
{% endif %}
|
||||
{% if perms.recruitment.delete_attendance %}
|
||||
{% comment %} <form action="{% url 'attendance-overtime-delete' ot.id %}?page={{accounts.number}}" method='post' class="w-50">
|
||||
@@ -195,30 +195,6 @@
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
{% if perms.attendance.change_attendanceovertime or request.user|is_reportingmanager %}
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="updateOtModal"
|
||||
role="dialog"
|
||||
aria-labelledby="updateOtModal"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h2 class="oh-modal__dialog-title" id="updateOtModalLabel">
|
||||
{% trans "Update Account" %}
|
||||
</h2>
|
||||
<button class="oh-modal__close" aria-label="Close" hx-get="{% url 'attendance-ot-search' %}?{{pd}}&page={{accounts.number}}" hx-target="#ot-table">
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
<div class="oh-modal__dialog-body p-0 pt-2" id='updateAttendanceOTModalBody'>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("#selectAllInstances").show();
|
||||
|
||||
@@ -2,27 +2,6 @@
|
||||
{% load i18n %}
|
||||
{% load basefilters %}
|
||||
{% if perms.attendance.add_attendanceovertime or request.user|is_reportingmanager %}
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="addAttendanceOtModal"
|
||||
role="dialog"
|
||||
aria-labelledby="addAttendanceOtModal"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h2 class="oh-modal__dialog-title" id="addAttendanceOtModalLabel">
|
||||
{% trans "Add OT" %}
|
||||
</h2>
|
||||
<button class="oh-modal__close" aria-label="Close" >
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id='addAttendanceOtModalBody'>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="hourAccountExport"
|
||||
@@ -208,9 +187,9 @@ aria-hidden="true"
|
||||
<div class="oh-dropdown" >
|
||||
<button class="oh-btn oh-btn--secondary"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#addAttendanceOtModal"
|
||||
data-target="#objectCreateModal"
|
||||
hx-get="{% url 'attendance-overtime-create' %}"
|
||||
hx-target="#addAttendanceOtModalBody"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
>
|
||||
<ion-icon name="add-sharp" class="mr-2"></ion-icon>
|
||||
{% trans "Create" %}
|
||||
|
||||
@@ -2,31 +2,6 @@
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load basefilters %}
|
||||
{% if perms.attendance.add_attendanceovertime or request.user|is_reportingmanager %}
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="addAttendanceOtModal"
|
||||
role="dialog"
|
||||
aria-labelledby="addAttendanceOtModal"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h2 class="oh-modal__dialog-title" id="addAttendanceOtModalLabel">
|
||||
{% trans "Add OT" %}
|
||||
</h2>
|
||||
<button class="oh-modal__close" aria-label="Close" >
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id='addAttendanceOtModalBody'>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<section class="oh-wrapper oh-main__topbar" x-data="{searchShow: false}">
|
||||
<div class="oh-main__titlebar oh-main__titlebar--left">
|
||||
<h1 class="oh-main__titlebar-title fw-bold">{% trans "Hour Account" %}</h1>
|
||||
@@ -40,9 +15,9 @@ aria-hidden="true"
|
||||
<div class="oh-dropdown" >
|
||||
<button class="oh-btn oh-btn--secondary"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#addAttendanceOtModal"
|
||||
data-target="#objectCreateModal"
|
||||
hx-get="{% url 'attendance-overtime-create' %}"
|
||||
hx-target="#addAttendanceOtModalBody"
|
||||
hx-target="#objectCreateModalTarget"
|
||||
>
|
||||
<ion-icon name="add-sharp" class="mr-2"></ion-icon>
|
||||
{% trans "Create" %}
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<div class="oh-sticky-table__td oh-sticky-table__right" onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group">
|
||||
{% if perms.attendance.change_attendanceovertime or request.user|is_reportingmanager %}
|
||||
<a hx-get="{% url 'attendance-overtime-update' ot.id %}" hx-target='#updateAttendanceOTModalBody' data-toggle='oh-modal-toggle' data-target='#updateOtModal' class="oh-btn oh-btn--light-bkg w-50" title="{% trans 'Edit' %}"><ion-icon name="create-outline"></ion-icon></a>
|
||||
<a hx-get="{% url 'attendance-overtime-update' ot.id %}" hx-target='#objectUpdateModalTarget' data-toggle='oh-modal-toggle' data-target='#objectUpdateModal' class="oh-btn oh-btn--light-bkg w-50" title="{% trans 'Edit' %}"><ion-icon name="create-outline"></ion-icon></a>
|
||||
{% endif %}
|
||||
{% if perms.attendance.delete_attendanceovertime or request.user|is_reportingmanager %}
|
||||
<form action="{% url 'attendance-overtime-delete' ot.id %}"
|
||||
@@ -149,28 +149,6 @@
|
||||
<!-- end of empty page -->
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if perms.attendance.change_attendanceovertime or request.user|is_reportingmanager %}
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="updateOtModal"
|
||||
role="dialog"
|
||||
aria-labelledby="updateOtModal"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h2 class="oh-modal__dialog-title" id="updateOtModalLabel">
|
||||
{% trans "Update Account" %}
|
||||
</h2>
|
||||
<button class="oh-modal__close" aria-label="Close" >
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
<div class="oh-modal__dialog-body p-0 pt-2" id='updateAttendanceOTModalBody'></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,27 @@
|
||||
{% load i18n %}
|
||||
<form
|
||||
id="update-form"
|
||||
hx-post="{% url 'attendance-overtime-update' form.instance.id %}"
|
||||
id="update-form"
|
||||
hx-target = "#updateAttendanceOTModalBody"
|
||||
hx-target="#attendanceAddMessage"
|
||||
hx-swap = 'innerHTML' >
|
||||
{{form.as_p}}
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<input type="submit" value="{% trans 'Save' %}" class="oh-btn oh-btn--secondary oh-btn--shadow mt-4 pl-5 pr-5">
|
||||
</div>
|
||||
</form>
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h2 class="oh-modal__dialog-title" id="objectCreateModalLabel">
|
||||
{% trans "Hour Account" %}
|
||||
</h2>
|
||||
<button class="oh-modal__close" aria-label="Close">
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body">
|
||||
<form
|
||||
id="update-form"
|
||||
hx-post="{% url 'attendance-overtime-update' form.instance.id %}"
|
||||
id="update-form"
|
||||
hx-target="#objectUpdateModalTarget"
|
||||
hx-swap="innerHTML"
|
||||
>
|
||||
{{form.as_p}}
|
||||
<div class="oh-modal__dialog-footer">
|
||||
<input
|
||||
type="submit"
|
||||
value="{% trans 'Save' %}"
|
||||
class="oh-btn oh-btn--secondary oh-btn--shadow mt-4 pl-5 pr-5"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -703,6 +703,15 @@
|
||||
>
|
||||
<div class="oh-modal__dialog" id="objectCreateModalTarget"></div>
|
||||
</div>
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="objectUpdateModal"
|
||||
role="dialog"
|
||||
aria-labelledby="objectUpdateModalLabel"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog" id="objectUpdateModalTarget"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user