[UPDT] HORILLA: Permission updations in views
This commit is contained in:
@@ -46,7 +46,7 @@ class CompanyleaveListView(HorillaListView):
|
||||
self.search_url = reverse("company-leave-filter")
|
||||
self.view_id = "companyleavedelete"
|
||||
|
||||
if self.request.user.has_perm("base.view_companyleave"):
|
||||
if self.request.user.has_perm("base.view_companyleaves"):
|
||||
self.action_method = "company_leave_actions"
|
||||
|
||||
if self.request.user.has_perm("base.view_company"):
|
||||
@@ -84,7 +84,7 @@ class CompanyLeaveNavView(HorillaNavView):
|
||||
def __init__(self, **kwargs: Any) -> None:
|
||||
super().__init__(**kwargs)
|
||||
self.search_url = reverse("company-leave-filter")
|
||||
if self.request.user.has_perm("base.add_companyleave"):
|
||||
if self.request.user.has_perm("base.add_companyleaves"):
|
||||
self.create_attrs = f"""
|
||||
hx-get="{reverse_lazy('company-leave-creation')}"
|
||||
hx-target="#genericModalBody"
|
||||
@@ -117,7 +117,6 @@ class CompanyLeaveDetailView(HorillaDetailedView):
|
||||
|
||||
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
@method_decorator(permission_required("base.add_companyleave"), name="dispatch")
|
||||
class CompanyleaveFormView(HorillaFormView):
|
||||
"""
|
||||
form view for create button
|
||||
|
||||
@@ -47,7 +47,9 @@ class HolidayListView(HorillaListView):
|
||||
super().__init__(**kwargs)
|
||||
self.search_url = reverse("holiday-filter")
|
||||
self.view_id = "holidaydelete"
|
||||
if self.request.user.has_perm("base.add_holiday"):
|
||||
if self.request.user.has_perm(
|
||||
"base.change_holidays"
|
||||
) or self.request.user.has_perm("base.delete_holidays"):
|
||||
self.action_method = "holidays_actions"
|
||||
|
||||
columns = [
|
||||
@@ -84,7 +86,7 @@ class HolidayNavView(HorillaNavView):
|
||||
def __init__(self, **kwargs: Any) -> None:
|
||||
super().__init__(**kwargs)
|
||||
self.search_url = reverse("holiday-filter")
|
||||
if self.request.user.has_perm("base.add_holiday"):
|
||||
if self.request.user.has_perm("base.add_holidays"):
|
||||
self.create_attrs = f"""
|
||||
hx-get="{reverse_lazy('holiday-creation')}"
|
||||
hx-target="#genericModalBody"
|
||||
@@ -172,7 +174,6 @@ class HolidayExport(TemplateView):
|
||||
|
||||
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
@method_decorator(permission_required("leave.add_holidays"), name="dispatch")
|
||||
class HolidayFormView(HorillaFormView):
|
||||
"""
|
||||
form view for create button
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{% load i18n static %}
|
||||
{% if perms.leave.change_companyleave or perms.leave.delete_companyleave %}
|
||||
{% if perms.base.change_companyleaves or perms.base.delete_companyleaves %}
|
||||
<div onclick="event.stopPropagation();" class="oh-btn-group">
|
||||
{% if perms.leave.change_companyleave %}
|
||||
{% if perms.base.change_companyleaves %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#genericModal" hx-get="{% url 'company-leave-update' instance.id %}?instance_ids={{instance.ordered_ids}}"
|
||||
hx-target="#genericModalBody"><ion-icon name="create-outline"></ion-icon></button>
|
||||
{% endif %}
|
||||
{% if perms.leave.delete_companyleave %}
|
||||
{% if perms.base.delete_companyleaves %}
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
|
||||
hx-confirm="{% trans 'Are you sure you want to delete ?' %}"
|
||||
hx-post="{% url 'company-leave-delete' instance.id %}"
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
{% load basefilters i18n %}
|
||||
|
||||
<div class="oh-btn-group">
|
||||
{% if perms.leave.change_companyleave or perms.leave.delete_companyleave %}
|
||||
{% if perms.leave.change_companyleave %}
|
||||
{% if perms.base.change_companyleaves or perms.base.delete_companyleaves %}
|
||||
{% if perms.base.change_companyleaves %}
|
||||
<a
|
||||
hx-get="{% url 'company-leave-update' instance.id %}"
|
||||
hx-target="#genericModalBody"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#genericModal"
|
||||
class="oh-btn oh-btn--info w-50"
|
||||
class="oh-btn oh-btn--info w-100"
|
||||
>
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
{% trans 'Edit' %}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if perms.leave.delete_companyleave %}
|
||||
{% if perms.base.delete_companyleaves %}
|
||||
<a
|
||||
hx-post="{% url 'company-leave-delete' instance.id %}"
|
||||
hx-target="#listContainer"
|
||||
hx-confirm="{% trans 'Are you sure you want to delete ?' %}"
|
||||
class="oh-btn oh-btn--secondary w-50"
|
||||
class="oh-btn oh-btn--secondary w-100"
|
||||
>
|
||||
<ion-icon
|
||||
name="trash-outline"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% load basefilters i18n %}
|
||||
|
||||
<div class="oh-btn-group w-100">
|
||||
{% if perms.leave.change_holiday %}
|
||||
{% if perms.base.change_holidays %}
|
||||
<a
|
||||
hx-get="{% url 'holiday-update' instance.id %}?{{pd}}"
|
||||
hx-target="#genericModalBody"
|
||||
@@ -14,7 +14,7 @@
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if perms.leave.delete_holiday %}
|
||||
{% if perms.base.delete_holidays %}
|
||||
<a
|
||||
hx-post="{% url 'holiday-delete' instance.id %}"
|
||||
hx-target="#holidaydelete"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% load i18n %}
|
||||
<div onclick="event.stopPropagation();" class="oh-btn-group">
|
||||
{% if perms.leave.change_holiday %}
|
||||
{% if perms.base.change_holidays %}
|
||||
<button
|
||||
class="oh-btn oh-btn--light-bkg w-100"
|
||||
title="{% trans 'Edit' %}"
|
||||
@@ -11,8 +11,6 @@
|
||||
>
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if perms.leave.change_holiday %}
|
||||
<button
|
||||
class="oh-btn oh-btn--light-bkg w-100"
|
||||
title="{% trans 'Duplicate' %}"
|
||||
@@ -24,7 +22,7 @@
|
||||
<ion-icon name="copy-outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if perms.leave.delete_holiday %}
|
||||
{% if perms.base.delete_holidays %}
|
||||
<a
|
||||
class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
|
||||
id="delete-link"
|
||||
|
||||
Reference in New Issue
Block a user