From 45c3d554705f685326f4ef7709f007395bb2a070 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Mon, 17 May 2021 21:34:49 +0200 Subject: [PATCH] Added admin templates --- advlabdb/customClasses.py | 14 +- advlabdb/templates/admin/actions.html | 34 +++ advlabdb/templates/admin/base.html | 98 +++++++ advlabdb/templates/admin/file/form.html | 9 + advlabdb/templates/admin/file/list.html | 196 ++++++++++++++ .../templates/admin/file/modals/form.html | 19 ++ advlabdb/templates/admin/index.html | 4 + advlabdb/templates/admin/layout.html | 102 +++++++ advlabdb/templates/admin/lib.html | 256 ++++++++++++++++++ advlabdb/templates/admin/master.html | 1 + advlabdb/templates/admin/model/create.html | 30 ++ advlabdb/templates/admin/model/details.html | 52 ++++ advlabdb/templates/admin/model/edit.html | 40 +++ .../admin/model/inline_field_list.html | 15 + .../templates/admin/model/inline_form.html | 4 + .../admin/model/inline_list_base.html | 45 +++ advlabdb/templates/admin/model/layout.html | 107 ++++++++ advlabdb/templates/admin/model/list.html | 197 ++++++++++++++ .../templates/admin/model/modals/create.html | 24 ++ .../templates/admin/model/modals/details.html | 40 +++ .../templates/admin/model/modals/edit.html | 26 ++ .../templates/admin/model/row_actions.html | 38 +++ .../templates/admin/rediscli/console.html | 27 ++ .../templates/admin/rediscli/response.html | 32 +++ advlabdb/templates/admin/static.html | 3 + advlabdb/templates/admin_create.html | 6 + advlabdb/templates/admin_edit.html | 6 + advlabdb/templates/admin_list.html | 6 + 28 files changed, 1421 insertions(+), 10 deletions(-) create mode 100644 advlabdb/templates/admin/actions.html create mode 100644 advlabdb/templates/admin/base.html create mode 100644 advlabdb/templates/admin/file/form.html create mode 100644 advlabdb/templates/admin/file/list.html create mode 100644 advlabdb/templates/admin/file/modals/form.html create mode 100644 advlabdb/templates/admin/index.html create mode 100644 advlabdb/templates/admin/layout.html create mode 100644 advlabdb/templates/admin/lib.html create mode 100644 advlabdb/templates/admin/master.html create mode 100644 advlabdb/templates/admin/model/create.html create mode 100644 advlabdb/templates/admin/model/details.html create mode 100644 advlabdb/templates/admin/model/edit.html create mode 100644 advlabdb/templates/admin/model/inline_field_list.html create mode 100644 advlabdb/templates/admin/model/inline_form.html create mode 100644 advlabdb/templates/admin/model/inline_list_base.html create mode 100644 advlabdb/templates/admin/model/layout.html create mode 100755 advlabdb/templates/admin/model/list.html create mode 100644 advlabdb/templates/admin/model/modals/create.html create mode 100755 advlabdb/templates/admin/model/modals/details.html create mode 100644 advlabdb/templates/admin/model/modals/edit.html create mode 100644 advlabdb/templates/admin/model/row_actions.html create mode 100644 advlabdb/templates/admin/rediscli/console.html create mode 100644 advlabdb/templates/admin/rediscli/response.html create mode 100644 advlabdb/templates/admin/static.html create mode 100644 advlabdb/templates/admin_create.html create mode 100644 advlabdb/templates/admin_edit.html create mode 100644 advlabdb/templates/admin_list.html diff --git a/advlabdb/customClasses.py b/advlabdb/customClasses.py index 6f3bb01..72f4812 100644 --- a/advlabdb/customClasses.py +++ b/advlabdb/customClasses.py @@ -9,25 +9,19 @@ from advlabdb.utils import userActiveSemester def adminViewIsAccessible(): return current_user.has_role("admin") -def handleAdminView(): - flash("User active semester: " + userActiveSemester(flashWarning=True).label) class SecureAdminIndexView(AdminIndexView): def is_accessible(self): return adminViewIsAccessible() - def _handle_view(self, *args, **kwargs): - handleAdminView() - return super()._handle_view(*args, **kwargs) - class SecureModelView(ModelView): can_export = True can_set_page_size = True + list_template = "admin_list.html" + create_template = "admin_create.html" + edit_template = "admin_edit.html" + def is_accessible(self): return adminViewIsAccessible() - - def _handle_view(self, *args, **kwargs): - handleAdminView() - return super()._handle_view(*args, **kwargs) diff --git a/advlabdb/templates/admin/actions.html b/advlabdb/templates/admin/actions.html new file mode 100644 index 0000000..02257bb --- /dev/null +++ b/advlabdb/templates/admin/actions.html @@ -0,0 +1,34 @@ +{% import 'admin/static.html' as admin_static with context %} + +{% macro dropdown(actions, btn_class='btn dropdown-toggle') -%} + {{ _gettext('With selected') }} + +{% endmacro %} + +{% macro form(actions, url) %} + {% if actions %} + + {% endif %} +{% endmacro %} + +{% macro script(message, actions, actions_confirmation) %} + {% if actions %} + + + + {% endif %} +{% endmacro %} diff --git a/advlabdb/templates/admin/base.html b/advlabdb/templates/admin/base.html new file mode 100644 index 0000000..823df51 --- /dev/null +++ b/advlabdb/templates/admin/base.html @@ -0,0 +1,98 @@ +{% import 'admin/layout.html' as layout with context -%} +{% import 'admin/static.html' as admin_static with context %} + + + + {% block title %}{% if admin_view.category %}{{ admin_view.category }} - {% endif %}{{ admin_view.name }} - {{ admin_view.admin.name }}{% endblock %} + {% block head_meta %} + + + + + + {% endblock %} + {% block head_css %} + + {%if config.get('FLASK_ADMIN_SWATCH', 'default') == 'default' %} + + {%endif%} + + + {% if admin_view.extra_css %} + {% for css_url in admin_view.extra_css %} + + {% endfor %} + {% endif %} + + {% endblock %} + {% block head %} + {% endblock %} + {% block head_tail %} + {% endblock %} + + + {% block page_body %} +
+ + + {% block messages %} + {{ layout.messages() }} + {% endblock %} + + {# store the jinja2 context for form_rules rendering logic #} + {% set render_ctx = h.resolve_ctx() %} + + {% block body %}{% endblock %} +
+ {% endblock %} + + {% block tail_js %} + + + + + + {% if admin_view.extra_js %} + {% for js_url in admin_view.extra_js %} + + {% endfor %} + {% endif %} + {% endblock %} + + {% block tail %} + {% endblock %} + + diff --git a/advlabdb/templates/admin/file/form.html b/advlabdb/templates/admin/file/form.html new file mode 100644 index 0000000..7a4474a --- /dev/null +++ b/advlabdb/templates/admin/file/form.html @@ -0,0 +1,9 @@ +{% extends 'admin/master.html' %} +{% import 'admin/lib.html' as lib with context %} + +{% block body %} + {% block header %}

{{ header_text }}

{% endblock %} + {% block fa_form %} + {{ lib.render_form(form, dir_url) }} + {% endblock %} +{% endblock %} diff --git a/advlabdb/templates/admin/file/list.html b/advlabdb/templates/admin/file/list.html new file mode 100644 index 0000000..1fb093e --- /dev/null +++ b/advlabdb/templates/admin/file/list.html @@ -0,0 +1,196 @@ +{% extends 'admin/master.html' %} +{% import 'admin/lib.html' as lib with context %} +{% import 'admin/actions.html' as actionslib with context %} + +{% block body %} + {% block breadcrums %} + + {% endblock %} + + {% block file_list_table %} +
+ + + + {% block list_header scoped %} + {% if actions %} + + {% endif %} + + {% for column in admin_view.column_list %} + + {% endfor %} + {% endblock %} + + + {% for name, path, is_dir, size, date in items %} + + {% block list_row scoped %} + {% if actions %} + + {% endif %} + + {% if is_dir %} + + {% else %} + + {% if admin_view.is_column_visible('size') %} + + {% endif %} + {% endif %} + {% if admin_view.is_column_visible('date') %} + + {% endif %} + {% endblock %} + + {% endfor %} +
+ +   + {% if admin_view.is_column_sortable(column) %} + {% if sort_column == column %} + + {{ admin_view.column_label(column) }} + {% if sort_desc %} + + {% else %} + + {% endif %} + + {% else %} + {{ admin_view.column_label(column) }} + {% endif %} + {% else %} + {{ _gettext(admin_view.column_label(column)) }} + {% endif %} +
+ {% if not is_dir %} + + {% endif %} + + {% block list_row_actions scoped %} + {% if admin_view.can_rename and path and name != '..' %} + {%- if admin_view.rename_modal -%} + {{ lib.add_modal_button(url=get_url('.rename', path=path, modal=True), + title=_gettext('Rename File'), + content='') }} + {% else %} + + + + {%- endif -%} + {% endif %} + {%- if admin_view.can_delete and path -%} + {% if is_dir %} + {% if name != '..' and admin_view.can_delete_dirs %} +
+ {{ delete_form.path(value=path) }} + {% if delete_form.csrf_token %} + {{ delete_form.csrf_token }} + {% elif csrf_token %} + + {% endif %} + +
+ {% endif %} + {% else %} +
+ {{ delete_form.path(value=path) }} + {% if delete_form.csrf_token %} + {{ delete_form.csrf_token }} + {% elif csrf_token %} + + {% endif %} + +
+ {% endif %} + {%- endif -%} + {% endblock %} +
+ + {{ name }} + + + {% if admin_view.can_download %} + {%- if admin_view.edit_modal and admin_view.is_file_editable(path) -%} + {{ lib.add_modal_button(url=get_file_url(path, modal=True)|safe, + btn_class='', content=name) }} + {% else %} + {{ name }} + {%- endif -%} + {% else %} + {{ name }} + {% endif %} + + {{ size|filesizeformat }} + + {{ timestamp_format(date) }} +
+
+ {% endblock %} + {% block toolbar %} +
+ {% if admin_view.can_upload %} +
+ {%- if admin_view.upload_modal -%} + {{ lib.add_modal_button(url=get_dir_url('.upload', path=dir_path, modal=True), + btn_class="btn btn-default btn-large", + content=_gettext('Upload File')) }} + {% else %} + {{ _gettext('Upload File') }} + {%- endif -%} +
+ {% endif %} + {% if admin_view.can_mkdir %} +
+ {%- if admin_view.mkdir_modal -%} + {{ lib.add_modal_button(url=get_dir_url('.mkdir', path=dir_path, modal=True), + btn_class="btn btn-default btn-large", + content=_gettext('Create Directory')) }} + {% else %} + {{ _gettext('Create Directory') }} + {%- endif -%} +
+ {% endif %} + {% if actions %} +
+ {{ actionslib.dropdown(actions, 'dropdown-toggle btn btn-default btn-large') }} +
+ {% endif %} +
+ {% endblock %} + + {% block actions %} + {{ actionslib.form(actions, get_url('.action_view')) }} + {% endblock %} + + {%- if admin_view.rename_modal or admin_view.mkdir_modal + or admin_view.upload_modal or admin_view.edit_modal -%} + {{ lib.add_modal_window() }} + {%- endif -%} +{% endblock %} + +{% block tail %} + {{ super() }} + {{ actionslib.script(_gettext('Please select at least one file.'), + actions, + actions_confirmation) }} +{% endblock %} diff --git a/advlabdb/templates/admin/file/modals/form.html b/advlabdb/templates/admin/file/modals/form.html new file mode 100644 index 0000000..68d2f87 --- /dev/null +++ b/advlabdb/templates/admin/file/modals/form.html @@ -0,0 +1,19 @@ +{% import 'admin/static.html' as admin_static with context %} +{% import 'admin/lib.html' as lib with context %} + +{% block body %} + {# content added to modal-content #} + + +{% endblock %} + +{% block tail %} + +{% endblock %} diff --git a/advlabdb/templates/admin/index.html b/advlabdb/templates/admin/index.html new file mode 100644 index 0000000..fbfdf4c --- /dev/null +++ b/advlabdb/templates/admin/index.html @@ -0,0 +1,4 @@ +{% extends 'admin/master.html' %} + +{% block body %} +{% endblock %} diff --git a/advlabdb/templates/admin/layout.html b/advlabdb/templates/admin/layout.html new file mode 100644 index 0000000..a2f63ea --- /dev/null +++ b/advlabdb/templates/admin/layout.html @@ -0,0 +1,102 @@ +{% macro menu_icon(item) -%} +{% set icon_type = item.get_icon_type() %} +{%- if icon_type %} + {% set icon_value = item.get_icon_value() %} + {% if icon_type == 'glyph' %} + + {% elif icon_type == 'fa' %} + + {% elif icon_type == 'image' %} + menu image + {% elif icon_type == 'image-url' %} + menu image + {% endif %} +{% endif %} +{%- endmacro %} + +{% macro menu(menu_root=None) %} + {% if menu_root is none %}{% set menu_root = admin_view.admin.menu() %}{% endif %} + {%- for item in menu_root %} + {%- if item.is_category() -%} + {% set children = item.get_children() %} + {%- if children %} + {% set class_name = item.get_class_name() or '' %} + {%- if item.is_active(admin_view) %} + + {% endif %} + {%- else %} + {%- if item.is_accessible() and item.is_visible() -%} + {% set class_name = item.get_class_name() %} + {%- if item.is_active(admin_view) %} +
  • + {%- else %} + + {%- endif %} + {{ menu_icon(item) }}{{ item.name }} +
  • + {%- endif -%} + {% endif -%} + {% endfor %} +{% endmacro %} + +{% macro menu_links(links=None) %} + {% if links is none %}{% set links = admin_view.admin.menu_links() %}{% endif %} + {% for item in links %} + {% set class_name = item.get_class_name() %} + {% if item.is_accessible() and item.is_visible() %} + + {{ menu_icon(item) }}{{ item.name }} + + {% endif %} + {% endfor %} +{% endmacro %} + +{% macro messages() %} + {% with messages = get_flashed_messages(with_categories=True) %} + {% if messages %} + {% for category, m in messages %} + {% if category %} + {# alert-error changed to alert-danger in bootstrap 3, mapping is for backwards compatibility #} + {% set mapping = {'message': 'info', 'error': 'danger'} %} +
    + {% else %} +
    + {% endif %} + + {{ m }} +
    + {% endfor %} + {% endif %} + {% endwith %} +{% endmacro %} diff --git a/advlabdb/templates/admin/lib.html b/advlabdb/templates/admin/lib.html new file mode 100644 index 0000000..6bfdb05 --- /dev/null +++ b/advlabdb/templates/admin/lib.html @@ -0,0 +1,256 @@ +{% import 'admin/static.html' as admin_static with context %} + +{# ---------------------- Pager -------------------------- #} +{% macro pager(page, pages, generator) -%} +{% if pages > 1 %} +
      + {% set min = page - 3 %} + {% set max = page + 3 + 1 %} + + {% if min < 0 %} + {% set max = max - min %} + {% endif %} + {% if max >= pages %} + {% set min = min - max + pages %} + {% endif %} + + {% if min < 0 %} + {% set min = 0 %} + {% endif %} + {% if max >= pages %} + {% set max = pages %} + {% endif %} + + {% if min > 0 %} +
    • + « +
    • + {% else %} +
    • + « +
    • + {% endif %} + {% if page > 0 %} +
    • + < +
    • + {% else %} +
    • + < +
    • + {% endif %} + + {% for p in range(min, max) %} + {% if page == p %} +
    • + {{ p + 1 }} +
    • + {% else %} +
    • + {{ p + 1 }} +
    • + {% endif %} + {% endfor %} + + {% if page + 1 < pages %} +
    • + > +
    • + {% else %} +
    • + > +
    • + {% endif %} + {% if max < pages %} +
    • + » +
    • + {% else %} +
    • + » +
    • + {% endif %} +
    +{% endif %} +{%- endmacro %} + +{% macro simple_pager(page, have_next, generator) -%} +
      + {% if page > 0 %} +
    • + < +
    • + {% else %} +
    • + < +
    • + {% endif %} + {% if have_next %} +
    • + > +
    • + {% else %} +
    • + > +
    • + {% endif %} +
    +{%- endmacro %} + +{# ---------------------- Modal Window ------------------- #} +{% macro add_modal_window(modal_window_id='fa_modal_window', modal_label_id='fa_modal_label') %} + +{% endmacro %} + +{% macro add_modal_button(url='', title='', content='', modal_window_id='fa_modal_window', btn_class='icon') %} + + {{ content|safe }} + +{% endmacro %} + +{# ---------------------- Forms -------------------------- #} +{% macro render_field(form, field, kwargs={}, caller=None) %} + {% set direct_error = h.is_field_error(field.errors) %} +
    + +
    + {% set _dummy = kwargs.setdefault('class', 'form-control') %} + {{ field(**kwargs)|safe }} + {% if field.description %} +

    {{ field.description|safe }}

    + {% endif %} + {% if direct_error %} +
      + {% for e in field.errors if e is string %} +
    • {{ e }}
    • + {% endfor %} +
    + {% endif %} +
    + {% if caller %} + {{ caller(form, field, direct_error, kwargs) }} + {% endif %} +
    +{% endmacro %} + +{% macro render_header(form, text) %} +

    {{ text }}

    +{% endmacro %} + +{% macro render_form_fields(form, form_opts=None) %} + {% if form.hidden_tag is defined %} + {{ form.hidden_tag() }} + {% else %} + {% if csrf_token %} + + {% endif %} + {% for f in form if f.widget.input_type == 'hidden' %} + {{ f }} + {% endfor %} + {% endif %} + + {% if form_opts and form_opts.form_rules %} + {% for r in form_opts.form_rules %} + {{ r(form, form_opts=form_opts) }} + {% endfor %} + {% else %} + {% for f in form if f.widget.input_type != 'hidden' %} + {% if form_opts %} + {% set kwargs = form_opts.widget_args.get(f.short_name, {}) %} + {% else %} + {% set kwargs = {} %} + {% endif %} + {{ render_field(form, f, kwargs) }} + {% endfor %} + {% endif %} +{% endmacro %} + +{% macro form_tag(form=None, action=None) %} +
    + {{ caller() }} +
    +{% endmacro %} + +{% macro render_form_buttons(cancel_url, extra=None, is_modal=False) %} +
    +
    +
    + + {% if extra %} + {{ extra }} + {% endif %} + {% if cancel_url %} + {{ _gettext('Cancel') }} + {% endif %} +
    +
    +{% endmacro %} + +{% macro render_form(form, cancel_url, extra=None, form_opts=None, action=None, is_modal=False) -%} + {% call form_tag(action=action) %} + {{ render_form_fields(form, form_opts=form_opts) }} + {{ render_form_buttons(cancel_url, extra, is_modal) }} + {% endcall %} +{% endmacro %} + +{% macro form_css() %} + + + + {% if config.MAPBOX_MAP_ID %} + + + {% endif %} + {% if editable_columns %} + + {% endif %} +{% endmacro %} + +{% macro form_js() %} + {% if config.MAPBOX_MAP_ID %} + + + + {% if config.MAPBOX_SEARCH %} + + + {% endif %} + {% endif %} + + {% if editable_columns %} + + {% endif %} + +{% endmacro %} + +{% macro extra() %} + {% if admin_view.can_create %} + + {% endif %} + {% if admin_view.can_edit %} + + {% endif %} +{% endmacro %} diff --git a/advlabdb/templates/admin/master.html b/advlabdb/templates/admin/master.html new file mode 100644 index 0000000..8f27dad --- /dev/null +++ b/advlabdb/templates/admin/master.html @@ -0,0 +1 @@ +{% extends admin_base_template %} diff --git a/advlabdb/templates/admin/model/create.html b/advlabdb/templates/admin/model/create.html new file mode 100644 index 0000000..9e0834e --- /dev/null +++ b/advlabdb/templates/admin/model/create.html @@ -0,0 +1,30 @@ +{% extends 'admin/master.html' %} +{% import 'admin/lib.html' as lib with context %} +{% from 'admin/lib.html' import extra with context %} {# backward compatible #} + +{% block head %} + {{ super() }} + {{ lib.form_css() }} +{% endblock %} + +{% block body %} + {% block navlinks %} + + {% endblock %} + + {% block create_form %} + {{ lib.render_form(form, return_url, extra(), form_opts) }} + {% endblock %} +{% endblock %} + +{% block tail %} + {{ super() }} + {{ lib.form_js() }} +{% endblock %} diff --git a/advlabdb/templates/admin/model/details.html b/advlabdb/templates/admin/model/details.html new file mode 100644 index 0000000..0008c5a --- /dev/null +++ b/advlabdb/templates/admin/model/details.html @@ -0,0 +1,52 @@ +{% extends 'admin/master.html' %} +{% import 'admin/lib.html' as lib with context %} + +{% block body %} + {% block navlinks %} + + {% endblock %} + + {% block details_search %} +
    + {{ _gettext('Filter') }} + +
    + {% endblock %} + + {% block details_table %} + + {% for c, name in details_columns %} + + + + + {% endfor %} +
    + {{ name }} + + {{ get_value(model, c) }} +
    + {% endblock %} +{% endblock %} + +{% block tail %} + {{ super() }} + +{% endblock %} diff --git a/advlabdb/templates/admin/model/edit.html b/advlabdb/templates/admin/model/edit.html new file mode 100644 index 0000000..5bd4099 --- /dev/null +++ b/advlabdb/templates/admin/model/edit.html @@ -0,0 +1,40 @@ +{% extends 'admin/master.html' %} +{% import 'admin/lib.html' as lib with context %} +{% from 'admin/lib.html' import extra with context %} {# backward compatible #} + +{% block head %} + {{ super() }} + {{ lib.form_css() }} +{% endblock %} + +{% block body %} + {% block navlinks %} + + {% endblock %} + + {% block edit_form %} + {{ lib.render_form(form, return_url, extra(), form_opts) }} + {% endblock %} +{% endblock %} + +{% block tail %} + {{ super() }} + {{ lib.form_js() }} +{% endblock %} diff --git a/advlabdb/templates/admin/model/inline_field_list.html b/advlabdb/templates/admin/model/inline_field_list.html new file mode 100644 index 0000000..b19dc2e --- /dev/null +++ b/advlabdb/templates/admin/model/inline_field_list.html @@ -0,0 +1,15 @@ +{% import 'admin/model/inline_list_base.html' as base with context %} + +{% macro render_field(field) %} + {{ field }} + + {% if h.is_field_error(field.errors) %} +
      + {% for e in field.errors if e is string %} +
    • {{ e }}
    • + {% endfor %} +
    + {% endif %} +{% endmacro %} + +{{ base.render_inline_fields(field, template, render_field, check) }} diff --git a/advlabdb/templates/admin/model/inline_form.html b/advlabdb/templates/admin/model/inline_form.html new file mode 100644 index 0000000..6ae3f6c --- /dev/null +++ b/advlabdb/templates/admin/model/inline_form.html @@ -0,0 +1,4 @@ +{% import 'admin/lib.html' as lib with context %} +
    + {{ lib.render_form_fields(field.form, form_opts=form_opts) }} +
    diff --git a/advlabdb/templates/admin/model/inline_list_base.html b/advlabdb/templates/admin/model/inline_list_base.html new file mode 100644 index 0000000..79a93db --- /dev/null +++ b/advlabdb/templates/admin/model/inline_list_base.html @@ -0,0 +1,45 @@ +{% macro render_inline_fields(field, template, render, check=None) %} +
    + {# existing inline form fields #} +
    + {% for subfield in field %} +
    + {%- if not check or check(subfield) %} + + + {{ field.label.text }} #{{ loop.index }} +
    + {% if subfield.get_pk and subfield.get_pk() %} + + + {% else %} + + {% endif %} +
    +
    +
    +
    + {%- endif -%} + {{ render(subfield) }} +
    + {% endfor %} +
    + + {# template for new inline form fields #} +
    + {% filter forceescape %} +
    + + {{ _gettext('New') }} {{ field.label.text }} +
    + +
    +
    +
    + {{ render(template) }} +
    + {% endfilter %} +
    + {{ _gettext('Add') }} {{ field.label.text }} +
    +{% endmacro %} diff --git a/advlabdb/templates/admin/model/layout.html b/advlabdb/templates/admin/model/layout.html new file mode 100644 index 0000000..792eb5b --- /dev/null +++ b/advlabdb/templates/admin/model/layout.html @@ -0,0 +1,107 @@ +{% macro filter_options(btn_class='dropdown-toggle') %} + + {{ _gettext('Add Filter') }} + + +{% endmacro %} + +{% macro export_options(btn_class='dropdown-toggle') %} + {% if admin_view.export_types|length > 1 %} + + {% else %} +
  • + {{ _gettext('Export') }} +
  • + {% endif %} +{% endmacro %} + +{% macro filter_form() %} +
    + {% for arg_name, arg_value in extra_args.items() %} + + {% endfor %} + {% if sort_column is not none %} + + {% endif %} + {% if sort_desc %} + + {% endif %} + {% if search %} + + {% endif %} + {% if page_size != default_page_size %} + + {% endif %} +
    + + {% if active_filters %} + {{ _gettext('Reset Filters') }} + {% endif %} +
    + +
    +
    +
    +{% endmacro %} + +{% macro search_form(input_class=None) %} + +{% endmacro %} + +{% macro page_size_form(generator, btn_class='dropdown-toggle') %} + + {{ page_size }} {{ _gettext('items') }} + + +{% endmacro %} diff --git a/advlabdb/templates/admin/model/list.html b/advlabdb/templates/admin/model/list.html new file mode 100755 index 0000000..08c1d57 --- /dev/null +++ b/advlabdb/templates/admin/model/list.html @@ -0,0 +1,197 @@ +{% extends 'admin/master.html' %} +{% import 'admin/lib.html' as lib with context %} +{% import 'admin/static.html' as admin_static with context%} +{% import 'admin/model/layout.html' as model_layout with context %} +{% import 'admin/actions.html' as actionlib with context %} +{% import 'admin/model/row_actions.html' as row_actions with context %} + +{% block head %} + {{ super() }} + {{ lib.form_css() }} +{% endblock %} + +{% block body %} + {% block model_menu_bar %} + + {% endblock %} + + {% if filters %} + {{ model_layout.filter_form() }} +
    + {% endif %} + + {% block model_list_table %} +
    + + + + {% block list_header scoped %} + {% if actions %} + + {% endif %} + {% block list_row_actions_header %} + {% if admin_view.column_display_actions %} + + {% endif %} + {% endblock %} + {% for c, name in list_columns %} + {% set column = loop.index0 %} + + {% endfor %} + {% endblock %} + + + {% for row in data %} + + {% block list_row scoped %} + {% if actions %} + + {% endif %} + {% block list_row_actions_column scoped %} + {% if admin_view.column_display_actions %} + + {%- endif -%} + {% endblock %} + + {% for c, name in list_columns %} + + {% endfor %} + {% endblock %} + + {% else %} + + + + {% endfor %} +
    + +   + {% if admin_view.is_sortable(c) %} + {% if sort_column == column %} + + {{ name }} + {% if sort_desc %} + + {% else %} + + {% endif %} + + {% else %} + {{ name }} + {% endif %} + {% else %} + {{ name }} + {% endif %} + {% if admin_view.column_descriptions.get(c) %} + + {% endif %} +
    + + + {% block list_row_actions scoped %} + {% for action in list_row_actions %} + {{ action.render_ctx(get_pk_value(row), row) }} + {% endfor %} + {% endblock %} + + {% if admin_view.is_editable(c) %} + {% set form = list_forms[get_pk_value(row)] %} + {% if form.csrf_token %} + {{ form[c](pk=get_pk_value(row), display_value=get_value(row, c), csrf=form.csrf_token._value()) }} + {% elif csrf_token %} + {{ form[c](pk=get_pk_value(row), display_value=get_value(row, c), csrf=csrf_token()) }} + {% else %} + {{ form[c](pk=get_pk_value(row), display_value=get_value(row, c)) }} + {% endif %} + {% else %} + {{ get_value(row, c) }} + {% endif %} +
    + {% block empty_list_message %} +
    + {{ admin_view.get_empty_list_message() }} +
    + {% endblock %} +
    +
    + {% block list_pager %} + {% if num_pages is not none %} + {{ lib.pager(page, num_pages, pager_url) }} + {% else %} + {{ lib.simple_pager(page, data|length == page_size, pager_url) }} + {% endif %} + {% endblock %} + {% endblock %} + + {% block actions %} + {{ actionlib.form(actions, get_url('.action_view')) }} + {% endblock %} + + {%- if admin_view.edit_modal or admin_view.create_modal or admin_view.details_modal -%} + {{ lib.add_modal_window() }} + {%- endif -%} +{% endblock %} + +{% block tail %} + {{ super() }} + + {% if filter_groups %} + + + {% endif %} + + {{ lib.form_js() }} + + + {{ actionlib.script(_gettext('Please select at least one record.'), + actions, + actions_confirmation) }} +{% endblock %} diff --git a/advlabdb/templates/admin/model/modals/create.html b/advlabdb/templates/admin/model/modals/create.html new file mode 100644 index 0000000..abc1cf5 --- /dev/null +++ b/advlabdb/templates/admin/model/modals/create.html @@ -0,0 +1,24 @@ +{% import 'admin/static.html' as admin_static with context%} +{% import 'admin/lib.html' as lib with context %} + +{# store the jinja2 context for form_rules rendering logic #} +{% set render_ctx = h.resolve_ctx() %} + +{% block body %} + + +{% endblock %} + +{% block tail %} + +{% endblock %} diff --git a/advlabdb/templates/admin/model/modals/details.html b/advlabdb/templates/admin/model/modals/details.html new file mode 100755 index 0000000..9abb55d --- /dev/null +++ b/advlabdb/templates/admin/model/modals/details.html @@ -0,0 +1,40 @@ +{% import 'admin/static.html' as admin_static with context%} +{% import 'admin/lib.html' as lib with context %} + +{% block body %} + + + +{% endblock %} + +{% block tail %} + + +{% endblock %} diff --git a/advlabdb/templates/admin/model/modals/edit.html b/advlabdb/templates/admin/model/modals/edit.html new file mode 100644 index 0000000..8897810 --- /dev/null +++ b/advlabdb/templates/admin/model/modals/edit.html @@ -0,0 +1,26 @@ +{% import 'admin/static.html' as admin_static with context%} +{% import 'admin/lib.html' as lib with context %} + +{# store the jinja2 context for form_rules rendering logic #} +{% set render_ctx = h.resolve_ctx() %} + +{% block body %} + + +{% endblock %} + +{% block tail %} + +{% endblock %} diff --git a/advlabdb/templates/admin/model/row_actions.html b/advlabdb/templates/admin/model/row_actions.html new file mode 100644 index 0000000..74d65ca --- /dev/null +++ b/advlabdb/templates/admin/model/row_actions.html @@ -0,0 +1,38 @@ +{% import 'admin/lib.html' as lib with context %} + +{% macro link(action, url, icon_class=None) %} + + + +{% endmacro %} + +{% macro view_row(action, row_id, row) %} + {{ link(action, get_url('.details_view', id=row_id, url=return_url), 'fa fa-eye glyphicon glyphicon-eye-open') }} +{% endmacro %} + +{% macro view_row_popup(action, row_id, row) %} + {{ lib.add_modal_button(url=get_url('.details_view', id=row_id, url=return_url, modal=True), title=action.title, content='') }} +{% endmacro %} + +{% macro edit_row(action, row_id, row) %} + {{ link(action, get_url('.edit_view', id=row_id, url=return_url), 'fa fa-pencil glyphicon glyphicon-pencil') }} +{% endmacro %} + +{% macro edit_row_popup(action, row_id, row) %} + {{ lib.add_modal_button(url=get_url('.edit_view', id=row_id, url=return_url, modal=True), title=action.title, content='') }} +{% endmacro %} + +{% macro delete_row(action, row_id, row) %} +
    + {{ delete_form.id(value=get_pk_value(row)) }} + {{ delete_form.url(value=return_url) }} + {% if delete_form.csrf_token %} + {{ delete_form.csrf_token }} + {% elif csrf_token %} + + {% endif %} + +
    +{% endmacro %} diff --git a/advlabdb/templates/admin/rediscli/console.html b/advlabdb/templates/admin/rediscli/console.html new file mode 100644 index 0000000..368f55d --- /dev/null +++ b/advlabdb/templates/admin/rediscli/console.html @@ -0,0 +1,27 @@ +{% extends 'admin/master.html' %} +{% import 'admin/lib.html' as lib with context %} +{% import 'admin/static.html' as admin_static with context%} + +{% block head %} + {{ super() }} + +{% endblock %} + +{% block body %} +
    +
    +
    +
    +
    + +
    +
    +
    +{% endblock %} + +{% block tail %} + {{ super() }} + + + +{% endblock %} diff --git a/advlabdb/templates/admin/rediscli/response.html b/advlabdb/templates/admin/rediscli/response.html new file mode 100644 index 0000000..f4a950a --- /dev/null +++ b/advlabdb/templates/admin/rediscli/response.html @@ -0,0 +1,32 @@ +{% macro render(item, depth=0) %} + {% set type = type_name(item) %} + + {% if type == 'tuple' or type == 'list' %} + {% if not item %} + Empty {{ type }}. + {% else %} + {% for n in item %} + {{ loop.index }}) {{ render(n, depth + 1) }}
    + {% endfor %} + {% endif %} + {% elif type == 'bool' %} + {% if depth == 0 and item %} + OK + {% else %} + {{ item }} + {% endif %} + {% elif type == 'str' or type == 'unicode' %} + "{{ item }}" + {% elif type == 'bytes' %} + "{{ item.decode('utf-8') }}" + {% elif type == 'TextWrapper' %} +
    {{ item }}
    + {% elif type == 'dict' %} + {% for k, v in item.items() %} + {{ loop.index }}) {{ k }} - {{ render(v, depth + 1) }}
    + {% endfor %} + {% else %} + {{ item }} + {% endif %} +{% endmacro %} +{{ render(result) }} \ No newline at end of file diff --git a/advlabdb/templates/admin/static.html b/advlabdb/templates/admin/static.html new file mode 100644 index 0000000..de632ee --- /dev/null +++ b/advlabdb/templates/admin/static.html @@ -0,0 +1,3 @@ +{% macro url() -%} + {{ get_url('{admin_endpoint}.static'.format(admin_endpoint=admin_view.admin.endpoint), *varargs, **kwargs) }} +{%- endmacro %} diff --git a/advlabdb/templates/admin_create.html b/advlabdb/templates/admin_create.html new file mode 100644 index 0000000..3d03b5d --- /dev/null +++ b/advlabdb/templates/admin_create.html @@ -0,0 +1,6 @@ +{% extends "admin/model/create.html" %} + +{% block body %} + User's active semester: {{userActiveSemester().label}} + {{super()}} +{% endblock %} diff --git a/advlabdb/templates/admin_edit.html b/advlabdb/templates/admin_edit.html new file mode 100644 index 0000000..86bc81f --- /dev/null +++ b/advlabdb/templates/admin_edit.html @@ -0,0 +1,6 @@ +{% extends "admin/model/edit.html" %} + +{% block body %} + User's active semester: {{userActiveSemester().label}} + {{super()}} +{% endblock %} diff --git a/advlabdb/templates/admin_list.html b/advlabdb/templates/admin_list.html new file mode 100644 index 0000000..609b1d8 --- /dev/null +++ b/advlabdb/templates/admin_list.html @@ -0,0 +1,6 @@ +{% extends "admin/model/list.html" %} + +{% block body %} + User's active semester: {{userActiveSemester(flashWarning=True).label}} + {{super()}} +{% endblock %}