stylised the login page

This commit is contained in:
Faraphel 2024-01-04 23:22:06 +01:00
parent d55ac2e4f8
commit 6a7a824a7e
9 changed files with 48 additions and 22 deletions

View file

@ -0,0 +1,11 @@
#login-form {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#login-form input {
box-sizing: border-box;
width: 100%;
}

View file

@ -1,6 +1,8 @@
{% extends "Palto/base.html" %}
{% extends "Palto/base/base-features.html" %}
{% block body %}
{{ block.super }}
<h1>Palto</h1>
<p>

View file

@ -12,7 +12,7 @@
<form id="login-form" method="POST">
{% csrf_token %}
<table>
{{ form_login.as_table }}
{{ form_login.as_p }}
</table>
<input type="submit" value="Se connecter">
</form>

View file

@ -1,7 +1,9 @@
{% extends "Palto/base.html" %}
{% extends "Palto/base/base-features.html" %}
{% load dict_tags %}
{% block body %}
{{ block.super }}
{{ profile.username }}
{{ profile.email }}
{% if profile.is_superuser %}Administrator{% endif %}

View file

@ -1,6 +1,8 @@
{% extends "Palto/base.html" %}
{% extends "Palto/base/base-features.html" %}
{% block body %}
{{ block.super }}
{# group's information #}
<table>
<tr>

View file

@ -1,6 +1,7 @@
{% extends "Palto/base.html" %}
{% extends "Palto/base/base-features.html" %}
{% block body %}
{{ block.super }}
{# table of all the sessions #}
<table>
<thead>

View file

@ -1,7 +1,9 @@
{% extends "Palto/base.html" %}
{% extends "Palto/base/base-features.html" %}
{% load dict_tags %}
{% block body %}
{{ block.super }}
{# session's information #}
<table>
<tr>

View file

@ -1,7 +1,9 @@
{% extends "Palto/base.html" %}
{% extends "Palto/base/base-features.html" %}
{% load dict_tags %}
{% block body %}
{{ block.super }}
{# unit's information #}
<table>
<tr>

View file

@ -24,24 +24,28 @@ def homepage_view(request: WSGIRequest):
def login_view(request: WSGIRequest):
# create a login form
form_login = forms.LoginForm(request.POST)
if form_login.is_valid():
# try to authenticate this user with the credentials
user = authenticate(
username=form_login.cleaned_data["username"],
password=form_login.cleaned_data["password"]
)
if request.POST:
form_login = forms.LoginForm(request.POST)
if user is not None:
# if the user was authenticated, log the user in.
login(request, user)
# redirect him to the main page
return redirect("Palto:homepage")
if form_login.is_valid():
# try to authenticate this user with the credentials
user = authenticate(
username=form_login.cleaned_data["username"],
password=form_login.cleaned_data["password"]
)
else:
# otherwise the credentials were invalid.
form_login.add_error(field=None, error="Invalid credentials.")
if user is not None:
# if the user was authenticated, log the user in.
login(request, user)
# redirect him to the main page
return redirect("Palto:homepage")
else:
# otherwise the credentials were invalid.
form_login.add_error(field=None, error="Invalid credentials.")
else:
form_login = forms.LoginForm()
# return the page
return render(