Skip to content

Commit

Permalink
Fix per_page on table in tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
a-belhadj authored and Sispheor committed Oct 20, 2023
1 parent 6612e78 commit bedfcc6
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 25 deletions.
8 changes: 7 additions & 1 deletion Squest/utils/squest_table.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django_tables2 import tables
from django_tables2 import tables, RequestConfig


class SquestTable(tables.Table):
Expand All @@ -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
6 changes: 3 additions & 3 deletions profiles/views/globalscope.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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-")
Expand All @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions profiles/views/organization.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion profiles/views/profile.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions profiles/views/quota.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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__
Expand Down
4 changes: 2 additions & 2 deletions profiles/views/role.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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-")
Expand Down
4 changes: 2 additions & 2 deletions profiles/views/team.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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-")
Expand Down
4 changes: 2 additions & 2 deletions profiles/views/user.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'] = [
{
Expand Down
4 changes: 2 additions & 2 deletions resource_tracker_v2/views/attribute_definition_views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions resource_tracker_v2/views/resource_group_views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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',),
Expand Down
4 changes: 2 additions & 2 deletions service_catalog/views/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions service_catalog/views/operation.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'] = [
{
Expand Down
4 changes: 2 additions & 2 deletions service_catalog/views/tower_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'])

Expand Down

0 comments on commit bedfcc6

Please sign in to comment.