From be99a76829c7da1de1723c25cb7c02f3fcc408da Mon Sep 17 00:00:00 2001 From: Guillaume Bertholon Date: Sun, 22 Nov 2020 13:34:01 +0100 Subject: [PATCH] Simplify header and adapt auth pages style Having a title in the header is worse than a normal title inside the page. Restore the border to compensate. --- gestiojeux/urls.py | 3 +- gestiojeux_auth/admin.py | 3 - gestiojeux_auth/apps.py | 6 +- gestiojeux_auth/cas_backend.py | 1 - .../templates/registration/login.html | 16 +++ .../templates/registration/login_switch.html | 18 +++ gestiojeux_auth/tests.py | 3 - gestiojeux_auth/urls.py | 4 +- gestiojeux_auth/views.py | 13 ++- inventory/templates/inventory/game.html | 8 +- inventory/templates/inventory/inventory.html | 8 +- mainsite/scss/header.scss | 20 ++-- mainsite/scss/params.scss | 7 +- mainsite/scss/style.scss | 42 ++----- mainsite/static/css/style.css | 110 +++++++++--------- mainsite/templates/400.html | 2 +- mainsite/templates/403.html | 2 +- mainsite/templates/404.html | 2 +- mainsite/templates/500.html | 2 +- mainsite/templates/base.html | 7 +- mainsite/templates/login.html | 36 ------ mainsite/templates/login_switch.html | 33 ------ mainsite/templates/mainsite/home.html | 7 +- mainsite/templates/mainsite/login.html | 11 -- mainsite/templates/partials/head.html | 12 +- mainsite/templates/partials/header.html | 13 ++- mainsite/templates/small_page.html | 3 + 27 files changed, 155 insertions(+), 237 deletions(-) delete mode 100644 gestiojeux_auth/admin.py create mode 100644 gestiojeux_auth/templates/registration/login.html create mode 100644 gestiojeux_auth/templates/registration/login_switch.html delete mode 100644 gestiojeux_auth/tests.py delete mode 100644 mainsite/templates/login.html delete mode 100644 mainsite/templates/login_switch.html delete mode 100644 mainsite/templates/mainsite/login.html create mode 100644 mainsite/templates/small_page.html diff --git a/gestiojeux/urls.py b/gestiojeux/urls.py index 508755d..b0715b2 100644 --- a/gestiojeux/urls.py +++ b/gestiojeux/urls.py @@ -21,9 +21,8 @@ from django.conf.urls.static import static urlpatterns = [ path("admin/", admin.site.urls), path("inventory/", include("inventory.urls")), - path("accounts/", include("gestiojeux_auth.urls")), + path("auth/", include("gestiojeux_auth.urls")), path("", include("mainsite.urls")), - ] if settings.DEBUG: diff --git a/gestiojeux_auth/admin.py b/gestiojeux_auth/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/gestiojeux_auth/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/gestiojeux_auth/apps.py b/gestiojeux_auth/apps.py index 2da02b9..08fa15c 100644 --- a/gestiojeux_auth/apps.py +++ b/gestiojeux_auth/apps.py @@ -2,8 +2,4 @@ from django.apps import AppConfig class GestiojeuxAuthConfig(AppConfig): - name = 'gestiojeux_auth' - - def ready(self): - from . import signals - + name = "gestiojeux_auth" diff --git a/gestiojeux_auth/cas_backend.py b/gestiojeux_auth/cas_backend.py index eb590fc..fdb5c14 100644 --- a/gestiojeux_auth/cas_backend.py +++ b/gestiojeux_auth/cas_backend.py @@ -12,4 +12,3 @@ class GestioJeuxCASBackend(CASBackend): casUser = CasUser(user=user) casUser.save() return user - diff --git a/gestiojeux_auth/templates/registration/login.html b/gestiojeux_auth/templates/registration/login.html new file mode 100644 index 0000000..baa49f9 --- /dev/null +++ b/gestiojeux_auth/templates/registration/login.html @@ -0,0 +1,16 @@ +{% extends "small_page.html" %} + +{% block "title" %} +{% endblock %} + +{% block "content" %} +

