1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-02-26 10:26:32 +00:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Emmy D'Anello
ff414ea046
Add dark theme based on browser preference 2023-02-20 23:02:09 +01:00
Emmy D'Anello
91d39b44a2
Add possibility to load Matrix credentials from env configuration 2023-02-20 22:25:13 +01:00
Emmy D'Anello
d3631877c4
Forgotten password link was invisible 2023-02-20 22:13:03 +01:00
Emmy D'Anello
502b066311
Commit bootstrap-select 2023-02-20 21:47:08 +01:00
22 changed files with 107 additions and 40 deletions

2
.gitignore vendored
View File

@ -36,7 +36,7 @@ secrets.py
*.log *.log
media/ media/
output/ output/
static/ /static/
# Virtualenv # Virtualenv
env/ env/

View File

@ -4,7 +4,7 @@
{% block content %} {% block content %}
{% trans "any" as any %} {% trans "any" as any %}
<div class="card bg-light shadow"> <div class="card bg-body shadow">
<div class="card-header text-center"> <div class="card-header text-center">
<h4>{% trans "Participation of team" %} {{ participation.team.name }} ({{ participation.team.trigram }})</h4> <h4>{% trans "Participation of team" %} {{ participation.team.name }} ({{ participation.team.trigram }})</h4>
</div> </div>

View File

@ -4,7 +4,7 @@
{% block content %} {% block content %}
{% trans "any" as any %} {% trans "any" as any %}
<div class="card bg-light shadow"> <div class="card bg-body shadow">
<div class="card-header text-center"> <div class="card-header text-center">
<h4>{{ passage }}</h4> <h4>{{ passage }}</h4>
</div> </div>
@ -59,7 +59,7 @@
{% render_table notes %} {% render_table notes %}
<div class="card bg-light shadow"> <div class="card bg-body shadow">
<div class="card-body"> <div class="card-body">
<dl class="row"> <dl class="row">
<dt class="col-sm-8">{% trans "Average points for the defender writing:" %}</dt> <dt class="col-sm-8">{% trans "Average points for the defender writing:" %}</dt>

View File

@ -3,7 +3,7 @@
{% load django_tables2 i18n %} {% load django_tables2 i18n %}
{% block content %} {% block content %}
<div class="card bg-light shadow"> <div class="card bg-body shadow">
<div class="card-header text-center"> <div class="card-header text-center">
<h4>{{ pool }}</h4> <h4>{{ pool }}</h4>
</div> </div>
@ -36,7 +36,7 @@
<dd class="col-sm-9">{{ pool.bbb_url|urlize }}</dd> <dd class="col-sm-9">{{ pool.bbb_url|urlize }}</dd>
</dl> </dl>
<div class="card bg-light shadow"> <div class="card bg-body shadow">
<div class="card-header text-center"> <div class="card-header text-center">
<h5>{% trans "Ranking" %}</h5> <h5>{% trans "Ranking" %}</h5>
</div> </div>

View File

@ -4,7 +4,7 @@
{% load crispy_forms_filters %} {% load crispy_forms_filters %}
{% block content %} {% block content %}
<div class="card bg-light shadow"> <div class="card bg-body shadow">
<div class="card-header text-center"> <div class="card-header text-center">
<h4>{{ team.name }}</h4> <h4>{{ team.name }}</h4>
</div> </div>

View File

@ -3,7 +3,7 @@
{% load getconfig i18n django_tables2 %} {% load getconfig i18n django_tables2 %}
{% block content %} {% block content %}
<div class="card bg-light shadow"> <div class="card bg-body shadow">
<div class="card-header text-center"> <div class="card-header text-center">
<h4>{{ tournament.name }}</h4> <h4>{{ tournament.name }}</h4>
</div> </div>
@ -92,7 +92,7 @@
{% if notes %} {% if notes %}
<hr> <hr>
<div class="card bg-light shadow"> <div class="card bg-body shadow">
<div class="card-header text-center"> <div class="card-header text-center">
<h5>{% trans "Ranking" %}</h5> <h5>{% trans "Ranking" %}</h5>
</div> </div>

