[UPDT] BASE: Exception handling in rotating work type assign archive method and trans tag updates

This commit is contained in:
Horilla
2024-02-29 18:31:29 +05:30
parent 3803de1f71
commit 897a7e8cc8
2 changed files with 25 additions and 21 deletions

View File

@@ -75,7 +75,7 @@ style="cursor: pointer; display: none;"
>{% trans "Requested Till" %}</div>
<div data-cell-index="5" data-cell-title='{% trans "Description" %}' class="oh-sticky-table__th">{% trans "Description" %}</div>
<div class="oh-sticky-table__th" style="width:115px;">{% trans "Comment" %}</div>
<div class="oh-sticky-table__th">{% trans "Actions" %}</div>
<div class="oh-sticky-table__th" style="width: 190px;">{% trans "Actions" %}</div>
{% if perms.base.change_worktyperequest or request.user|is_reportingmanager %}
<div class="oh-sticky-table__th" style="width:180px">{% trans "Confirmation" %}</div>
{% endif %}

View File

@@ -1477,27 +1477,31 @@ def rotating_work_type_assign_archive(request, id):
"""
This method is used to archive or un-archive rotating work type assigns
"""
rwork_type = RotatingWorkTypeAssign.objects.get(id=id)
employees_rwork_types = RotatingWorkTypeAssign.objects.filter(
is_active=True, employee_id=rwork_type.employee_id
)
flag = False
if len(employees_rwork_types) < 1:
rwork_type.is_active = True
flag = True
message = _("un-archived")
if request.GET.get("is_active") == "False":
rwork_type.is_active = False
message = _("archived")
flag = True
rwork_type.save()
if flag:
messages.success(
request, _("Rotating shift assign is {message}").format(message=message)
try:
rwork_type = RotatingWorkTypeAssign.objects.get(id=id)
employees_rwork_types = RotatingWorkTypeAssign.objects.filter(
is_active=True, employee_id=rwork_type.employee_id
)
else:
messages.error(request, "Already on record is active")
flag = False
if len(employees_rwork_types) < 1:
rwork_type.is_active = True
flag = True
message = _("un-archived")
if request.GET.get("is_active") == "False":
rwork_type.is_active = False
message = _("archived")
flag = True
rwork_type.save()
if flag:
messages.success(
request, _("Rotating shift assign is {message}").format(message=message)
)
else:
messages.error(request, "Already on record is active")
except RotatingWorkTypeAssign.DoesNotExist:
messages.error(request, _("Rotating work type assign not found."))
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))