diff --git a/Squest/utils/squest_table.py b/Squest/utils/squest_table.py index bfb628f97..d1abe2a4b 100644 --- a/Squest/utils/squest_table.py +++ b/Squest/utils/squest_table.py @@ -1,4 +1,4 @@ -from django_tables2 import tables +from django_tables2 import tables, RequestConfig class SquestTable(tables.Table): @@ -12,3 +12,9 @@ def __init__(self, *args, **kwargs): for field in hide_field: if field in self.columns.columns: self.columns.hide(field) + +class SquestRequestConfig(RequestConfig): + + def __init__(self, request, paginate=False): + self.request = request + self.paginate = paginate diff --git a/profiles/views/globalscope.py b/profiles/views/globalscope.py index c3965976c..9fd3edef1 100644 --- a/profiles/views/globalscope.py +++ b/profiles/views/globalscope.py @@ -1,4 +1,4 @@ -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import * from profiles.forms import GlobalScopeForm @@ -23,7 +23,7 @@ def dispatch(self, request, *args, **kwargs): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) context['breadcrumbs'] = None context['title'] = "Global scope" context['users'] = UserRoleTable(self.object.users, prefix="user-") @@ -46,7 +46,7 @@ def dispatch(self, request, *args, **kwargs): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) context['breadcrumbs'] = None context['title'] = "Default permissions" context['global_permissions'] = PermissionTable(self.object.global_permissions.all(), exclude='actions', diff --git a/profiles/views/organization.py b/profiles/views/organization.py index dc427fece..283991122 100644 --- a/profiles/views/organization.py +++ b/profiles/views/organization.py @@ -1,4 +1,4 @@ -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import * from profiles.filters import OrganizationFilter @@ -22,7 +22,7 @@ class OrganizationDetailView(SquestDetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) if self.request.user.has_perm("profiles.view_users_organization", self.get_object()): context['users'] = UserRoleTable(self.object.users.all(), prefix="user-") else: diff --git a/profiles/views/profile.py b/profiles/views/profile.py index 77133437f..61c6d3880 100644 --- a/profiles/views/profile.py +++ b/profiles/views/profile.py @@ -1,7 +1,7 @@ from django.contrib.auth.decorators import login_required from django.http import HttpResponseRedirect from django.shortcuts import render -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from profiles.models import Token from profiles.tables import RequestNotificationFilterTable, InstanceNotificationFilterTable diff --git a/profiles/views/quota.py b/profiles/views/quota.py index fa9fbf135..7b750b1d1 100644 --- a/profiles/views/quota.py +++ b/profiles/views/quota.py @@ -1,7 +1,7 @@ from django.core.exceptions import ImproperlyConfigured from django.db.models import Sum from django.shortcuts import get_object_or_404 -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import * from profiles.filters.quota import QuotaFilter @@ -83,7 +83,7 @@ class QuotaDetailsView(SquestDetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) scope = self.object.scope.get_object() class_name = scope.__class__.__name__ diff --git a/profiles/views/role.py b/profiles/views/role.py index 92c566887..b9745b18d 100644 --- a/profiles/views/role.py +++ b/profiles/views/role.py @@ -1,4 +1,4 @@ -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import * from profiles.filters import RoleFilter @@ -19,7 +19,7 @@ class RoleDetailView(SquestDetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) context['permissions_table'] = PermissionTable(self.object.permissions.prefetch_related("content_type"), exclude='actions', prefix="permission-") diff --git a/profiles/views/team.py b/profiles/views/team.py index 0536aac3d..79e2f2386 100644 --- a/profiles/views/team.py +++ b/profiles/views/team.py @@ -1,4 +1,4 @@ -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import * from profiles.filters.team_filter import TeamFilter @@ -29,7 +29,7 @@ class TeamDetailView(SquestDetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) context['breadcrumbs'] = get_organization_breadcrumbs(self.object) + context['breadcrumbs'] if self.request.user.has_perm("profiles.view_users_team", self.get_object()): context['users'] = UserRoleTable(self.object.users.all(), prefix="user-") diff --git a/profiles/views/user.py b/profiles/views/user.py index 3b9e4da44..358446d25 100644 --- a/profiles/views/user.py +++ b/profiles/views/user.py @@ -1,5 +1,5 @@ from django.contrib.auth.models import User -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import SquestListView, SquestDetailView from profiles.filters.user_filter import UserFilter @@ -27,7 +27,7 @@ class UserDetailsView(SquestDetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) context['breadcrumbs'] = [ { diff --git a/resource_tracker_v2/views/attribute_definition_views.py b/resource_tracker_v2/views/attribute_definition_views.py index 22ec528d4..b89611d0b 100644 --- a/resource_tracker_v2/views/attribute_definition_views.py +++ b/resource_tracker_v2/views/attribute_definition_views.py @@ -1,4 +1,4 @@ -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import * from profiles.tables.quota_table import QuotaTable @@ -14,7 +14,7 @@ class AttributeDefinitionDetailView(SquestDetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) if self.request.user.has_perm("profiles.view_quota", self.get_object()): context['quotas'] = QuotaTable\ (self.object.quotas.distinct(), diff --git a/resource_tracker_v2/views/resource_group_views.py b/resource_tracker_v2/views/resource_group_views.py index 69daf869d..38376cc5c 100644 --- a/resource_tracker_v2/views/resource_group_views.py +++ b/resource_tracker_v2/views/resource_group_views.py @@ -1,4 +1,4 @@ -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import * from resource_tracker_v2.filters.resource_group_filter import ResourceGroupFilter @@ -25,7 +25,7 @@ class ResourceGroupDetailView(SquestDetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) context["attributes_table"] = TransformerTable(self.object.transformers.all(), prefix="attribute-") config.configure(context['attributes_table']) context["resources_table"] = ResourceTable(self.object.resources.all(), hide_fields=('selection',), diff --git a/service_catalog/views/instance.py b/service_catalog/views/instance.py index 12a87cce2..669fabd77 100644 --- a/service_catalog/views/instance.py +++ b/service_catalog/views/instance.py @@ -6,7 +6,7 @@ from django.urls import reverse from django.utils.safestring import mark_safe from django_fsm import can_proceed -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from jinja2 import UndefinedError from Squest.utils.squest_views import SquestListView, SquestDetailView, SquestUpdateView, SquestDeleteView, \ @@ -82,7 +82,7 @@ class InstanceDetailView(SquestDetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) # operations operations = Operation.objects.none() diff --git a/service_catalog/views/operation.py b/service_catalog/views/operation.py index c068377da..170b09d9f 100644 --- a/service_catalog/views/operation.py +++ b/service_catalog/views/operation.py @@ -1,5 +1,5 @@ from django.shortcuts import redirect, get_object_or_404 -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import * from service_catalog.filters.operation_filter import OperationFilter, OperationFilterLimited @@ -64,7 +64,7 @@ def get_queryset(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) context['breadcrumbs'] = [ { diff --git a/service_catalog/views/tower_server.py b/service_catalog/views/tower_server.py index 545e1ef4d..c66768c98 100644 --- a/service_catalog/views/tower_server.py +++ b/service_catalog/views/tower_server.py @@ -4,7 +4,7 @@ from django.shortcuts import get_object_or_404 from django.urls import reverse_lazy from django_celery_results.models import TaskResult -from django_tables2 import RequestConfig +from Squest.utils.squest_table import SquestRequestConfig from Squest.utils.squest_views import SquestListView, SquestCreateView, SquestDeleteView, SquestUpdateView, \ SquestDetailView @@ -27,7 +27,7 @@ class TowerServerDetailView(SquestDetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = RequestConfig(self.request) + config = SquestRequestConfig(self.request) context["jobtemplate_table"] = JobTemplateTable(self.object.jobtemplate_set.all(), prefix="jobtemplate-") config.configure(context['jobtemplate_table'])