diff --git a/musician/templates/musician/components/table_paginator.html b/musician/templates/musician/components/table_paginator.html new file mode 100644 index 0000000..0bfef23 --- /dev/null +++ b/musician/templates/musician/components/table_paginator.html @@ -0,0 +1,31 @@ +{# #} + + + {{ page_obj.paginator.count }} items in total + + {% if page_obj.has_previous %} + « + + {% endif %} + Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }} + {% if page_obj.has_next %} + + » + {% endif %} + + +
+ Showing + + per page + +
+ + + diff --git a/musician/templates/musician/mailinglists.html b/musician/templates/musician/mailinglists.html index 927ff1c..031c33e 100644 --- a/musician/templates/musician/mailinglists.html +++ b/musician/templates/musician/mailinglists.html @@ -3,7 +3,30 @@ {% block content %} -

Section title

+

Mailing lists

Little description of what to be expected...

+ + + + + + + + + + + + {% for resource in object_list %} + + + + + + + + {% endfor %} + + {% include "musician/components/table_paginator.html" %} +
NameStatusAddressAdmin emailConfigure
{{ resource.name }}{{ resource.status }}{{ resource.address_name}}@{{ resource.address_domain.name }}{{ resource.admin_email }}Mailtrain
{% endblock %} diff --git a/musician/views.py b/musician/views.py index 4e9674d..ef45234 100644 --- a/musician/views.py +++ b/musician/views.py @@ -34,8 +34,30 @@ class MailView(CustomContextMixin, UserTokenRequiredMixin, TemplateView): template_name = "musician/mail.html" -class MailingListsView(CustomContextMixin, UserTokenRequiredMixin, TemplateView): +class MailingListsView(CustomContextMixin, UserTokenRequiredMixin, ListView): template_name = "musician/mailinglists.html" + paginate_by = 20 + paginate_by_kwarg = 'per_page' + + def get_queryset(self): + return self.orchestra.retrieve_service_list('mailinglist') + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context.update({ + 'page_param': self.page_kwarg, + 'per_page_values': [5, 10, 20, 50], + 'per_page_param': self.paginate_by_kwarg, + }) + return context + + def get_paginate_by(self, queryset): + per_page = self.request.GET.get(self.paginate_by_kwarg) or self.paginate_by + try: + paginate_by = int(per_page) + except ValueError: + paginate_by = self.paginate_by + return paginate_by class DatabasesView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):