mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
feat: Formulaire de création RF sur une seule pag
This commit is contained in:
@ -174,4 +174,45 @@ def delete_registration_files(registerForm):
|
||||
registerForm.registration_file.delete(save=False)
|
||||
|
||||
if os.path.exists(base_dir):
|
||||
shutil.rmtree(base_dir)
|
||||
shutil.rmtree(base_dir)
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
def getCurrentSchoolYear():
|
||||
"""
|
||||
Retourne l'année scolaire en cours au format "YYYY-YYYY".
|
||||
Exemple : Si nous sommes en octobre 2023, retourne "2023-2024".
|
||||
"""
|
||||
now = datetime.now()
|
||||
current_year = now.year
|
||||
current_month = now.month
|
||||
|
||||
# Si nous sommes avant septembre, l'année scolaire a commencé l'année précédente
|
||||
start_year = current_year if current_month >= 9 else current_year - 1
|
||||
return f"{start_year}-{start_year + 1}"
|
||||
|
||||
def getNextSchoolYear():
|
||||
"""
|
||||
Retourne l'année scolaire suivante au format "YYYY-YYYY".
|
||||
Exemple : Si nous sommes en octobre 2023, retourne "2024-2025".
|
||||
"""
|
||||
current_school_year = getCurrentSchoolYear()
|
||||
start_year, end_year = map(int, current_school_year.split('-'))
|
||||
return f"{start_year + 1}-{end_year + 1}"
|
||||
|
||||
|
||||
def getHistoricalYears(count=5):
|
||||
"""
|
||||
Retourne un tableau des années scolaires passées au format "YYYY-YYYY".
|
||||
Exemple : ["2022-2023", "2021-2022", "2020-2021"].
|
||||
:param count: Le nombre d'années scolaires passées à inclure.
|
||||
"""
|
||||
current_school_year = getCurrentSchoolYear()
|
||||
start_year = int(current_school_year.split('-')[0])
|
||||
|
||||
historical_years = []
|
||||
for i in range(1, count + 1):
|
||||
historical_start_year = start_year - i
|
||||
historical_years.append(f"{historical_start_year}-{historical_start_year + 1}")
|
||||
|
||||
return historical_years
|
||||
Reference in New Issue
Block a user