Connexion par mot de passe

+ +
+ {% csrf_token %} + {{ form.as_p }} + + +
+{% endblock %} + diff --git a/gestiojeux_auth/templates/registration/login_switch.html b/gestiojeux_auth/templates/registration/login_switch.html new file mode 100644 index 0000000..3f154d5 --- /dev/null +++ b/gestiojeux_auth/templates/registration/login_switch.html @@ -0,0 +1,18 @@ +{% extends "small_page.html" %} + +{% block "content" %} +

Mode de connexion

+ +
+ + Compte clipper + + + + Mot de passe + +
+ +

Si vous êtes exté·e et que vous n'avez pas encore de compte, demandez en un.

+{% endblock %} + diff --git a/gestiojeux_auth/tests.py b/gestiojeux_auth/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/gestiojeux_auth/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/gestiojeux_auth/urls.py b/gestiojeux_auth/urls.py index ab03bc9..05a5d80 100644 --- a/gestiojeux_auth/urls.py +++ b/gestiojeux_auth/urls.py @@ -1,6 +1,6 @@ from django.urls import include, path import django.contrib.auth.views as dj_auth_views -from .views import login, logout +from .views import login, logout import django_cas_ng.views app_name = "gestiojeux_auth" @@ -23,5 +23,5 @@ accounts_patterns = [ ] urlpatterns = [ - path("", include(accounts_patterns)), + path("", include(accounts_patterns)), ] diff --git a/gestiojeux_auth/views.py b/gestiojeux_auth/views.py index e02b196..16b3ed6 100644 --- a/gestiojeux_auth/views.py +++ b/gestiojeux_auth/views.py @@ -30,7 +30,7 @@ def login(req): "cas_url": reverse("gestiojeux_auth:cas_ng_login"), } - return render(req, "login_switch.html", context=context) + return render(req, "registration/login_switch.html", context=context) @login_required @@ -38,6 +38,15 @@ def logout(req): CAS_BACKEND_NAME = "django_cas_ng.backends.CASBackend" if req.session["_auth_user_backend"] != CAS_BACKEND_NAME: auth_logout(req) + if "next" in req.GET: + return redirect(req.GET["next"]) return redirect("mainsite:home") - return redirect("gestiojeux_auth:cas_ng_logout") + if "next" in req.GET: + return redirect( + "{}?next={}".format( + reverse("gestiojeux_auth:cas_ng_logout"), + urlquote(req.GET["next"], safe=""), + ) + ) + return redirect("gestiojeux_auth:cas_ng_logout") diff --git a/inventory/templates/inventory/game.html b/inventory/templates/inventory/game.html index 92412a9..c5cf165 100644 --- a/inventory/templates/inventory/game.html +++ b/inventory/templates/inventory/game.html @@ -1,14 +1,12 @@ {% extends "base.html" %} -{% block "title" %} - Inventaire du club Jeux -{% endblock %} - {% block "content" %} -

{{ game.title }}

+

{{ game.title }}

+ {% if game.image %} {{ game.title }} + {% endif %}

{{ game.category }}

diff --git a/inventory/templates/inventory/inventory.html b/inventory/templates/inventory/inventory.html index 3962806..2b25794 100644 --- a/inventory/templates/inventory/inventory.html +++ b/inventory/templates/inventory/inventory.html @@ -1,14 +1,12 @@ {% extends "base.html" %} -{% block "title" %} - Inventaire du club Jeux -{% endblock %} - {% block "content" %} +

Inventaire du club Jeux

