From e52b6b0e231573bfa4a972234651190d8b5581f8 Mon Sep 17 00:00:00 2001 From: Frank Sauerburger <frank@sauerburger.com> Date: Tue, 5 Jan 2021 21:10:53 +0100 Subject: [PATCH] Improve design of remaining views --- uhepp_org/uhepp_org/settings.py | 2 + .../templates/registration/login.html | 7 +++ .../collection_confirm_delete.html | 16 +++-- .../uhepp_vault/collection_list.html | 1 - .../templates/uhepp_vault/logout.html | 17 +++++- .../templates/uhepp_vault/plot_list.html | 1 - .../templates/uhepp_vault/profile_list.html | 1 - .../uhepp_vault/token_confirm_delete.html | 15 +++-- .../templates/uhepp_vault/token_form.html | 19 ++++-- .../templates/uhepp_vault/token_list.html | 59 ++++++++++++++----- 10 files changed, 103 insertions(+), 35 deletions(-) diff --git a/uhepp_org/uhepp_org/settings.py b/uhepp_org/uhepp_org/settings.py index ca69151..ac8e75d 100644 --- a/uhepp_org/uhepp_org/settings.py +++ b/uhepp_org/uhepp_org/settings.py @@ -198,3 +198,5 @@ USE_TZ = True # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_URL = '/static/' + +DATETIME_INPUT_FORMATS = '%Y-%m-%d %H:%M' diff --git a/uhepp_org/uhepp_vault/templates/registration/login.html b/uhepp_org/uhepp_vault/templates/registration/login.html index db67857..ce44275 100644 --- a/uhepp_org/uhepp_vault/templates/registration/login.html +++ b/uhepp_org/uhepp_vault/templates/registration/login.html @@ -3,6 +3,13 @@ {% block content %} +<nav aria-label="breadcrumb" class="d-none d-sm-block"> + <ol class="breadcrumb my-2"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item active"><a href="/login">Login</a></li> + </ol> +</nav> + <h1>Login</h1> <div class="row"> diff --git a/uhepp_org/uhepp_vault/templates/uhepp_vault/collection_confirm_delete.html b/uhepp_org/uhepp_vault/templates/uhepp_vault/collection_confirm_delete.html index 1a6fb89..f61bea5 100644 --- a/uhepp_org/uhepp_vault/templates/uhepp_vault/collection_confirm_delete.html +++ b/uhepp_org/uhepp_vault/templates/uhepp_vault/collection_confirm_delete.html @@ -1,13 +1,21 @@ {% extends 'uhepp_vault/base.html' %} {% block content %} -<h2>Delete collection</h2> +<nav aria-label="breadcrumb" class="d-none d-sm-block"> + <ol class="breadcrumb my-2"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="{% url 'uhepp_vault:user-detail' collection.owner.username %}">{{ collection.owner }}</a></li> + <li class="breadcrumb-item active"><a href="{% url 'uhepp_vault:collection-detail' collection.id %}">{{ collection.title }}</a></li> + </ol> +</nav> -<a href="{% url 'uhepp_vault:user-detail' request.user.username %}">Back to profile</a> +<h1>Delete collection</h1> <form method="post">{% csrf_token %} - <p>Are you sure you want to delete collection "{{ collection.title }}"?</p> - <input type="submit" value="Delete"> + <p>Are you sure you want to delete collection <b>{{ collection.title }}</b>? + Deleting the collection will also delete <span class="badge badge-primary + badge-pill">{{ collection.plots.count }}</span> plots.</p> + <button type="submit" class="btn btn-outline-danger">Delete</button> </form> {% endblock %} diff --git a/uhepp_org/uhepp_vault/templates/uhepp_vault/collection_list.html b/uhepp_org/uhepp_vault/templates/uhepp_vault/collection_list.html index 77d2cce..fad959e 100644 --- a/uhepp_org/uhepp_vault/templates/uhepp_vault/collection_list.html +++ b/uhepp_org/uhepp_vault/templates/uhepp_vault/collection_list.html @@ -4,7 +4,6 @@ <nav aria-label="breadcrumb"> <ol class="breadcrumb my-2"> <li class="breadcrumb-item"><a href="/">Home</a></li> - <li class="breadcrumb-item">Explore</li> <li class="breadcrumb-item active"><a class="active" href="{% url 'uhepp_vault:collection-list' %}">Collections</a></li> </ol> </nav> diff --git a/uhepp_org/uhepp_vault/templates/uhepp_vault/logout.html b/uhepp_org/uhepp_vault/templates/uhepp_vault/logout.html index 226c6be..d2cd33c 100644 --- a/uhepp_org/uhepp_vault/templates/uhepp_vault/logout.html +++ b/uhepp_org/uhepp_vault/templates/uhepp_vault/logout.html @@ -2,8 +2,21 @@ {% load pygmentify_tags %} {% block content %} -<h1>Logout</h2> +<nav aria-label="breadcrumb" class="d-none d-sm-block"> + <ol class="breadcrumb my-2"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item active"><a href="{% url 'uhepp_vault:logout' %}">Logout</a></li> + </ol> +</nav> + +<h1>Logout</h1> + <form action="{% url 'oidc_logout' %}" method="post"> {% csrf_token %} - <input type="submit" value="logout"> + <p>Do you really want to log out?</p> + <button class="btn btn-primary" type="submit">Log out</button> + <p class="text-muted"><small>Please note, this will only end your session + on uhepp.org. Your + access tokens or sessions on other CERN services will remain + active.</small></p> </form> {% endblock %} diff --git a/uhepp_org/uhepp_vault/templates/uhepp_vault/plot_list.html b/uhepp_org/uhepp_vault/templates/uhepp_vault/plot_list.html index d11a8fb..4b05942 100644 --- a/uhepp_org/uhepp_vault/templates/uhepp_vault/plot_list.html +++ b/uhepp_org/uhepp_vault/templates/uhepp_vault/plot_list.html @@ -4,7 +4,6 @@ <nav aria-label="breadcrumb"> <ol class="breadcrumb my-2"> <li class="breadcrumb-item"><a href="/">Home</a></li> - <li class="breadcrumb-item">Explore</li> <li class="breadcrumb-item active"><a class="active" href="{% url 'uhepp_vault:plot-list' %}">Plots</a></li> </ol> </nav> diff --git a/uhepp_org/uhepp_vault/templates/uhepp_vault/profile_list.html b/uhepp_org/uhepp_vault/templates/uhepp_vault/profile_list.html index 8024631..0c51013 100644 --- a/uhepp_org/uhepp_vault/templates/uhepp_vault/profile_list.html +++ b/uhepp_org/uhepp_vault/templates/uhepp_vault/profile_list.html @@ -4,7 +4,6 @@ <nav aria-label="breadcrumb"> <ol class="breadcrumb my-2"> <li class="breadcrumb-item"><a href="/">Home</a></li> - <li class="breadcrumb-item">Explore</li> <li class="breadcrumb-item active"><a class="active" href="{% url 'uhepp_vault:user-list' %}">Users</a></li> </ol> </nav> diff --git a/uhepp_org/uhepp_vault/templates/uhepp_vault/token_confirm_delete.html b/uhepp_org/uhepp_vault/templates/uhepp_vault/token_confirm_delete.html index eac72cb..5bc8fe1 100644 --- a/uhepp_org/uhepp_vault/templates/uhepp_vault/token_confirm_delete.html +++ b/uhepp_org/uhepp_vault/templates/uhepp_vault/token_confirm_delete.html @@ -1,13 +1,18 @@ {% extends 'uhepp_vault/base.html' %} {% block content %} -<h2>API access tokens</h2> - -<a href="{% url 'uhepp_vault:token-list' %}">Back to token list</a> +<nav aria-label="breadcrumb" class="d-none d-sm-block"> + <ol class="breadcrumb my-2"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="{% url 'uhepp_vault:token-list' %}">API access tokens</a></li> + </ol> +</nav> +<h1>API access tokens</h1> <form method="post">{% csrf_token %} - <p>Are you sure you want to delete token "{{ token.description }}"?</p> - <input type="submit" value="Delete"> + <p>Are you sure you want to delete token <b>{{ token.description }}</b>? + Access to the API won't be possible with this token.</p> + <button class="btn btn-outline-danger" type="submit">Yes, delete the token</button> </form> {% endblock %} diff --git a/uhepp_org/uhepp_vault/templates/uhepp_vault/token_form.html b/uhepp_org/uhepp_vault/templates/uhepp_vault/token_form.html index 32eeea7..c283174 100644 --- a/uhepp_org/uhepp_vault/templates/uhepp_vault/token_form.html +++ b/uhepp_org/uhepp_vault/templates/uhepp_vault/token_form.html @@ -1,13 +1,22 @@ {% extends 'uhepp_vault/base.html' %} {% load pygmentify_tags %} +{% load crispy_forms_tags %} {% block content %} -<h2>API access tokens</h2> +<nav aria-label="breadcrumb" class="d-none d-sm-block"> + <ol class="breadcrumb my-2"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="{% url 'uhepp_vault:token-list' %}">API access tokens</a></li> + </ol> +</nav> -<a href="{% url 'uhepp_vault:token-list' %}">Back to token list</a> +<h1>API access tokens</h1> {% if token %} -<p>New token is: {{ token.key }}</p> +<div class="alert alert-success"> + <p>Your brand new token is: <code class="text-dark">{{ token.key }}</code></p> + <p>Keep the token secure and don't share it with anyone.</p> +</div> <p>In order to use the token to access the API, add the following code to your environment.</p> @@ -20,8 +29,8 @@ export UHEPP_TOKEN={{ token.key }} {% else %} <form method="post">{% csrf_token %} - {{ form }} - <input type="submit" value="Save"> + {{ form|crispy }} + <button type="submit" class="btn btn-primary">Save</button> </form> {% endif %} {% endblock %} diff --git a/uhepp_org/uhepp_vault/templates/uhepp_vault/token_list.html b/uhepp_org/uhepp_vault/templates/uhepp_vault/token_list.html index c1aba8b..bc6adf4 100644 --- a/uhepp_org/uhepp_vault/templates/uhepp_vault/token_list.html +++ b/uhepp_org/uhepp_vault/templates/uhepp_vault/token_list.html @@ -1,27 +1,54 @@ {% extends 'uhepp_vault/base.html' %} {% block content %} -<h2>API access tokens</h2> +<nav aria-label="breadcrumb" class="d-none d-sm-block"> + <ol class="breadcrumb my-2"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="{% url 'uhepp_vault:token-list' %}">API access tokens</a></li> + </ol> +</nav> -<a href="{% url 'uhepp_vault:token-create' %}">Create a new token</a> +<h1 class="controls-head"> + <span>API access tokens</span> + <span> + <a class="btn btn-outline-primary" href="{% url 'uhepp_vault:token-create' %}"> + <i class="fas fa-plus"></i> + </a> + </span> +</h1> + + +<p>API tokens let you access uhepp hub from Python or the command-line. The +token is used to authenticate you. This way, you don't need to expose your CERN +password in environment variables.</p> {% if token_list %} - <ul> +<table class="table table-bordered table-striped"> + <thead class="thead-light"> + <tr> + <th scope="col">Comment</th> + <th scope="col">Created</th> + <th scope="col">Expires</th> + <th scope="col"></th> + </tr> + </thead> {% for token in token_list %} - <li> - <b>{{ token.description }}</b><br /> - Created: {{ token.created }}<br /> - {% if token.expires %} - {% if token.expired %} - <b>Expired</b>: {{ token.expires }}<br /> - {% else %} - Expires: {{ token.expires }}<br /> - {% endif %} - {% endif %} - <a href="{% url 'uhepp_vault:token-delete' token.pk %}">Delete</a> - </li> + <tr> + <th scope="row">{{ token.description }}</th> + <td>{{ token.created|date:"Y-m-d H:i" }}</td> + <td> + {{ token.expires|default_if_none:"never" }} + {% if token.expired %} + <small class="text-danger">(Expired)</small> + {% endif %} + </td> + <td> + <a class="text-danger" href="{% url 'uhepp_vault:token-delete' token.pk %}"><i class="fas fa-trash"></i></a> + </td> + </tr> {% endfor %} - </ul> + </tbody> +</table> {% else %} <p>You don't have any tokens.</p> {% endif %} -- GitLab