diff --git a/apps/core/templatetags/tags.py b/apps/core/templatetags/tags.py index 81921eb..caa68c6 100644 --- a/apps/core/templatetags/tags.py +++ b/apps/core/templatetags/tags.py @@ -27,4 +27,13 @@ def get_proper_elided_page_range(p, number, on_each_side=2, on_ends=2): @register.filter def get_item(dictionary, key): - return dictionary.get(key) \ No newline at end of file + return dictionary.get(key) + + +@register.simple_tag +def get_filter_link(request, key, value): + qs: str = request.GET.urlencode() + qs_dict = request.GET.dict() + qs_dict.update({key: value}) + return '&'.join(f'{k}={v}' for k, v in qs_dict.items()) + # return 'page={{ i }}{% for fil, fil_value in filter.data.items %}{% if fil != 'page' %}&{{fil}}={{fil_value}}{% endif %}{% endfor %}">{{ i }} diff --git a/apps/gooyal_oauth2/views/pages.py b/apps/gooyal_oauth2/views/pages.py index 3d45911..baaaa25 100644 --- a/apps/gooyal_oauth2/views/pages.py +++ b/apps/gooyal_oauth2/views/pages.py @@ -54,9 +54,13 @@ class ApplicationDetailView(DetailView): class ApplicationListView(FilterMixin, ListView): model = Application template_name = "gooyal_oauth2/application_list.html" - paginate_by = 20 + paginate_by = 2 filterset_class = ApplicationFilter + def get_ordering(self): + ordering = self.request.GET.get('ordering', 'name') + return ordering + def get_queryset(self): qs = super().get_queryset() return qs.filter(user=self.request.user) diff --git a/templates/gooyal_oauth2/application_list.html b/templates/gooyal_oauth2/application_list.html index 9ff5cdb..c1057c5 100644 --- a/templates/gooyal_oauth2/application_list.html +++ b/templates/gooyal_oauth2/application_list.html @@ -2,6 +2,8 @@ {% load static %} {% load jalali_tags %} {% load crispy_forms_tags %} +{% load tags %} + {% block title %}Application: list{% endblock %} {% block page_title %}Application: list{% endblock %} @@ -21,8 +23,8 @@ {% block content %} - - + + {% for obj in object_list %} diff --git a/templates/include/paginator.html b/templates/include/paginator.html index f78b941..47f4018 100644 --- a/templates/include/paginator.html +++ b/templates/include/paginator.html @@ -10,7 +10,7 @@ {% elif i == '…' %}
  • {{ i }}
  • {% else %} -
  • {{ i }}
  • +
  • {{ i }}
  • {% endif %} {% endfor %} {% endif %}
    nameclient idname{% if request.GET.ordering and 'name' in request.GET.ordering %}{% endif %}client id{% if request.GET.ordering and 'client_id' in request.GET.ordering %}{% endif %} actions