View File

@ -5,7 +5,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% load i18n %} {% load i18n %}
{% block content %} {% block content %}
<div class="card bg-light"> <div class="card bg-body">
<h3 class="card-header text-center"> <h3 class="card-header text-center">
{{ title }} {{ title }}
</h3> </h3>

View File

@ -5,7 +5,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% load i18n %} {% load i18n %}
{% block content %} {% block content %}
<div class="card bg-light"> <div class="card bg-body">
<h3 class="card-header text-center"> <h3 class="card-header text-center">
{% trans "Account activation" %} {% trans "Account activation" %}
</h3> </h3>

View File

@ -5,7 +5,7 @@
{% block content %} {% block content %}
{% trans "any" as any %} {% trans "any" as any %}
<div class="card bg-light shadow"> <div class="card bg-body shadow">
<div class="card-header text-center"> <div class="card-header text-center">
<h4>{{ user_object.first_name }} {{ user_object.last_name }}</h4> <h4>{{ user_object.first_name }} {{ user_object.last_name }}</h4>
</div> </div>

View File

@ -23,14 +23,18 @@ class Matrix:
Retrieve the bot account. Retrieve the bot account.
If not logged, log in and store access token. If not logged, log in and store access token.
""" """
if not os.getenv("SYNAPSE_PASSWORD"): if not os.getenv("SYNAPSE_PASSWORD") and not os.getenv("SYNAPSE_TOKEN"):
return FakeMatrixClient() return FakeMatrixClient()
from nio import AsyncClient from nio import AsyncClient
client = AsyncClient("https://tfjm.org", "@tfjmbot:tfjm.org") client = AsyncClient("https://tfjm.org", "@tfjmbot:tfjm.org")
client.user_id = "@tfjmbot:tfjm.org" client.user_id = "@tfjmbot:tfjm.org"
if os.path.isfile(".matrix_token"): if os.getenv("SYNAPSE_TOKEN"):
client.access_token = os.getenv("SYNAPSE_TOKEN")
client.device_id = os.getenv("SYNAPSE_DEVICE")
return client
elif os.path.isfile(".matrix_token"):
with open(".matrix_device", "r") as f: with open(".matrix_device", "r") as f:
cls._device_id = f.read().rstrip(" \t\r\n") cls._device_id = f.read().rstrip(" \t\r\n")
client.device_id = cls._device_id client.device_id = cls._device_id

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
/*!
* Bootstrap-select v1.14.0-beta3 (https://developer.snapappointments.com/bootstrap-select)
*
* Copyright 2012-2022 SnapAppointments, LLC
* Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
*/
!function(e,t){void 0===e&&void 0!==window&&(e=window),"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(e.jQuery)}(this,function(e){e.fn.selectpicker.defaults={noneSelectedText:"Aucune s\xe9lection",noneResultsText:"Aucun r\xe9sultat pour {0}",countSelectedText:function(e,t){return 1<e?"{0} \xe9l\xe9ments s\xe9lectionn\xe9s":"{0} \xe9l\xe9ment s\xe9lectionn\xe9"},maxOptionsText:function(e,t){return[1<e?"Limite atteinte ({n} \xe9l\xe9ments max)":"Limite atteinte ({n} \xe9l\xe9ment max)",1<t?"Limite du groupe atteinte ({n} \xe9l\xe9ments max)":"Limite du groupe atteinte ({n} \xe9l\xe9ment max)"]},multipleSeparator:", ",selectAllText:"Tout s\xe9lectionner",deselectAllText:"Tout d\xe9s\xe9lectionner"}});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

15
tfjm/static/main.js Normal file
View File

@ -0,0 +1,15 @@
function initModal(target, url, content_id = 'form-content') {
document.querySelector('[data-bs-target="#' + target + 'Modal"]').addEventListener('click', () => {
let modalBody = document.querySelector("#" + target + "Modal div.modal-body")
if (!modalBody.innerHTML.trim()) {
if (url instanceof Function) url = url()
fetch(url, {headers: {'CONTENT-ONLY': '1'}})
.then(resp => resp.text())
.then(resp => new DOMParser().parseFromString(resp, 'text/html'))
.then(res => modalBody.innerHTML = res.getElementById(content_id).outerHTML)
.then(() => $('.selectpicker').selectpicker()) // TODO Update that when the library will be JQuery-free
}
})
}

View File

@ -14,8 +14,18 @@
sodipodi:docname="logo.svg" sodipodi:docname="logo.svg"
width="30.311995" width="30.311995"
height="9.7779999" height="9.7779999"
style="fill:black"
inkscape:version="0.92.2 2405546, 2018-03-11"> inkscape:version="0.92.2 2405546, 2018-03-11">
<style>
path {
fill: black;
}
@media (prefers-color-scheme: dark) {
path {
fill: white;
}
}
</style>
<metadata <metadata
id="metadata31"> id="metadata31">
<rdf:RDF> <rdf:RDF>

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

27
tfjm/static/theme.js Normal file
View File

@ -0,0 +1,27 @@
/*!
* Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
* Copyright 2011-2022 The Bootstrap Authors
* Licensed under the Creative Commons Attribution 3.0 Unported License.
*/
(() => {
'use strict'
const getPreferredTheme = () => {
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
const setTheme = function (theme) {
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-bs-theme', 'dark')
} else {
document.documentElement.setAttribute('data-bs-theme', theme)
}
}
setTheme(getPreferredTheme())
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
setTheme(getPreferredTheme())
})
})()

