diff --git a/app/database.py b/app/database.py index 5d288e5..28719e9 100644 --- a/app/database.py +++ b/app/database.py @@ -61,4 +61,19 @@ class Session: cursor.execute("SELECT utilisateurs.user_id, username, nom, prenom, creation_date FROM utilisateurs " "JOIN sessions ON utilisateurs.user_id=sessions.user_id WHERE session_id=%s", (self.uuid,)) result = cursor.fetchall() - return User(*result[0]) \ No newline at end of file + 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 \ No newline at end of file diff --git a/app/static/login.css b/app/static/login.css new file mode 100644 index 0000000..1681345 --- /dev/null +++ b/app/static/login.css @@ -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; +} \ No newline at end of file diff --git a/app/static/style.css b/app/static/style.css index 0b9fd0d..78ef17a 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -90,7 +90,13 @@ body { background-color: var(--theme-color-light); } +main { + margin: 10px; +} +.grade-report td, .grade-report th { + padding: 5px; +} footer { background-color: #46484d; diff --git a/app/templates/grades.html b/app/templates/grades.html index 6375858..0a8c119 100644 --- a/app/templates/grades.html +++ b/app/templates/grades.html @@ -8,15 +8,17 @@

Mes notes

- + + {% for matiere, notes in grades.items() %} + + {% for note in notes %} + + + + + + {% endfor %} + {% endfor %} +
{{ matiere }}
{{ note[1] }}{{ note[4] }}/{{ note[5] }}coeff. {{ note[3] }}
{% endblock %} \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index 2f9b1f6..74036b2 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -6,9 +6,6 @@

Bienvenue sur Antinote !

-Ce site est encore en construction. yo - -{{ session }} - +Vous pouvez vous déplacer dans le site à l'aide des menus. {% endblock %} \ No newline at end of file diff --git a/app/templates/login.html b/app/templates/login.html index 1526054..8f274c9 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -5,12 +5,20 @@ + Se connecter +

Se connecter

+

Vous pouvez utiliser les identifiants de démonstration : demo/demo.

+ {% if request.args["error"] %} +

Nom d'utilisateur ou mot de passe invalide.

+ {% endif %}
- - + + + +
Nom d'utilisateur
Mot de passe
diff --git a/app/templates/timetable.html b/app/templates/timetable.html index dc6d7cb..6fa27d7 100644 --- a/app/templates/timetable.html +++ b/app/templates/timetable.html @@ -6,6 +6,6 @@

Emploi du temps

-Ce site est encore en construction. +Veuillez attendre encore un peu pour que cette fonctionnalité soit implémentée. {% endblock %} \ No newline at end of file diff --git a/app/views.py b/app/views.py index f9c27e3..f9a5108 100644 --- a/app/views.py +++ b/app/views.py @@ -30,19 +30,22 @@ def views(app, db): request.form["username"], sha256(request.form["password"].encode()).hexdigest() ) - return redirect("/") + + return redirect("/") if session["uuid"] else redirect("/login?error=1") @app.route("/logout/") @login_required def logout(): db.destroy_session(session["uuid"]) session["uuid"] = None - return redirect("/login/") + return redirect("/login") @app.route("/grades/") @login_required 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/") @login_required