From b840746fed7659956654d9fb663c5fd7b58a39c5 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Fri, 23 Oct 2020 10:17:14 +0200 Subject: [PATCH 1/9] Rework admin package --- web/app/admin/views.py | 20 +++--- web/app/static/js/nopaque.lists.js | 4 +- web/app/templates/admin/edit_user.html.j2 | 46 +++++++------ web/app/templates/admin/index.html.j2 | 42 ------------ web/app/templates/admin/user.html.j2 | 80 +++++++++++++---------- web/app/templates/admin/users.html.j2 | 48 ++++++++++++++ web/app/templates/main/news.html.j2 | 1 + web/app/templates/nopaque.html.j2 | 2 +- 8 files changed, 132 insertions(+), 111 deletions(-) delete mode 100644 web/app/templates/admin/index.html.j2 create mode 100644 web/app/templates/admin/users.html.j2 diff --git a/web/app/admin/views.py b/web/app/admin/views.py index e8d0d916..3046a63c 100644 --- a/web/app/admin/views.py +++ b/web/app/admin/views.py @@ -8,10 +8,10 @@ from ..models import Role, User from ..profile import tasks as profile_tasks -@admin.route('/') +@admin.route('/users') @login_required @admin_required -def index(): +def users(): users = User.query.all() users = [dict(username=u.username, email=u.email, @@ -19,21 +19,18 @@ def index(): confirmed=u.confirmed, id=u.id) for u in users] - return render_template('admin/index.html.j2', - title='Administration tools', - users=users) + return render_template('admin/users.html.j2', title='Users', users=users) -@admin.route('/user/') +@admin.route('/users/') @login_required @admin_required def user(user_id): user = User.query.get_or_404(user_id) - return render_template('admin/user.html.j2', title='Administration: User', - user=user) + return render_template('admin/user.html.j2', title='Edit user', user=user) -@admin.route('/user//delete') +@admin.route('/users//delete') @login_required @admin_required def delete_user(user_id): @@ -42,7 +39,7 @@ def delete_user(user_id): return redirect(url_for('admin.index')) -@admin.route('/user//edit', methods=['GET', 'POST']) +@admin.route('/users//edit', methods=['GET', 'POST']) @login_required @admin_required def edit_user(user_id): @@ -63,4 +60,5 @@ def edit_user(user_id): edit_user_form.role.data = user.role_id return render_template('admin/edit_user.html.j2', edit_user_form=edit_user_form, - title='Administration: Edit user', user=user) + title='Edit user', + user=user) diff --git a/web/app/static/js/nopaque.lists.js b/web/app/static/js/nopaque.lists.js index d91186dc..603f81b1 100644 --- a/web/app/static/js/nopaque.lists.js +++ b/web/app/static/js/nopaque.lists.js @@ -131,11 +131,11 @@ RessourceList.dataMappers = { confirmed: user.confirmed, email: user.email, id: user.id, - link: `user/${user.id}`, + link: `users/${user.id}`, role_id: user.role_id, username: user.username, username2: user.username, - "delete-link": `/admin/user/${user.id}/delete`, + "delete-link": `/admin/users/${user.id}/delete`, "delete-modal": `delete-user-${user.id}-modal`, "delete-modal-trigger": `delete-user-${user.id}-modal`, }), diff --git a/web/app/templates/admin/edit_user.html.j2 b/web/app/templates/admin/edit_user.html.j2 index 3a48adf8..6e47db5f 100644 --- a/web/app/templates/admin/edit_user.html.j2 +++ b/web/app/templates/admin/edit_user.html.j2 @@ -1,27 +1,35 @@ {% extends "nopaque.html.j2" %} +{% import 'materialize/wtf.html.j2' as wtf %} {% block page_content %} -
-

{{ user.username }}

-

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,

- arrow_backBack to user administration -
+
+
+
+

Edit user

+
-
-
-
-
- {{ edit_user_form.hidden_tag() }} - {{ M.render_field(edit_user_form.username, data_length='64', material_icon='account_circle') }} - {{ M.render_field(edit_user_form.email, class_='validate', material_icon='email', type='email') }} - {{ M.render_field(edit_user_form.role, material_icon='swap_vert') }} - {{ M.render_field(edit_user_form.confirmed, material_icon='check') }} +
+

{{ user.username }}

+

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,

