Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qa elias #671

Merged
merged 4 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Squest/utils/squest_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion profiles/views/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion profiles/views/quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion service_catalog/tables/instance_tables.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"):
Expand Down
2 changes: 2 additions & 0 deletions service_catalog/views/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
6 changes: 3 additions & 3 deletions templates/generics/buttons/add_button.html
Original file line number Diff line number Diff line change
@@ -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 %}
<span {% if not can_change %} title="Permission {{ perm }} needed" {% endif %}>
<a class="btn btn-success {% if not can_add %} disabled{% endif %}" href="{{ add_url }}">
{% if can_add %}
<a class="btn btn-success" href="{{ add_url }}">
<i class="fas fa-plus"></i> Add
</a>
</span>
{% endif %}
{% endwith %}
8 changes: 5 additions & 3 deletions templates/generics/buttons/bulk_delete_button.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% has_perm request.user django_content_type.app_label|add:".delete_"|add:django_content_type.model as can_delete %}
<button class="btn btn-danger{% if not can_delete %} disabled{% endif %}" type="submit"{% if not can_delete %} disabled{% endif %}>
<i class="fas fa-trash"></i> Delete
</button>
{% if can_delete %}
<a class="btn btn-danger" type="submit">
<i class="fas fa-trash"></i> Delete
</a>
{% endif %}
12 changes: 6 additions & 6 deletions templates/generics/buttons/delete_button.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<span {% if not can_change %} title="Permission {{ perm }} needed" {% endif %}>
<a href="{% url app|add:':'|add:class|add:'_delete' object.id %}"
class="btn btn-danger{% if not can_delete %} disabled{% endif %}">
<i class="fas fa-trash"></i>
</a>
</span>
{% if can_delete %}
<a href="{% url app|add:':'|add:class|add:'_delete' object.id %}"
class="btn btn-danger">
<i class="fas fa-trash"></i>
</a>
{% endif %}
{% endwith %}
{% endwith %}
{% endwith %}
6 changes: 3 additions & 3 deletions templates/generics/buttons/edit_button.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<span {% if not can_change %} title="Permission {{ perm }} needed" {% endif %}>
{% if can_change %}
<a href="{% url app|add:':'|add:class|add:'_edit' object.id %}"
class="btn btn-primary{% if not can_change %} disabled{% endif %}">
class="btn btn-primary">
<i class="fas fa-pencil-alt"></i>
</a>
</span>
{% endif %}
{% endwith %}
{% endwith %}
{% endwith %}
31 changes: 14 additions & 17 deletions templates/generics/custom_columns/generic_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<span {% if not can_delete %} title="Permission {{ perm }} needed" {% endif %}>

<a href="{% url app|add:":"|add:class|add:"_delete" parent_id record.id %}"
class="btn btn-danger bg-sm{% if not can_delete %} disabled{% endif %}"
title="Delete">
<i class="fas fa-trash"></i>
</a>
</span>
{% else %}
<span {% if not can_delete %} title="Permission {{ perm }} needed" {% endif %}>
<a href="{% url app|add:":"|add:class|add:"_delete" record.id %}"
class="btn btn-danger bg-sm{% if not can_delete %} disabled{% endif %}"
title="Delete">
<i class="fas fa-trash"></i>
</a>
</span>
{% if can_delete %}
{% if parent_id %}
<a href="{% url app|add:":"|add:class|add:"_delete" parent_id record.id %}"
class="btn btn-danger bg-sm"
title="Delete">
<i class="fas fa-trash"></i>
</a>
{% else %}
<a href="{% url app|add:":"|add:class|add:"_delete" record.id %}"
class="btn btn-danger bg-sm"
title="Delete">
<i class="fas fa-trash"></i>
</a>
{% endif %}
{% endif %}
{% endwith %}
{% endwith %}
Expand Down
30 changes: 14 additions & 16 deletions templates/generics/custom_columns/generic_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<span {% if not can_change %} title="Permission {{ perm }} needed" {% endif %}>
{% if can_change %}
{% if parent_id %}

