From bd0b8fd0a2913fb5d5410a04547b5af398725639 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Fri, 29 Sep 2017 01:26:08 +0200 Subject: [PATCH] added user list view as a paginated resource \o/ --- ordr2/templates/admin/admin_section.jinja2 | 4 +- ordr2/templates/admin/user_list.jinja2 | 90 ++++++++++++++++++++++ ordr2/templates/macros.jinja2 | 58 ++++++++++++++ ordr2/views/admin.py | 12 +++ 4 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 ordr2/templates/admin/user_list.jinja2 diff --git a/ordr2/templates/admin/admin_section.jinja2 b/ordr2/templates/admin/admin_section.jinja2 index 9ac9d70..68f1635 100644 --- a/ordr2/templates/admin/admin_section.jinja2 +++ b/ordr2/templates/admin/admin_section.jinja2 @@ -17,13 +17,13 @@
{{ macros.flash_messages() }}
- +

Mangage Users

- +

Manage Consumables

diff --git a/ordr2/templates/admin/user_list.jinja2 b/ordr2/templates/admin/user_list.jinja2 new file mode 100644 index 0000000..5582222 --- /dev/null +++ b/ordr2/templates/admin/user_list.jinja2 @@ -0,0 +1,90 @@ +{% extends "ordr2:templates/layout.jinja2" %} +{% import 'ordr2:templates/macros.jinja2' as macros with context %} + +{% block subtitle %} Admin | Users {% endblock subtitle %} + +{% block content %} +
+{% endblock content %} diff --git a/ordr2/templates/macros.jinja2 b/ordr2/templates/macros.jinja2 index 7fb24ba..95f5943 100644 --- a/ordr2/templates/macros.jinja2 +++ b/ordr2/templates/macros.jinja2 @@ -14,3 +14,61 @@ {% endfor %} {% endfor %} {%- endmacro %} + + +{% macro filter_box(title, query_key, items) -%} + +{%- endmacro %} + + +{% macro sortable_table_header(title, sort_by) -%} + + {% set new_direction = 'desc' if context.sorting.direction == 'asc' else 'asc' %} + {% set new_sort = sort_by + '.' + new_direction %} + {{ title }} + +{%- endmacro %} + + +{% macro pagination_helper(page, text=None, css_class='') -%} + {% set is_active = 'active' if page == context.pages.current %} + {% set is_disabled = 'disabled' if not page %} + {% set url = context.url( (context.query_key_current_page, page) ) if page %} +
  • + {{ text if text else page }} +
  • +{%- endmacro %}} + +{% macro pagination() -%} + {% if context.pages and context.pages.last > 1 %} + + {% endif %} +{%- endmacro %} + + diff --git a/ordr2/views/admin.py b/ordr2/views/admin.py index 8f7749f..93b4a04 100644 --- a/ordr2/views/admin.py +++ b/ordr2/views/admin.py @@ -29,3 +29,15 @@ def admin_section(context, request): processed.'''.format(request.resource_url(context, 'users')) ) return {} + + +@view_config( + context='ordr2:resources.UserList', + permission='view', + renderer='ordr2:templates/admin/user_list.jinja2' + ) +def user_list(context, request): + ''' display the user list ''' + users = context.items() + roles = [(role.name, role.value.capitalize()) for role in Role] + return {'users':users, 'roles':roles}