+ arrow_backBack to user administration +
+ +
+
+ +
+ {{ edit_user_form.hidden_tag() }} + {{ wtf.render_field(edit_user_form.username, data_length='64', material_icon='account_circle') }} + {{ wtf.render_field(edit_user_form.email, class_='validate', material_icon='email', type='email') }} + {{ wtf.render_field(edit_user_form.role, material_icon='swap_vert') }} + {{ wtf.render_field(edit_user_form.confirmed, material_icon='check') }} +
+
+ {{ wtf.render_field(edit_user_form.submit, material_icon='send') }} +
+
-
- {{ M.render_field(edit_user_form.submit, material_icon='send') }} -
- +
- {% endblock %} diff --git a/web/app/templates/admin/index.html.j2 b/web/app/templates/admin/index.html.j2 deleted file mode 100644 index 9fca5b58..00000000 --- a/web/app/templates/admin/index.html.j2 +++ /dev/null @@ -1,42 +0,0 @@ -{% extends "nopaque.html.j2" %} - -{% set full_width = True %} - -{% block page_content %} -
-
-
- User list -
- search - - -
-
    - - - - - - - - - - - - - -
    UsernameEmailRoleConfirmed StatusId{# Actions #}
    -
      -
      -
      -
      - - -{% endblock %} diff --git a/web/app/templates/admin/user.html.j2 b/web/app/templates/admin/user.html.j2 index c1e53a18..c66d1fdc 100644 --- a/web/app/templates/admin/user.html.j2 +++ b/web/app/templates/admin/user.html.j2 @@ -1,34 +1,40 @@ {% extends "nopaque.html.j2" %} {% block page_content %} -
      -

      {{ user.username }}

      -

      Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,

      - arrow_backBack to admin board -
      +
      +
      +
      +

      {{ title }}

      +
      -
      -
      -
      - User information -
        -
      • Username: {{ user.username }}
      • -
      • Email: {{ user.email }}
      • -
      • ID: {{ user.id }}
      • -
      • Member since: {{ user.member_since.strftime('%m/%d/%Y, %H:%M:%S %p') }}
      • -
      • Confirmed status: {{ user.confirmed }}
      • -
      • Last seen: {{ user.last_seen.strftime('%m/%d/%Y, %H:%M:%S %p') }}
      • -
      • Role ID: {{ user.role_id }}
      • -
      • Permissions as Int: {{ user.role.permissions }}
      • -
      • Role name: {{ user.role.name }}
      • -
      +
      +

      {{ user.username }}

      +

      Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,

      + arrow_backBack to Users
      -
      - editEdit - deleteDelete + +
      +
      +
      + User information +
        +
      • Username: {{ user.username }}
      • +
      • Email: {{ user.email }}
      • +
      • ID: {{ user.id }}
      • +
      • Member since: {{ user.member_since.strftime('%m/%d/%Y, %H:%M:%S %p') }}
      • +
      • Confirmed status: {{ user.confirmed }}
      • +
      • Last seen: {{ user.last_seen.strftime('%m/%d/%Y, %H:%M:%S %p') }}
      • +
      • Role ID: {{ user.role_id }}
      • +
      • Permissions as Int: {{ user.role.permissions }}
      • +
      • Role name: {{ user.role.name }}
      • +
      +
      + +
      -
      -

      Corpora

      @@ -92,21 +98,23 @@ - - {% endblock %} + + +{% block scripts %} +{{ super() }} + +{% endblock scripts %} diff --git a/web/app/templates/admin/users.html.j2 b/web/app/templates/admin/users.html.j2 new file mode 100644 index 00000000..022f7e5c --- /dev/null +++ b/web/app/templates/admin/users.html.j2 @@ -0,0 +1,48 @@ +{% extends "nopaque.html.j2" %} + +{% block page_content %} +
      +
      +
      +

      {{ title }}

      +
      + +
      +
      +
      +
      + search + + +
      +
        + + + + + + + + + + + + + +
        UsernameEmailRoleConfirmed StatusId{# Actions #}
        +
          +
          +
          +
          +
          +
          +{% endblock %} + +{% block scripts %} +{{ super() }} + +{% endblock scripts %} diff --git a/web/app/templates/main/news.html.j2 b/web/app/templates/main/news.html.j2 index cf3d9653..968e0f1b 100644 --- a/web/app/templates/main/news.html.j2 +++ b/web/app/templates/main/news.html.j2 @@ -6,6 +6,7 @@

          {{ title }}

          +
          diff --git a/web/app/templates/nopaque.html.j2 b/web/app/templates/nopaque.html.j2 index 0437c29a..c9097dd1 100644 --- a/web/app/templates/nopaque.html.j2 +++ b/web/app/templates/nopaque.html.j2 @@ -136,7 +136,7 @@ {% if current_user.is_administrator() %}
        • Administration
        • -
        • buildAdministration tools
        • +
        • buildAdministration tools
        • {% endif %} {% endblock sidenav %} From 780de62db22619582d6b1bffabd1a08862d00d9d Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Fri, 23 Oct 2020 10:26:04 +0200 Subject: [PATCH 2/9] Rework auth package --- web/app/templates/auth/login.html.j2 | 2 +- web/app/templates/auth/register.html.j2 | 2 +- web/app/templates/auth/reset_password.html.j2 | 4 ++-- web/app/templates/auth/reset_password_request.html.j2 | 2 +- web/app/templates/auth/unconfirmed.html.j2 | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web/app/templates/auth/login.html.j2 b/web/app/templates/auth/login.html.j2 index a477da4f..657da25f 100644 --- a/web/app/templates/auth/login.html.j2 +++ b/web/app/templates/auth/login.html.j2 @@ -18,7 +18,7 @@
          -

          {{ title }}

          +

          {{ title }}

          Want to boost your research and get going? nopaque is free and no download is needed. Register now!

          diff --git a/web/app/templates/auth/register.html.j2 b/web/app/templates/auth/register.html.j2 index db4ef2c0..9909cd60 100644 --- a/web/app/templates/auth/register.html.j2 +++ b/web/app/templates/auth/register.html.j2 @@ -18,7 +18,7 @@
          -

          Register

          +

          {{ title }}

          Simply enter a username and password to receive your registration email. After that you can start right away.

          It goes without saying that the General Data Protection Regulation applies, only necessary data is stored.

          Please also read our terms of use before signing up for nopaque!

          diff --git a/web/app/templates/auth/reset_password.html.j2 b/web/app/templates/auth/reset_password.html.j2 index 414a2d10..f3e4f26e 100644 --- a/web/app/templates/auth/reset_password.html.j2 +++ b/web/app/templates/auth/reset_password.html.j2 @@ -5,11 +5,11 @@
          -

          {{ title }}

          +

          {{ title }}

          -

          dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,

          +

          Enter a new password and confirm it! After that, the entered password is your new one!

          diff --git a/web/app/templates/auth/reset_password_request.html.j2 b/web/app/templates/auth/reset_password_request.html.j2 index 549af6cd..403f1388 100644 --- a/web/app/templates/auth/reset_password_request.html.j2 +++ b/web/app/templates/auth/reset_password_request.html.j2 @@ -5,7 +5,7 @@
          -

          {{ title }}

          +

          {{ title }}

          diff --git a/web/app/templates/auth/unconfirmed.html.j2 b/web/app/templates/auth/unconfirmed.html.j2 index 98ce4de4..613c51a4 100644 --- a/web/app/templates/auth/unconfirmed.html.j2 +++ b/web/app/templates/auth/unconfirmed.html.j2 @@ -4,7 +4,7 @@
          -

          {{ title }}

          +

          {{ title }}

          @@ -13,10 +13,10 @@ Hello, {{ current_user.username }}!

          You have not confirmed your account yet.

          Before you can access this site you need to confirm your account. Check your inbox, you should have received an email with a confirmation link.

          -

          Need another confirmation email? Click here

          +

          Need another confirmation email? Click the button below!

          From 310809cc51f81714261e42258ddbc8fc22b2549d Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Fri, 23 Oct 2020 10:26:36 +0200 Subject: [PATCH 3/9] Add missing title ids to admin pages --- web/app/templates/admin/user.html.j2 | 2 +- web/app/templates/admin/users.html.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/app/templates/admin/user.html.j2 b/web/app/templates/admin/user.html.j2 index c66d1fdc..81fc243a 100644 --- a/web/app/templates/admin/user.html.j2 +++ b/web/app/templates/admin/user.html.j2 @@ -4,7 +4,7 @@
          -

          {{ title }}

          +

          {{ title }}

          diff --git a/web/app/templates/admin/users.html.j2 b/web/app/templates/admin/users.html.j2 index 022f7e5c..539ce0f1 100644 --- a/web/app/templates/admin/users.html.j2 +++ b/web/app/templates/admin/users.html.j2 @@ -4,7 +4,7 @@
          -

          {{ title }}

          +

          {{ title }}

          From e14f397ec3d81a1be2d8912c8ed187f07913a6e4 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Fri, 23 Oct 2020 10:30:56 +0200 Subject: [PATCH 4/9] Rework error package --- web/app/templates/errors/403.html.j2 | 4 ++-- web/app/templates/errors/404.html.j2 | 4 ++-- web/app/templates/errors/413.html.j2 | 4 ++-- web/app/templates/errors/500.html.j2 | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web/app/templates/errors/403.html.j2 b/web/app/templates/errors/403.html.j2 index 7a4eca4e..0ebbea86 100644 --- a/web/app/templates/errors/403.html.j2 +++ b/web/app/templates/errors/403.html.j2 @@ -2,14 +2,14 @@ {% block page_content %}
          -

          {{ title }}

          +

          {{ title }}

          {{ request.path }}

          Alternatively, you can visit the Main Page or read more information about this type of error.