diff --git a/Squest/utils/squest_views.py b/Squest/utils/squest_views.py index 51c12c0dc..a89126f20 100644 --- a/Squest/utils/squest_views.py +++ b/Squest/utils/squest_views.py @@ -57,6 +57,8 @@ class SquestListView(LoginRequiredMixin, SquestPermissionRequiredMixin, SquestEx table_pagination = {'per_page': 10} template_name = 'generics/list.html' no_data_message = "There is no data to show or you don't have required permission" + ordering = None + def get_permission_required(self): return f"{self.django_content_type.app_label}.list_{self.django_content_type.model}" @@ -80,6 +82,8 @@ def get_queryset(self): except AttributeError as e: traceback.print_exc() qs = self.model.objects.all() + if self.ordering is not None: + qs = qs.order_by(self.ordering) return qs diff --git a/profiles/views/organization.py b/profiles/views/organization.py index 7acd10061..f72a79b4d 100644 --- a/profiles/views/organization.py +++ b/profiles/views/organization.py @@ -2,7 +2,7 @@ from profiles.filters import OrganizationFilter from profiles.filters.user_filter import UserFilter from profiles.forms import OrganizationForm -from profiles.models import Organization, Team, Role, Quota +from profiles.models import Organization, Team from profiles.tables import OrganizationTable, ScopeRoleTable, TeamTable, UserRoleTable from profiles.tables.quota_table import QuotaTable diff --git a/profiles/views/quota.py b/profiles/views/quota.py index 7f56ebfbc..0ef780e60 100644 --- a/profiles/views/quota.py +++ b/profiles/views/quota.py @@ -17,7 +17,7 @@ class QuotaListView(SquestListView): model = Quota filterset_class = QuotaFilter table_class = QuotaTable - ordering = 'name' + ordering = 'attribute_definition__name' no_data_message = 'To create quota, go to organization/team and click on "Set quotas"' export_csv = True diff --git a/service_catalog/tables/instance_tables.py b/service_catalog/tables/instance_tables.py index 5119e1d38..3fdbd905e 100644 --- a/service_catalog/tables/instance_tables.py +++ b/service_catalog/tables/instance_tables.py @@ -1,6 +1,6 @@ from django.utils.html import format_html -from django_tables2 import TemplateColumn, LinkColumn, CheckBoxColumn +from django_tables2 import TemplateColumn, LinkColumn, CheckBoxColumn, Column from django_tables2.utils import A from Squest.utils.squest_table import SquestTable @@ -9,7 +9,10 @@ class InstanceTable(SquestTable): selection = CheckBoxColumn(accessor='pk', attrs={"th__input": {"onclick": "toggle(this)"}}) + quota_scope__name = Column(verbose_name='Quota scope') name = LinkColumn() + date_available = TemplateColumn(template_name='generics/custom_columns/generic_date_format.html') + last_updated = TemplateColumn(template_name='generics/custom_columns/generic_date_format.html') def before_render(self, request): if not request.user.has_perm("service_catalog.delete_instance"): diff --git a/service_catalog/views/filters.py b/service_catalog/views/filters.py index 1dcefe772..750dde751 100644 --- a/service_catalog/views/filters.py +++ b/service_catalog/views/filters.py @@ -179,6 +179,8 @@ def addstr(arg1, arg2): @register.filter(name="squest_date_format") def squest_date_format(date_to_format): + if date_to_format is None: + return date_to_format return date_to_format.astimezone().strftime(settings.DATE_FORMAT) 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 @@