From 0fb5068b4a61370e473f167dd3c4ebec670a63d8 Mon Sep 17 00:00:00 2001 From: elias-boulharts Date: Mon, 18 Sep 2023 12:03:24 +0200 Subject: [PATCH] hide button without permission --- templates/generics/buttons/add_button.html | 6 ++-- .../generics/buttons/bulk_delete_button.html | 8 +++-- templates/generics/buttons/delete_button.html | 12 +++---- templates/generics/buttons/edit_button.html | 6 ++-- .../custom_columns/generic_delete.html | 31 +++++++++---------- .../generics/custom_columns/generic_edit.html | 30 +++++++++--------- .../custom_columns/delete_all_user_roles.html | 6 ++-- ..._permission_default_permission_detail.html | 10 +++--- .../globalpermission_rbac_detail.html | 8 +++-- templates/profiles/organization_detail.html | 19 ++++++------ templates/profiles/team_detail.html | 22 ++++++------- .../buttons/delete_operation_button.html | 12 +++---- .../buttons/edit_operation_button.html | 12 +++---- .../buttons/instance_buttons.html | 22 +++++++------ .../buttons/operation_survey_button.html | 12 +++---- .../common/instance-support-details.html | 9 +++--- .../create_operation_request.html | 13 ++++---- .../custom_columns/operation_actions.html | 12 +++---- .../request_details/approval.html | 24 ++++++++------ 19 files changed, 141 insertions(+), 133 deletions(-) diff --git a/templates/generics/buttons/add_button.html b/templates/generics/buttons/add_button.html index 171c7f570..25eb1b3be 100644 --- a/templates/generics/buttons/add_button.html +++ b/templates/generics/buttons/add_button.html @@ -1,8 +1,8 @@ {% with perm=django_content_type.app_label|add:".add_"|add:django_content_type.model %} {% has_perm request.user perm as can_add %} - - + {% if can_add %} + Add - + {% endif %} {% endwith %} diff --git a/templates/generics/buttons/bulk_delete_button.html b/templates/generics/buttons/bulk_delete_button.html index c3627d551..947148d7d 100644 --- a/templates/generics/buttons/bulk_delete_button.html +++ b/templates/generics/buttons/bulk_delete_button.html @@ -1,4 +1,6 @@ {% has_perm request.user django_content_type.app_label|add:".delete_"|add:django_content_type.model as can_delete %} - +{% if can_delete %} + + Delete + +{% endif %} \ No newline at end of file diff --git a/templates/generics/buttons/delete_button.html b/templates/generics/buttons/delete_button.html index 3bbf0b6e3..0f0841b1d 100644 --- a/templates/generics/buttons/delete_button.html +++ b/templates/generics/buttons/delete_button.html @@ -2,12 +2,12 @@ {% with class=object|to_class_name|lower %} {% with perm=app|add:".delete_"|add:class %} {% has_perm request.user perm object as can_delete %} - - - - - + {% if can_delete %} + + + + {% endif %} {% endwith %} {% endwith %} {% endwith %} diff --git a/templates/generics/buttons/edit_button.html b/templates/generics/buttons/edit_button.html index 830dce05a..2181e203d 100644 --- a/templates/generics/buttons/edit_button.html +++ b/templates/generics/buttons/edit_button.html @@ -2,12 +2,12 @@ {% with class=object|to_class_name|lower %} {% with perm=app|add:".change_"|add:class %} {% has_perm request.user perm object as can_change %} - + {% if can_change %} + class="btn btn-primary"> - + {% endif %} {% endwith %} {% endwith %} {% endwith %} diff --git a/templates/generics/custom_columns/generic_delete.html b/templates/generics/custom_columns/generic_delete.html index 808c36f7a..5591f8f24 100644 --- a/templates/generics/custom_columns/generic_delete.html +++ b/templates/generics/custom_columns/generic_delete.html @@ -2,23 +2,20 @@ {% with class=record|to_class_name|lower %} {% with perm=app|add:".delete_"|add:class %} {% has_perm request.user perm as can_delete %} - {% if parent_id %} - - - - - - - {% else %} - - - - - + {% if can_delete %} + {% if parent_id %} + + + + {% else %} + + + + {% endif %} {% endif %} {% endwith %} {% endwith %} diff --git a/templates/generics/custom_columns/generic_edit.html b/templates/generics/custom_columns/generic_edit.html index 6a25db856..e10c46bfe 100644 --- a/templates/generics/custom_columns/generic_edit.html +++ b/templates/generics/custom_columns/generic_edit.html @@ -2,23 +2,21 @@ {% with class=record|to_class_name|lower %} {% with perm=app|add:".change_"|add:class %} {% has_perm request.user perm as can_change %} - {% if parent_id %} - + {% if can_change %} + {% if parent_id %} - - - - - {% else %} - - - - - + + + + {% else %} + + + + {% endif %} {% endif %} {% endwith %} {% endwith %} diff --git a/templates/profiles/custom_columns/delete_all_user_roles.html b/templates/profiles/custom_columns/delete_all_user_roles.html index 6894cb8a9..232bcb2bc 100644 --- a/templates/profiles/custom_columns/delete_all_user_roles.html +++ b/templates/profiles/custom_columns/delete_all_user_roles.html @@ -1,10 +1,10 @@ {# can_delete_user come from {organization,team,globalpermission}_detail.html#} {% with class_name=object|to_class_name|lower %} - + {% if can_delete_user %} - + {% endif %} {% endwith %} diff --git a/templates/profiles/global_permission_default_permission_detail.html b/templates/profiles/global_permission_default_permission_detail.html index e38fe8a58..3c4d626b5 100644 --- a/templates/profiles/global_permission_default_permission_detail.html +++ b/templates/profiles/global_permission_default_permission_detail.html @@ -6,10 +6,12 @@ {% load static %} {% block header_button %} {% has_perm request.user "profiles.change_globalpermission" object as can_change_global_perm %} - - - + {% if can_change_global_perm %} + + + + {% endif %} {% endblock %} {% block main %} diff --git a/templates/profiles/globalpermission_rbac_detail.html b/templates/profiles/globalpermission_rbac_detail.html index 16389cb03..f19ade3a2 100644 --- a/templates/profiles/globalpermission_rbac_detail.html +++ b/templates/profiles/globalpermission_rbac_detail.html @@ -6,9 +6,11 @@ {% load static %} {% block extra_header_button %} {% has_perm request.user "profiles.add_users_globalpermission" object as can_add_users %} - Add Global RBAC - + {% if can_add_users %} + Add Global RBAC + + {% endif %} {% endblock %} {% block main %} diff --git a/templates/profiles/organization_detail.html b/templates/profiles/organization_detail.html index 31a34185a..acc5418ce 100644 --- a/templates/profiles/organization_detail.html +++ b/templates/profiles/organization_detail.html @@ -9,26 +9,27 @@ {% has_perm request.user "profiles.add_users_organization" object as can_add_user_in_organization %} {% has_perm request.user "profiles.add_team" object as can_add_team %} {% has_perm request.user "profiles.change_organization_quota" object as can_change_quota %} - + {% if can_change_quota %} + class="btn btn-primary"> Set quotas - + {% endif %} - + {% if can_add_user_in_organization %} + class="btn btn-success"> Add Organization RBAC - + {% endif %} - + {% if can_add_team %} + class="btn btn-success"> Add team - + {% endif %} + {% endblock %} {% block header_button %} diff --git a/templates/profiles/team_detail.html b/templates/profiles/team_detail.html index d15657d2f..dd76328bf 100644 --- a/templates/profiles/team_detail.html +++ b/templates/profiles/team_detail.html @@ -7,17 +7,17 @@ {% block extra_header_button %} {% has_perm request.user "profiles.add_users_team" object as can_add_user %} {% has_perm request.user "profiles.change_team_quota" object as can_change_quota %} - - Set quotas - - - - Add Team RBAC - - + {% if can_change_quota %} + Set quotas + + {% endif %} + {% if can_add_user %} + Add Team RBAC + + {% endif %} {% endblock %} {% block header_button %} {% include 'generics/buttons/edit_button.html' %} diff --git a/templates/service_catalog/buttons/delete_operation_button.html b/templates/service_catalog/buttons/delete_operation_button.html index e2be568ce..54ecf1b04 100644 --- a/templates/service_catalog/buttons/delete_operation_button.html +++ b/templates/service_catalog/buttons/delete_operation_button.html @@ -1,9 +1,9 @@ {% with perm="service_catalog.delete_operation" %} {% has_perm request.user perm object as can_delete %} - - - - - + {% if can_delete %} + + + + {% endif %} {% endwith %} diff --git a/templates/service_catalog/buttons/edit_operation_button.html b/templates/service_catalog/buttons/edit_operation_button.html index 85555908d..0a3ea646c 100644 --- a/templates/service_catalog/buttons/edit_operation_button.html +++ b/templates/service_catalog/buttons/edit_operation_button.html @@ -1,9 +1,9 @@ {% with perm="service_catalog.change_operation" %} {% has_perm request.user perm object as can_change %} - - - - - + {% if can_change %} + + + + {% endif %} {% endwith %} diff --git a/templates/service_catalog/buttons/instance_buttons.html b/templates/service_catalog/buttons/instance_buttons.html index 10a2f0c03..e87a252d1 100644 --- a/templates/service_catalog/buttons/instance_buttons.html +++ b/templates/service_catalog/buttons/instance_buttons.html @@ -19,14 +19,16 @@ {% endif %} {% endwith %} -{% if object.service.external_support_url is not None and object.service.external_support_url != '' %} - - Open new support - -{% else %} - - Open new support - +{% if can_add_support %} + {% if object.service.external_support_url is not None and object.service.external_support_url != '' %} + + Open new support + + {% else %} + + Open new support + + {% endif %} {% endif %} \ No newline at end of file diff --git a/templates/service_catalog/buttons/operation_survey_button.html b/templates/service_catalog/buttons/operation_survey_button.html index 168afc755..bfbd381c0 100644 --- a/templates/service_catalog/buttons/operation_survey_button.html +++ b/templates/service_catalog/buttons/operation_survey_button.html @@ -1,7 +1,7 @@ {% has_perm request.user "service_catalog.change_operation" as can_change %} - - - Survey - - +{% if can_change %} + + Survey + +{% endif %} diff --git a/templates/service_catalog/common/instance-support-details.html b/templates/service_catalog/common/instance-support-details.html index 84880b85b..8a96ab6cd 100644 --- a/templates/service_catalog/common/instance-support-details.html +++ b/templates/service_catalog/common/instance-support-details.html @@ -5,6 +5,7 @@ {% load static %} {% block content %} {% has_perm request.user "service_catalog.add_supportmessage" instance as can_comment_support %} + {% has_perm request.user "service_catalog.reopen_support" instance as can_reopen_support %} {% has_perm request.user "service_catalog.close_support" instance as can_close_support %} {% has_perm request.user "service_catalog.change_support" instance as can_change_support %} @@ -69,15 +70,15 @@ {% endif %} - {% if support.get_state_display == "OPENED" %} + {% if support.get_state_display == "OPENED" and can_close_support %} + class="btn btn-danger"> Close {% endif %} - {% if support.get_state_display == "CLOSED" %} + {% if support.get_state_display == "CLOSED" and can_reopen_support %} + class="btn btn-success"> Re-open {% endif %} diff --git a/templates/service_catalog/custom_columns/create_operation_request.html b/templates/service_catalog/custom_columns/create_operation_request.html index 4266da0f6..ffc8da040 100644 --- a/templates/service_catalog/custom_columns/create_operation_request.html +++ b/templates/service_catalog/custom_columns/create_operation_request.html @@ -3,10 +3,9 @@ {% else %} {% has_perm request.user "service_catalog.request_on_service" as can_request_operation %} {% endif %} - - - - - - +{% if can_request_operation %} + + + +{% endif %} diff --git a/templates/service_catalog/custom_columns/operation_actions.html b/templates/service_catalog/custom_columns/operation_actions.html index c3087612c..400d9703a 100644 --- a/templates/service_catalog/custom_columns/operation_actions.html +++ b/templates/service_catalog/custom_columns/operation_actions.html @@ -1,10 +1,10 @@ {% has_perm request.user "service_catalog.change_operation" as can_change %} - - - - - +{% if can_change %} + + + +{% endif %} {% with parent_id=record.service.id %} {% include 'generics/custom_columns/generic_actions.html' %} {% endwith %} diff --git a/templates/service_catalog/request_details/approval.html b/templates/service_catalog/request_details/approval.html index 9b59edbc6..4da8266fc 100644 --- a/templates/service_catalog/request_details/approval.html +++ b/templates/service_catalog/request_details/approval.html @@ -244,11 +244,13 @@

Process the request

@@ -295,11 +297,13 @@

Processing failed