+ Il y a {{ game_list|length }} jeux en salle jeux : {% endblock %} diff --git a/mainsite/scss/header.scss b/mainsite/scss/header.scss index f941c3b..4642875 100644 --- a/mainsite/scss/header.scss +++ b/mainsite/scss/header.scss @@ -8,16 +8,13 @@ header { color: $header_text_color; padding: 0 30px; + border-bottom: 4px solid $header_border_color; + h1 { margin: 0; - a { - display: block; - - padding: 0 20px; - color: $header_text_color; - font-size: $font_size; - text-decoration: none; - } + padding: 0 20px; + color: $header_text_color; + font-size: $font_size; } nav { @@ -27,7 +24,7 @@ header { flex: 1 1 100px; } - nav a, a.login { + a { display: block; margin: 0; padding: 10px 20px; @@ -47,6 +44,11 @@ header { &:focus { background-color: darken($header_bg_color, 10%); box-shadow: none; + color: $page_link_hover_color; } } + + .username { + font-size: 12pt; + } } diff --git a/mainsite/scss/params.scss b/mainsite/scss/params.scss index a73359c..32c6fdb 100644 --- a/mainsite/scss/params.scss +++ b/mainsite/scss/params.scss @@ -3,6 +3,7 @@ $page_text_color: #250f2d; $page_link_color: #2b153f; $page_link_hover_color: #180c23; $page_width: 800px; +$small_page_width: 500px; $help_text_color: rgba($page_text_color, .65); @@ -11,17 +12,11 @@ $font_family: "Open Sans"; $small_screen_font_size: 12pt; -$header_height: 125px; -$header_logo_maxwidth: 300px; $header_bg_color: #6bb8c4; $header_text_color: #f6fbfd; -$header_infos_font_size: 28pt; $header_infos_font_family: "Kalam"; $header_border_color: #51808c; -$header_horizontal_padding: 80px; - $nav_font_size: 18pt; -$nav_height: 55px; $footer_bg_color: $header_bg_color; $footer_font_size: 12pt; diff --git a/mainsite/scss/style.scss b/mainsite/scss/style.scss index 218a4b8..7a54ca8 100644 --- a/mainsite/scss/style.scss +++ b/mainsite/scss/style.scss @@ -30,13 +30,6 @@ body { } } -body > h1 { - margin: 0; - background-color: $header_border_color; - color: $header_text_color; - text-align: center; -} - main { display: flex; justify-content: center; @@ -49,6 +42,10 @@ main { padding: 20px; margin-bottom: 50px; text-align: justify; + + &.small_page { + width: $small_page_width; + } } footer { @@ -67,6 +64,11 @@ footer { } } +h1 { + font-size: 1.5em; + font-weight: bold; +} + a { text-decoration: underline; color: $page_link_color; @@ -175,28 +177,6 @@ button, .btn_row a { direction: rtl; } -.team_infos { - margin: 25px 0; - padding: 0; - p, ul { - margin: 10px; - } -} - -.invite_link { - display: flex; - - input { - flex: 1 0 200px; - margin: 10px 5px; - } - button { - min-width: 45px; - font-size: 12pt; - } -} - - table { border-collapse: collapse; width: 100%; @@ -219,7 +199,7 @@ iframe { border: 2px solid $header_border_color; } -.indexbar { +/*.indexbar { width: 100%; display: flex; justify-content: center; @@ -256,7 +236,7 @@ iframe { border-radius: 0 1ex 1ex 0; } } -} +}*/ #game_infos { display: flex; diff --git a/mainsite/static/css/style.css b/mainsite/static/css/style.css index e4ff87c..fae83c5 100644 --- a/mainsite/static/css/style.css +++ b/mainsite/static/css/style.css @@ -6,21 +6,19 @@ header { align-content: stretch; background-color: #6bb8c4; color: #f6fbfd; - padding: 0 30px; } + padding: 0 30px; + border-bottom: 4px solid #51808c; } header h1 { - margin: 0; } - header h1 a { - display: block; - padding: 0 20px; - color: #f6fbfd; - font-size: 16pt; - text-decoration: none; } + margin: 0; + padding: 0 20px; + color: #f6fbfd; + font-size: 16pt; } header nav { display: flex; justify-content: left; margin: 0 20px; flex: 1 1 100px; } - header nav a, header a.login { + header a { display: block; margin: 0; padding: 10px 20px; @@ -28,14 +26,17 @@ header { color: #f6fbfd; font-size: 18pt; text-decoration: none; } - header nav a:hover, header a.login:hover { + header a:hover { background-color: #48a6b4; color: #180c23; } - header nav a.current, header a.login.current { + header a.current { background-color: #51808c; } - header nav a:focus, header a.login:focus { + header a:focus { background-color: #48a6b4; - box-shadow: none; } + box-shadow: none; + color: #180c23; } + header .username { + font-size: 12pt; } form { display: flex; @@ -183,12 +184,6 @@ body { body { font-size: 12pt; } } -body > h1 { - margin: 0; - background-color: #51808c; - color: #f6fbfd; - text-align: center; } - main { display: flex; justify-content: center; @@ -199,6 +194,8 @@ main { padding: 20px; margin-bottom: 50px; text-align: justify; } + #main_content.small_page { + width: 500px; } footer { background-color: #6bb8c4; @@ -213,6 +210,10 @@ footer { bottom: 0.3ex; left: 0.2ex; } } +h1 { + font-size: 1.5em; + font-weight: bold; } + a { text-decoration: underline; color: #2b153f; @@ -333,21 +334,6 @@ button, .btn_row a { unicode-bidi: bidi-override; direction: rtl; } -.team_infos { - margin: 25px 0; - padding: 0; } - .team_infos p, .team_infos ul { - margin: 10px; } - -.invite_link { - display: flex; } - .invite_link input { - flex: 1 0 200px; - margin: 10px 5px; } - .invite_link button { - min-width: 45px; - font-size: 12pt; } - table { border-collapse: collapse; width: 100%; @@ -364,32 +350,44 @@ iframe { height: 400px; border: 2px solid #51808c; } -.indexbar { - width: 100%; - display: flex; - justify-content: center; - align-items: stretch; } - .indexbar a { - text-align: center; - flex: 1 1 0; +/*.indexbar { + width: 100%; display: flex; - flex-direction: column; justify-content: center; align-items: stretch; - color: #040206; - text-decoration: none; - border-radius: 0; } - .indexbar a span { - margin: auto 5px; } - .indexbar a:first-child { - border-radius: 1ex 0 0 1ex; } - .indexbar a:nth-child(odd) { - background-color: rgba(107, 184, 196, 0.75); } - .indexbar a:nth-child(even) { - background-color: rgba(107, 184, 196, 0.6); } - .indexbar a:last-child { - border-radius: 0 1ex 1ex 0; } + a { + text-align: center; + flex: 1 1 0; + + display: flex; + flex-direction: column; + justify-content: center; + align-items: stretch; + + color: $indexbar_text_color; + text-decoration: none; + + border-radius: 0; + + span { + margin: auto 5px; + } + + &:first-child { + border-radius: 1ex 0 0 1ex; + } + &:nth-child(odd) { + background-color: $indexbar_bg_color_1; + } + &:nth-child(even) { + background-color: $indexbar_bg_color_2; + } + &:last-child { + border-radius: 0 1ex 1ex 0; + } + } +}*/ #game_infos { display: flex; align-items: center; diff --git a/mainsite/templates/400.html b/mainsite/templates/400.html index 5d76311..c5d1716 100644 --- a/mainsite/templates/400.html +++ b/mainsite/templates/400.html @@ -1,4 +1,4 @@ -{% extends "base_minimal.html" %} +{% extends "small_page.html" %} {% block "content" %}

Requête invalide

diff --git a/mainsite/templates/403.html b/mainsite/templates/403.html index e3618b2..1a9adab 100644 --- a/mainsite/templates/403.html +++ b/mainsite/templates/403.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "small_page.html" %} {% block "content" %}

Accès refusé

diff --git a/mainsite/templates/404.html b/mainsite/templates/404.html index 39de595..a76efad 100644 --- a/mainsite/templates/404.html +++ b/mainsite/templates/404.html @@ -1,4 +1,4 @@ -{% extends "base_minimal.html" %} +{% extends "small_page.html" %} {% block "content" %}

Page introuvable

diff --git a/mainsite/templates/500.html b/mainsite/templates/500.html index ebbbee5..fa2d0b4 100644 --- a/mainsite/templates/500.html +++ b/mainsite/templates/500.html @@ -1,4 +1,4 @@ -{% extends "base_minimal.html" %} +{% extends "small_page.html" %} {% block "content" %}

Incident technique

diff --git a/mainsite/templates/base.html b/mainsite/templates/base.html index 1f88740..ca14787 100644 --- a/mainsite/templates/base.html +++ b/mainsite/templates/base.html @@ -9,13 +9,8 @@ {% include "partials/header.html" %} -

- {% block "title" %} - {% endblock %} -

-
-
+
{% include "partials/messages.html" %} {% block "content" %} diff --git a/mainsite/templates/login.html b/mainsite/templates/login.html deleted file mode 100644 index bb364f1..0000000 --- a/mainsite/templates/login.html +++ /dev/null @@ -1,36 +0,0 @@ -{% extends "base.html" %} - -{% block "content" %} -
- {% if form.errors %} -

Login ou mot de passe incorrect

- {% endif %} - - {% if next %} - {% if user.is_authenticated %} -

Accès non autorisé.

- {% else %} -

Merci de vous connecter.

- {% endif %} - {% endif %} - -
- {% csrf_token %} - - - - - - - - - -
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
- - - -
-
- -{% endblock %} - diff --git a/mainsite/templates/login_switch.html b/mainsite/templates/login_switch.html deleted file mode 100644 index d99c111..0000000 --- a/mainsite/templates/login_switch.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends "base.html" %} - -{% block "content" %} -
-
-
-
- -
- -
-
-
- -{% endblock %} - diff --git a/mainsite/templates/mainsite/home.html b/mainsite/templates/mainsite/home.html index 22f4829..ed75189 100644 --- a/mainsite/templates/mainsite/home.html +++ b/mainsite/templates/mainsite/home.html @@ -1,9 +1,6 @@ {% extends "base.html" %} -{% block "title" %} - Bienvenue en salle Jeux -{% endblock %} - {% block "content" %} - Site d'inventaire et de gestion du club Jeux de l'ENS. +

Bienvenue en salle Jeux

+Site d'inventaire et de gestion du club Jeux de l'ENS. {% endblock %} diff --git a/mainsite/templates/mainsite/login.html b/mainsite/templates/mainsite/login.html deleted file mode 100644 index 42145ad..0000000 --- a/mainsite/templates/mainsite/login.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "base.html" %} - -{% block content %} - - - - - - -{% endblock content %} - diff --git a/mainsite/templates/partials/head.html b/mainsite/templates/partials/head.html index 605fa31..f60515d 100644 --- a/mainsite/templates/partials/head.html +++ b/mainsite/templates/partials/head.html @@ -1,8 +1,8 @@ {% load static %} - - - GestioJeux - - - + + +GestioJeux + + + diff --git a/mainsite/templates/partials/header.html b/mainsite/templates/partials/header.html index 47e6fde..f251a0e 100644 --- a/mainsite/templates/partials/header.html +++ b/mainsite/templates/partials/header.html @@ -1,17 +1,18 @@
-

- - GestioJeux - -

+

GestioJeux

+ {% with url_name=request.resolver_match.url_name %} {% if request.user.is_authenticated %} - Déconnexion +
{{ request.user.username }}
+ {% else %} {% endif %} {# #} diff --git a/mainsite/templates/small_page.html b/mainsite/templates/small_page.html new file mode 100644 index 0000000..2adaa40 --- /dev/null +++ b/mainsite/templates/small_page.html @@ -0,0 +1,3 @@ +{% extends "base.html" %} + +{% block "main_content_class" %}small_page{% endblock %}