<a href="{% url app|add:":"|add:class|add:"_edit" parent_id record.id %}"
class="btn btn-primary bg-sm{% if not can_change %} disabled{% endif %}"
title="Edit">
<i class="fas fa-pencil-alt"></i>
</a>
</span>
{% else %}
<span {% if not can_change %} title="Permission {{ perm }} needed" {% endif %}>
<a href="{% url app|add:":"|add:class|add:"_edit" record.id %}"
class="btn btn-primary bg-sm{% if not can_change %} disabled{% endif %}"
title="Edit">
<i class="fas fa-pencil-alt"></i>
</a>
</span>
<a href="{% url app|add:":"|add:class|add:"_edit" parent_id record.id %}"
class="btn btn-primary bg-sm"
title="Edit">
<i class="fas fa-pencil-alt"></i>
</a>
{% else %}
<a href="{% url app|add:":"|add:class|add:"_edit" record.id %}"
class="btn btn-primary bg-sm"
title="Edit">
<i class="fas fa-pencil-alt"></i>
</a>
{% endif %}
{% endif %}
{% endwith %}
{% endwith %}
Expand Down
6 changes: 3 additions & 3 deletions templates/profiles/custom_columns/delete_all_user_roles.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{# can_delete_user come from {organization,team,globalpermission}_detail.html#}
{% with class_name=object|to_class_name|lower %}
<span {% if not can_delete_user %} title="Permission 'profiles.delete_role' needed" {% endif %}>
{% if can_delete_user %}
<a href="{% url "profiles:"|add:class_name|add:"_rbac_delete" object.id record.id %}"
class="btn btn-danger bg-sm{% if not can_delete_user %} disabled{% endif %}"
class="btn btn-danger bg-sm"
title="Delete">
<i class="fas fa-trash"></i>
</a>
</span>
{% endif %}
{% endwith %}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
{% load static %}
{% block header_button %}
{% has_perm request.user "profiles.change_globalpermission" object as can_change_global_perm %}
<a href="{% url 'profiles:globalpermission_edit' %}"
class="btn btn-primary">
<i class="fas fa-pencil-alt {% if not can_change_global_perm %} disabled{% endif %}"></i>
</a>
{% if can_change_global_perm %}
<a href="{% url 'profiles:globalpermission_edit' %}"
class="btn btn-primary">
<i class="fas fa-pencil-alt"></i>
</a>
{% endif %}
{% endblock %}

{% block main %}
Expand Down
8 changes: 5 additions & 3 deletions templates/profiles/globalpermission_rbac_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
{% load static %}
{% block extra_header_button %}
{% has_perm request.user "profiles.add_users_globalpermission" object as can_add_users %}
<a href="{% url 'profiles:globalpermission_rbac_create' object.id %}"
class="btn btn-success{% if not can_add_users %} disabled{% endif %}"><i class="fas fa-user-plus"></i> Add Global RBAC
</a>
{% if can_add_users %}
<a href="{% url 'profiles:globalpermission_rbac_create' object.id %}"
class="btn btn-success"><i class="fas fa-user-plus"></i> Add Global RBAC
</a>
{% endif %}
{% endblock %}

{% block main %}
Expand Down
19 changes: 10 additions & 9 deletions templates/profiles/organization_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<span {% if not can_change_quota %}title="Permission profiles.change_quota needed"{% endif %}>
{% if can_change_quota %}
<a href="{% url 'profiles:organization_quota_edit' object.id %}"
class="btn btn-primary{% if not can_change_quota %} disabled{% endif %}">
class="btn btn-primary">
<i class="fas fa-chart-pie"></i> Set quotas
</a>
</span>
{% endif %}

<span {% if not can_add_user_in_organization %}title="Permission profiles.add_users_organization needed"{% endif %}>
{% if can_add_user_in_organization %}
<a href="{% url 'profiles:organization_rbac_create' object.id %}"
class="btn btn-success{% if not can_add_user_in_organization %} disabled{% endif %}">
class="btn btn-success">
<i class="fas fa-user-plus"></i> Add Organization RBAC
</a>
</span>
{% endif %}

<span {% if not can_add_team %}title="Permission profiles.add_team needed"{% endif %}>
{% if can_add_team %}
<a href="{% url 'profiles:team_create' %}?org={{ object.id }}"
class="btn btn-success{% if not can_add_team %} disabled{% endif %}">
class="btn btn-success">
<i class="fas fa-users"></i> Add team
</a>
</span>
{% endif %}

{% endblock %}

{% block header_button %}
Expand Down
22 changes: 11 additions & 11 deletions templates/profiles/team_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<span {% if not can_change_quota %} title="Permission profiles.change_quota needed" {% endif %}>
<a href="{% url 'profiles:team_quota_edit' object.id %}"
class="btn btn-primary{% if not can_change_quota %} disabled{% endif %}"> <i
class="fas fa-chart-pie"></i> Set quotas
</a>
</span>
<span {% if not can_add_user %} title="Permission profiles.add_users_team needed" {% endif %}>
<a href="{% url 'profiles:team_rbac_create' object.id %}"
class="btn btn-success{% if not can_add_user %} disabled{% endif %}"><i class="fas fa-user-plus"></i> Add Team RBAC
</a>
</span>
{% if can_change_quota %}
<a href="{% url 'profiles:team_quota_edit' object.id %}"
class="btn btn-primary"> <i
class="fas fa-chart-pie"></i> Set quotas
</a>
{% endif %}
{% if can_add_user %}
<a href="{% url 'profiles:team_rbac_create' object.id %}"
class="btn btn-success"><i class="fas fa-user-plus"></i> Add Team RBAC
</a>
{% endif %}
{% endblock %}
{% block header_button %}
{% include 'generics/buttons/edit_button.html' %}
Expand Down
12 changes: 6 additions & 6 deletions templates/service_catalog/buttons/delete_operation_button.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% with perm="service_catalog.delete_operation" %}
{% has_perm request.user perm object as can_delete %}
<span {% if not can_change %} title="Permission {{ perm }} needed" {% endif %}>
<a href="{% url 'service_catalog:operation_delete' object.service.id object.id %}"
class="btn btn-danger{% if not can_delete %} disabled{% endif %}">
<i class="fas fa-trash"></i>
</a>
</span>
{% if can_delete %}
<a href="{% url 'service_catalog:operation_delete' object.service.id object.id %}"
class="btn btn-danger">
<i class="fas fa-trash"></i>
</a>
{% endif %}
{% endwith %}
12 changes: 6 additions & 6 deletions templates/service_catalog/buttons/edit_operation_button.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% with perm="service_catalog.change_operation" %}
{% has_perm request.user perm object as can_change %}
<span {% if not can_change %} title="Permission {{ perm }} needed" {% endif %}>
<a href="{% url 'service_catalog:operation_edit' object.service.id object.id %}"
class="btn btn-primary{% if not can_change %} disabled{% endif %}">
<i class="fas fa-pencil-alt"></i>
</a>
</span>
{% if can_change %}
<a href="{% url 'service_catalog:operation_edit' object.service.id object.id %}"
class="btn btn-primary">
<i class="fas fa-pencil-alt"></i>
</a>
{% endif %}
{% endwith %}
22 changes: 12 additions & 10 deletions templates/service_catalog/buttons/instance_buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
</a>
{% endif %}
{% endwith %}
{% if object.service.external_support_url is not None and object.service.external_support_url != '' %}
<a class="btn btn-success {% if not can_add_support %}disabled{% endif %}"
href="{% url 'service_catalog:support_create' object.id %}">
<i class="fas fa-link"></i> Open new support
</a>
{% else %}
<a class="btn btn-success {% if not can_add_support %}disabled{% endif %}"
href="{% url 'service_catalog:support_create' object.id %}">
<i class="fas fa-plus"></i> Open new support
</a>
{% if can_add_support %}
{% if object.service.external_support_url is not None and object.service.external_support_url != '' %}
<a class="btn btn-success"
href="{% url 'service_catalog:support_create' object.id %}">
<i class="fas fa-link"></i> Open new support
</a>
{% else %}
<a class="btn btn-success"
href="{% url 'service_catalog:support_create' object.id %}">
<i class="fas fa-plus"></i> Open new support
</a>
{% endif %}
{% endif %}
12 changes: 6 additions & 6 deletions templates/service_catalog/buttons/operation_survey_button.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% has_perm request.user "service_catalog.change_operation" as can_change %}
<span {% if not can_change %} title="Permission service_catalog.change_operation needed" {% endif %}>
<a href="{% url 'service_catalog:operation_edit_survey' service_id=object.service.id pk=object.id %}"
class="btn btn-default bg-sm {% if not can_change %} disabled {% endif %}">
<i class="fas fa-clipboard-list"></i> Survey
</a>
</span>
{% if can_change %}
<a href="{% url 'service_catalog:operation_edit_survey' service_id=object.service.id pk=object.id %}"
class="btn btn-default bg-sm">
<i class="fas fa-clipboard-list"></i> Survey
</a>
{% endif %}
Loading
Loading