[UPDT] BASE: Exception handling in rotating work type assign archive method and trans tag updates
This commit is contained in:
@@ -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 %}
|
||||
|
||||
@@ -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", "/"))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user