diff --git a/horilla/decorators.py b/horilla/decorators.py index 2145330c9..c3b9970a2 100755 --- a/horilla/decorators.py +++ b/horilla/decorators.py @@ -274,10 +274,14 @@ def owner_can_enter(function, perm: str, model: object, manager_access=False): def _function(request, *args, **kwargs): instance_id = kwargs[list(kwargs.keys())[0]] if model == Employee: - employee = Employee.objects.get(id=instance_id) + employee = Employee.objects.filter(id=instance_id).first() else: try: - employee = model.objects.get(id=instance_id).employee_id + employee = ( + model.objects.filter(id=instance_id).first().employee_id + if model.objects.filter(id=instance_id).first() + else None + ) except: messages.error(request, ("Sorry, something went wrong!")) return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/")) @@ -293,7 +297,7 @@ def owner_can_enter(function, perm: str, model: object, manager_access=False): else False ) ) - if can_enter: + if can_enter or not employee: return function(request, *args, **kwargs) return render(request, "no_perm.html") diff --git a/horilla/methods.py b/horilla/methods.py index 5c61e0c5e..ea291e292 100644 --- a/horilla/methods.py +++ b/horilla/methods.py @@ -71,3 +71,10 @@ def horilla_users_with_perms(permissions): ) return users_with_permissions.distinct() + + +def get_urlencode(request): + get_data = request.GET.copy() + get_data.pop("instances_ids", None) + previous_data = get_data.urlencode() + return previous_data diff --git a/payroll/templates/payroll/allowance/card_allowance.html b/payroll/templates/payroll/allowance/card_allowance.html index 6e56e3cbb..f4e1e8100 100644 --- a/payroll/templates/payroll/allowance/card_allowance.html +++ b/payroll/templates/payroll/allowance/card_allowance.html @@ -15,7 +15,7 @@
diff --git a/payroll/templates/payroll/allowance/view_single_allowance.html b/payroll/templates/payroll/allowance/view_single_allowance.html
index 5b13e938c..9fcf59e7e 100644
--- a/payroll/templates/payroll/allowance/view_single_allowance.html
+++ b/payroll/templates/payroll/allowance/view_single_allowance.html
@@ -1,17 +1,37 @@
-{% load i18n %} {% load yes_no %}
-{% if request.GET.instances_ids %}
-
+{% load i18n %} {% load yes_no %} {% load static %}
+{% if messages %}
+
+
+