diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef484de2..b08cdcf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Sith 3 CI +name: Sith CI on: push: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a1ed6db0..514d2a06 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: script_stop: true - # See https://github.com/ae-utbm/sith3/wiki/GitHub-Actions#deployment-action + # See https://github.com/ae-utbm/sith/wiki/GitHub-Actions#deployment-action script: | export PATH="/home/sith/.local/bin:$PATH" pushd ${{secrets.SITH_PATH}} diff --git a/.github/workflows/taiste.yml b/.github/workflows/taiste.yml index ce102a8e..c6eadafc 100644 --- a/.github/workflows/taiste.yml +++ b/.github/workflows/taiste.yml @@ -1,4 +1,4 @@ -name: Sith3 taiste +name: Sith taiste on: push: @@ -30,7 +30,7 @@ jobs: script_stop: true - # See https://github.com/ae-utbm/sith3/wiki/GitHub-Actions#deployment-action + # See https://github.com/ae-utbm/sith/wiki/GitHub-Actions#deployment-action script: | export PATH="$HOME/.poetry/bin:$PATH" pushd ${{secrets.SITH_PATH}} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c844b4f8..3d0b57f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,18 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.5.7 + rev: v0.6.9 hooks: - id: ruff # just check the code, and print the errors - id: ruff # actually fix the fixable errors, but print nothing args: ["--fix", "--silent"] # Run the formatter. - id: ruff-format + - repo: https://github.com/biomejs/pre-commit + rev: "v0.1.0" # Use the sha / tag you want to point at + hooks: + - id: biome-check + additional_dependencies: ["@biomejs/biome@1.9.3"] - repo: https://github.com/rtts/djhtml rev: 3.0.6 hooks: diff --git a/README.md b/README.md index f27dc28d..ba594fec 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,15 @@ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](#) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) -[![CI status](https://github.com/ae-utbm/sith3/actions/workflows/ci.yml/badge.svg)](#) -[![Docs status](https://github.com/ae-utbm/sith3/actions/workflows/deploy_docs.yml/badge.svg)](https://ae-utbm.github.io/sith3) +[![CI status](https://github.com/ae-utbm/sith/actions/workflows/ci.yml/badge.svg)](#) +[![Docs status](https://github.com/ae-utbm/sith/actions/workflows/deploy_docs.yml/badge.svg)](https://ae-utbm.github.io/sith) [![Built with Material for MkDocs](https://img.shields.io/badge/Material_for_MkDocs-526CFE?style=default&logo=MaterialForMkDocs&logoColor=white)](https://squidfunk.github.io/mkdocs-material/) +[![Checked with Biome](https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome)](https://biomejs.dev) [![discord](https://img.shields.io/discord/971448179075731476?label=discord&logo=discord&style=default)](https://discord.gg/xk9wfpsufm) ### This is the source code of the UTBM's student association available at [https://ae.utbm.fr/](https://ae.utbm.fr/). -All documentation is in the `docs` directory and online at [https://ae-utbm.github.io/sith3](https://ae-utbm.github.io/sith3). This documentation is written in French because it targets a French audience and it's too much work to maintain two versions. The code and code comments are strictly written in English. +All documentation is in the `docs` directory and online at [https://ae-utbm.github.io/sith](https://ae-utbm.github.io/sith). This documentation is written in French because it targets a French audience and it's too much work to maintain two versions. The code and code comments are strictly written in English. #### If you want to contribute, here's how we recommend to read the docs: diff --git a/accounting/__init__.py b/accounting/__init__.py index a098e7ba..f4445e69 100644 --- a/accounting/__init__.py +++ b/accounting/__init__.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/accounting/admin.py b/accounting/admin.py index f0a3784e..29321713 100644 --- a/accounting/admin.py +++ b/accounting/admin.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/accounting/models.py b/accounting/models.py index b0c3fab1..7eaba943 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/accounting/tests.py b/accounting/tests.py index 3630c0e2..6dc61d08 100644 --- a/accounting/tests.py +++ b/accounting/tests.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/accounting/urls.py b/accounting/urls.py index 029cd4cc..c8e6082c 100644 --- a/accounting/urls.py +++ b/accounting/urls.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/accounting/views.py b/accounting/views.py index 85d1a4c7..276aefcc 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/babel.config.json b/babel.config.json index ae719f31..623ee01c 100644 --- a/babel.config.json +++ b/babel.config.json @@ -12,4 +12,4 @@ } ] ] -} \ No newline at end of file +} diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..fdfe712a --- /dev/null +++ b/biome.json @@ -0,0 +1,29 @@ +{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": false, + "ignore": ["core/static/vendored", "*.min.*", "staticfiles/generated"] + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "lineWidth": 88 + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "all": true + } + }, + "javascript": { + "globals": ["Alpine", "$", "jQuery", "gettext", "interpolate"] + } +} diff --git a/club/__init__.py b/club/__init__.py index a098e7ba..f4445e69 100644 --- a/club/__init__.py +++ b/club/__init__.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/club/admin.py b/club/admin.py index 3dab59fd..c2444c17 100644 --- a/club/admin.py +++ b/club/admin.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/club/models.py b/club/models.py index 3c31aad1..be875632 100644 --- a/club/models.py +++ b/club/models.py @@ -35,6 +35,7 @@ from django.db.models import Q from django.urls import reverse from django.utils import timezone from django.utils.functional import cached_property +from django.utils.timezone import localdate from django.utils.translation import gettext_lazy as _ from core.models import Group, MetaGroup, Notification, Page, RealGroup, SithFile, User @@ -269,7 +270,7 @@ class Club(models.Model): class MembershipQuerySet(models.QuerySet): def ongoing(self) -> Self: """Filter all memberships which are not finished yet.""" - return self.filter(Q(end_date=None) | Q(end_date__gt=timezone.now().date())) + return self.filter(Q(end_date=None) | Q(end_date__gt=localdate())) def board(self) -> Self: """Filter all memberships where the user is/was in the board. diff --git a/club/tests.py b/club/tests.py index 6450d32d..e0de344d 100644 --- a/club/tests.py +++ b/club/tests.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # @@ -19,7 +19,7 @@ from django.core.cache import cache from django.test import TestCase from django.urls import reverse from django.utils import timezone -from django.utils.timezone import localtime, now +from django.utils.timezone import localdate, localtime, now from django.utils.translation import gettext as _ from club.forms import MailingForm @@ -109,7 +109,7 @@ class TestMembershipQuerySet(TestClub): def test_ongoing_with_membership_ending_today(self): """Test that a membership ending the present day is considered as ended.""" - today = timezone.now().date() + today = localdate() self.richard.memberships.filter(club=self.club).update(end_date=today) current_members = list(self.club.members.ongoing().order_by("id")) expected = [ diff --git a/com/__init__.py b/com/__init__.py index a098e7ba..f4445e69 100644 --- a/com/__init__.py +++ b/com/__init__.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/com/admin.py b/com/admin.py index 76b966fc..84e85328 100644 --- a/com/admin.py +++ b/com/admin.py @@ -5,10 +5,10 @@ # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # -# You can find the source code of the website at https://github.com/ae-utbm/sith3 +# You can find the source code of the website at https://github.com/ae-utbm/sith # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) -# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE +# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # diff --git a/com/static/com/js/poster_list.js b/com/static/com/js/poster_list.js index 9d4090e9..8ffb97c4 100644 --- a/com/static/com/js/poster_list.js +++ b/com/static/com/js/poster_list.js @@ -1,24 +1,23 @@ -$(document).ready(function(){ +$(document).ready(() => { + $("#poster_list #view").click(() => { + $("#view").removeClass("active"); + }); - $("#poster_list #view").click(function(e){ - $("#view").removeClass("active"); - }); + $("#poster_list .poster .image").click((e) => { + let el = $(e.target); + if (el.hasClass("image")) { + el = el.find("img"); + } + $("#poster_list #view #placeholder").html(el.clone()); - $("#poster_list .poster .image").click(function(e){ - - el = $(e.target); - if(el.hasClass("image")) - el = el.find("img") - $("#poster_list #view #placeholder").html(el.clone()); - - $("#view").addClass("active"); - }); - - $(document).keyup(function(e) { - if (e.keyCode == 27) { // escape key maps to keycode `27` - e.preventDefault(); - $("#view").removeClass("active"); - } - }); + $("#view").addClass("active"); + }); + $(document).keyup((e) => { + if (e.keyCode === 27) { + // escape key maps to keycode `27` + e.preventDefault(); + $("#view").removeClass("active"); + } + }); }); diff --git a/com/static/com/js/slideshow.js b/com/static/com/js/slideshow.js index 74ac9765..952af8b8 100644 --- a/com/static/com/js/slideshow.js +++ b/com/static/com/js/slideshow.js @@ -1,118 +1,98 @@ -$(document).ready(function(){ +$(document).ready(() => { + const transitionTime = 1000; - transition_time = 1000; + let i = 0; + const max = $("#slideshow .slide").length; - i = 0; - max = $("#slideshow .slide").length; - - next_trigger = 0 - - function enterFullscreen() { - element = document.getElementById("slideshow"); - $(element).addClass("fullscreen"); - if(element.requestFullscreen) { - element.requestFullscreen(); - } else if(element.mozRequestFullScreen) { - element.mozRequestFullScreen(); - } else if(element.webkitRequestFullscreen) { - element.webkitRequestFullscreen(); - } else if(element.msRequestFullscreen) { - element.msRequestFullscreen(); - } + function enterFullscreen() { + const element = document.getElementById("slideshow"); + $(element).addClass("fullscreen"); + if (element.requestFullscreen) { + element.requestFullscreen(); + } else if (element.mozRequestFullScreen) { + element.mozRequestFullScreen(); + } else if (element.webkitRequestFullscreen) { + element.webkitRequestFullscreen(); + } else if (element.msRequestFullscreen) { + element.msRequestFullscreen(); } + } - function exitFullscreen() { - element = document.getElementById("slideshow"); - $(element).removeClass("fullscreen"); - if (document.exitFullscreen) { - document.exitFullscreen(); - } else if (document.webkitExitFullscreen) { - document.webkitExitFullscreen(); - } else if (document.mozCancelFullScreen) { - document.mozCancelFullScreen(); - } else if (document.msExitFullscreen) { - document.msExitFullscreen(); - } + function exitFullscreen() { + const element = document.getElementById("slideshow"); + $(element).removeClass("fullscreen"); + if (document.exitFullscreen) { + document.exitFullscreen(); + } else if (document.webkitExitFullscreen) { + document.webkitExitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.msExitFullscreen) { + document.msExitFullscreen(); } + } - function init_progress_bar() - { + function initProgressBar() { + $("#slideshow #progress_bar").css("transition", "none"); + $("#slideshow #progress_bar").removeClass("progress"); + $("#slideshow #progress_bar").addClass("init"); + } - $("#slideshow #progress_bar").css("transition", "none"); - $("#slideshow #progress_bar").removeClass("progress"); - $("#slideshow #progress_bar").addClass("init"); + function startProgressBar(displayTime) { + $("#slideshow #progress_bar").removeClass("init"); + $("#slideshow #progress_bar").addClass("progress"); + $("#slideshow #progress_bar").css("transition", `width ${displayTime}s linear`); + } + function next() { + initProgressBar(); + const slide = $($("#slideshow .slide").get(i % max)); + slide.removeClass("center"); + slide.addClass("left"); + + const nextSlide = $($("#slideshow .slide").get((i + 1) % max)); + nextSlide.removeClass("right"); + nextSlide.addClass("center"); + const displayTime = nextSlide.attr("display_time") || 2; + + $("#slideshow .bullet").removeClass("active"); + const bullet = $("#slideshow .bullet")[(i + 1) % max]; + $(bullet).addClass("active"); + + i = (i + 1) % max; + + setTimeout(() => { + const othersLeft = $("#slideshow .slide.left"); + othersLeft.removeClass("left"); + othersLeft.addClass("right"); + + startProgressBar(displayTime); + setTimeout(next, displayTime * 1000); + }, transitionTime); + } + + const displayTime = $("#slideshow .center").attr("display_time"); + initProgressBar(); + setTimeout(() => { + if (max > 1) { + startProgressBar(displayTime); + setTimeout(next, displayTime * 1000); } + }, 10); - function start_progress_bar(display_time) - { - - $("#slideshow #progress_bar").removeClass("init"); - $("#slideshow #progress_bar").addClass("progress"); - $("#slideshow #progress_bar").css("transition", "width " + display_time + "s linear") - + $("#slideshow").click(() => { + if ($("#slideshow").hasClass("fullscreen")) { + exitFullscreen(); + } else { + enterFullscreen(); } + }); - function next() - { - - init_progress_bar(); - slide = $($("#slideshow .slide").get(i % max)); - slide.removeClass("center"); - slide.addClass("left"); - - next_slide = $($("#slideshow .slide").get((i + 1) % max)); - next_slide.removeClass("right"); - next_slide.addClass("center"); - display_time = next_slide.attr("display_time") || 2; - - $("#slideshow .bullet").removeClass("active"); - bullet = $("#slideshow .bullet")[(i + 1) % max]; - $(bullet).addClass("active"); - - i = (i + 1) % max; - - setTimeout(function(){ - - others_left = $("#slideshow .slide.left"); - others_left.removeClass("left"); - others_left.addClass("right"); - - start_progress_bar(display_time); - next_trigger = setTimeout(next, display_time * 1000); - - }, transition_time); - + $(document).keyup((e) => { + if (e.keyCode === 27) { + // escape key maps to keycode `27` + e.preventDefault(); + exitFullscreen(); } - - - display_time = $("#slideshow .center").attr("display_time"); - init_progress_bar(); - setTimeout(function(){ - if(max > 1){ - start_progress_bar(display_time); - setTimeout(next, display_time * 1000); - } - }, 10); - - - $("#slideshow").click(function(e){ - if(!$("#slideshow").hasClass("fullscreen")) - { - console.log("Entering fullscreen ..."); - enterFullscreen(); - }else{ - console.log("Exiting fullscreen ..."); - exitFullscreen(); - } - }); - - $(document).keyup(function(e) { - if (e.keyCode == 27) { // escape key maps to keycode `27` - e.preventDefault(); - console.log("Exiting fullscreen ..."); - exitFullscreen(); - } - }); - + }); }); diff --git a/com/templates/com/poster_list.jinja b/com/templates/com/poster_list.jinja index 9ff3add4..8c4f5cd1 100644 --- a/com/templates/com/poster_list.jinja +++ b/com/templates/com/poster_list.jinja @@ -27,7 +27,7 @@