View File

@ -38,10 +38,10 @@
{% block extracss %}{% endblock %} {% block extracss %}{% endblock %}
</head> </head>
<body class="d-flex w-100 h-100 flex-column"> <body class="d-flex w-100 h-100 flex-column">
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-navbar shadow-sm"> <nav class="navbar navbar-expand-lg fixed-navbar shadow-sm">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="https://tfjm.org/"> <a class="navbar-brand" href="https://tfjm.org/">
<img src="{% static "tfjm.svg" %}" style="width: 42px;" alt="Logo TFJM²" id="navbar-logo"> <img src="{% static "tfjm.svg" %}" style="height: 2em;" alt="Logo TFJM²" id="navbar-logo">
</a> </a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" <button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarNavDropdown" data-bs-target="#navbarNavDropdown"
@ -107,7 +107,7 @@
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" placeholder="{% trans "Search" %}" name="q" id="search-term" value="{{ request.GET.q }}"> <input type="text" class="form-control" placeholder="{% trans "Search" %}" name="q" id="search-term" value="{{ request.GET.q }}">
<div class="input-group-btn"> <div class="input-group-btn">
<button class="btn btn-default" data-bs-toggle="modal" data-bs-target="#searchModal"><i class="fa fa-search"></i></button> <button class="btn btn-default" data-bs-toggle="modal" data-bs-target="#searchModal"><i class="fa fa-search text-body"></i></button>
</div> </div>
</div> </div>
</form> </form>
@ -174,7 +174,7 @@
{% endblock %} {% endblock %}
</main> </main>
<footer class="bg-light text-primary mt-auto py-2"> <footer class="text-primary mt-auto py-2">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-sm-1"> <div class="col-sm-1">
@ -248,26 +248,13 @@
{% include "base_modal.html" with modal_id="login" %} {% include "base_modal.html" with modal_id="login" %}
{% endif %} {% endif %}
<script src="{% static 'main.js' %}"></script>
<script src="{% static 'theme.js' %}"></script>
<script> <script>
CSRF_TOKEN = "{{ csrf_token }}"; CSRF_TOKEN = "{{ csrf_token }}";
document.querySelectorAll(".invalid-feedback").forEach(elem => elem.classList.add('d-block')) document.querySelectorAll(".invalid-feedback").forEach(elem => elem.classList.add('d-block'))
function initModal(target, url, content_id = 'form-content') {
document.querySelector('[data-bs-target="#' + target + 'Modal"]').addEventListener('click', () => {
let modalBody = document.querySelector("#" + target + "Modal div.modal-body")
if (!modalBody.innerHTML.trim()) {
if (url instanceof Function) url = url()
fetch(url, {headers: {'CONTENT-ONLY': '1'}})
.then(resp => resp.text())
.then(resp => new DOMParser().parseFromString(resp, 'text/html'))
.then(res => modalBody.innerHTML = res.getElementById(content_id).outerHTML)
.then(() => $('.selectpicker').selectpicker()) // TODO Update that when the library will be JQuery-free
}
})
}
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
initModal("tournamentList", "{% url "participation:tournament_list" %}") initModal("tournamentList", "{% url "participation:tournament_list" %}")

