Ajout du style pour la page de connexion

This commit is contained in:
Valentin Moguérou 2023-05-15 05:15:34 +02:00
parent e97b1d1659
commit 38f24a3ec3
8 changed files with 96 additions and 21 deletions

View File

@ -62,3 +62,18 @@ class Session:
"JOIN sessions ON utilisateurs.user_id=sessions.user_id WHERE session_id=%s", (self.uuid,)) "JOIN sessions ON utilisateurs.user_id=sessions.user_id WHERE session_id=%s", (self.uuid,))
result = cursor.fetchall() result = cursor.fetchall()
return User(*result[0]) return User(*result[0])
def fetch_grades(self):
cursor = self.db.db.cursor()
cursor.execute("SELECT matieres.libelle, devoirs.libelle, date, coefficient, valeur, maximum FROM notes "
"JOIN devoirs ON notes.id_devoir=devoirs.id_devoir "
"JOIN matieres ON devoirs.id_matiere=matieres.id_matiere WHERE id_eleve=%s", (self.user.id,))
result = cursor.fetchall()
dico = {}
for note in result:
if note[0] in dico:
dico[note[0]].append(note)
else:
dico[note[0]] = [note]
return dico

44
app/static/login.css Normal file
View File

@ -0,0 +1,44 @@
body {
width: clamp(400px, 65%, 800px);
margin: 50px auto;
font-family: "Montserrat", sans-serif;
text-align: center;
}
form table {
margin: 30px auto;
}
form input[type=text], form input[type=password] {
padding: 10px;
border: none;
background-color: #eee;
transition: 200ms background-color;
}
form input[type=text]:hover, form input[type=password]:hover {
background-color: #ddd;
}
input[type=submit] {
border: none;
background-color: dodgerblue;
color: white;
padding: 5px 10px;
border-radius: 3px;
transition: 200ms background-color, 200ms color;
}
input[type=submit]:hover {
background-color: #ddd;
color: black;
}
input[type=submit]:active {
background-color: #bbb;
}
p.error-box {
padding: 10px;
background-color: #ef9a9a;
}

View File

@ -90,7 +90,13 @@ body {
background-color: var(--theme-color-light); background-color: var(--theme-color-light);
} }
main {
margin: 10px;
}
.grade-report td, .grade-report th {
padding: 5px;
}
footer { footer {
background-color: #46484d; background-color: #46484d;

View File

@ -8,15 +8,17 @@
<h1>Mes notes</h1> <h1>Mes notes</h1>
<ul id="liste-notes"> <table class="grade-report">
<li> {% for matiere, notes in grades.items() %}
<span class="section">Mathématiques</span> <tr><th colspan=3>{{ matiere }}</th></tr>
<ul> {% for note in notes %}
<li>12/20</li> <tr>
<li>15/20</li> <td>{{ note[1] }}</td>
</ul> <td>{{ note[4] }}/{{ note[5] }}</td>
</li> <td>coeff. {{ note[3] }}</td>
<li>Philosophie</li> </tr>
</ul> {% endfor %}
{% endfor %}
</table>
{% endblock %} {% endblock %}

View File

@ -6,9 +6,6 @@
<h1>Bienvenue sur Antinote&nbsp;!</h1> <h1>Bienvenue sur Antinote&nbsp;!</h1>
Ce site est encore en construction. yo Vous pouvez vous déplacer dans le site à l'aide des menus.
{{ session }}
{% endblock %} {% endblock %}

View File

@ -5,12 +5,20 @@
<meta name="viewport" <meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="/static/login.css" rel="stylesheet" type="text/css">
<title>Se connecter</title> <title>Se connecter</title>
</head> </head>
<body> <body>
<h1>Se connecter</h1>
<p>Vous pouvez utiliser les identifiants de démonstration&nbsp;: <strong>demo</strong>/<strong>demo</strong>.</p>
{% if request.args["error"] %}
<p class="error-box">Nom d'utilisateur ou mot de passe invalide.</p>
{% endif %}
<form method="post"> <form method="post">
<input type="text" name="username"> <table>
<input type="password" name="password"> <tr><th>Nom d'utilisateur</th><td><input type="text" name="username"></td></tr>
<tr><th>Mot de passe</th><td><input type="password" name="password"></td></tr>
</table>
<input type="submit"> <input type="submit">
</form> </form>
</body> </body>

View File

@ -6,6 +6,6 @@
<h1>Emploi du temps</h1> <h1>Emploi du temps</h1>
Ce site est encore en construction. Veuillez attendre encore un peu pour que cette fonctionnalité soit implémentée.
{% endblock %} {% endblock %}

View File

@ -30,19 +30,22 @@ def views(app, db):
request.form["username"], request.form["username"],
sha256(request.form["password"].encode()).hexdigest() sha256(request.form["password"].encode()).hexdigest()
) )
return redirect("/")
return redirect("/") if session["uuid"] else redirect("/login?error=1")
@app.route("/logout/") @app.route("/logout/")
@login_required @login_required
def logout(): def logout():
db.destroy_session(session["uuid"]) db.destroy_session(session["uuid"])
session["uuid"] = None session["uuid"] = None
return redirect("/login/") return redirect("/login")
@app.route("/grades/") @app.route("/grades/")
@login_required @login_required
def grades(): def grades():
return render_template("grades.html", s=Session(db, session["uuid"])) s = Session(db, session["uuid"])
grades = s.fetch_grades()
return render_template("grades.html", s=s, grades=grades)
@app.route("/timetable/") @app.route("/timetable/")
@login_required @login_required