View File

@ -14,7 +14,7 @@
</p> </p>
</div> </div>
<div class="jumbotron bg-white p-5"> <div class="jumbotron p-5">
<div class="row text-center"> <div class="row text-center">
<h1 class="display-4"> <h1 class="display-4">
Bienvenue sur le site d'inscription au <a href="https://tfjm.org/" target="_blank">𝕋𝔽𝕁𝕄²</a> ! Bienvenue sur le site d'inscription au <a href="https://tfjm.org/" target="_blank">𝕋𝔽𝕁𝕄²</a> !
@ -22,7 +22,7 @@
</div> </div>
</div> </div>
<div class="row bg-white p-5"> <div class="row p-5">
<div class="col-sm"> <div class="col-sm">
<h3> <h3>
Tu souhaites participer au 𝕋𝔽𝕁𝕄² ? Tu souhaites participer au 𝕋𝔽𝕁𝕄² ?
@ -33,12 +33,12 @@
<div class="col-sm text-end"> <div class="col-sm text-end">
<div class="btn-group-vertical"> <div class="btn-group-vertical">
<a class="btn btn-primary btn-lg" href="{% url "registration:signup" %}" role="button">Inscris-toi maintenant !</a> <a class="btn btn-primary btn-lg" href="{% url "registration:signup" %}" role="button">Inscris-toi maintenant !</a>
<a class="btn btn-light btn-lg" href="{% url "login" %}" role="button">J'ai déjà un compte</a> <a class="btn btn-light text-dark btn-lg" href="{% url "login" %}" role="button">J'ai déjà un compte</a>
</div> </div>
</div> </div>
</div> </div>
<div class="jumbotron p-5 border rounded-5 bg-light"> <div class="jumbotron p-5 border rounded-5">
<h5 class="display-4">Comment ça marche ?</h5> <h5 class="display-4">Comment ça marche ?</h5>
<p> <p>
Pour participer au 𝕋𝔽𝕁𝕄², il suffit de créer un compte sur la rubrique <strong><a href="{% url "registration:signup" %}">Inscription</a></strong>. Pour participer au 𝕋𝔽𝕁𝕄², il suffit de créer un compte sur la rubrique <strong><a href="{% url "registration:signup" %}">Inscription</a></strong>.

View File

@ -20,7 +20,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
<div id="form-content"> <div id="form-content">
{% csrf_token %} {% csrf_token %}
{{ form | crispy }} {{ form | crispy }}
<a href="{% url 'password_reset' %}" class="badge badge-light">{% trans 'Forgotten your password or username?' %}</a> <a href="{% url 'password_reset' %}" class="badge text-bg-warning">{% trans 'Forgotten your password or username?' %}</a>
</div> </div>
<input type="submit" value="{% trans 'Log in' %}" class="btn btn-primary"> <input type="submit" value="{% trans 'Log in' %}" class="btn btn-primary">
</form> </form>