forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -3,15 +3,23 @@ from datetime import datetime
|
||||
from flask import url_for
|
||||
from flask_login import current_user
|
||||
from flask_sqlalchemy.query import Query
|
||||
from sqlalchemy import desc, literal, union, asc
|
||||
from sqlalchemy import desc, literal, literal_column, union, asc
|
||||
|
||||
from app import db, g
|
||||
from app.auth.models import User
|
||||
from app.models import Assiduite, Identite, Justificatif
|
||||
from app.scodoc.sco_utils import EtatAssiduite, EtatJustificatif, to_bool
|
||||
from app.scodoc.sco_utils import (
|
||||
EtatAssiduite,
|
||||
EtatJustificatif,
|
||||
to_bool,
|
||||
date_debut_annee_scolaire,
|
||||
date_fin_annee_scolaire,
|
||||
localize_datetime,
|
||||
)
|
||||
from app.tables import table_builder as tb
|
||||
from app.scodoc.sco_cache import RequeteTableauAssiduiteCache
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
from app.scodoc.sco_preferences import get_preference
|
||||
|
||||
|
||||
class Pagination:
|
||||
@ -195,6 +203,17 @@ class ListeAssiJusti(tb.Table):
|
||||
r = query_finale.all()
|
||||
RequeteTableauAssiduiteCache.set(cle_cache, r)
|
||||
|
||||
# Filtrer Si préférence "Limiter les assiduités à l'année courante"
|
||||
if get_preference("assi_limit_annee"):
|
||||
annee_debut = localize_datetime(date_debut_annee_scolaire())
|
||||
annee_fin = localize_datetime(date_fin_annee_scolaire())
|
||||
r = [
|
||||
obj
|
||||
for obj in r
|
||||
if obj._asdict()["date_debut"] >= annee_debut
|
||||
and obj._asdict()["date_fin"] <= annee_fin
|
||||
]
|
||||
|
||||
# Paginer la requête pour ne pas envoyer trop d'informations au client
|
||||
pagination: Pagination = self.paginer(r, no_pagination=self.no_pagination)
|
||||
self.total_pages = pagination.total_pages
|
||||
@ -637,7 +656,7 @@ class AssiFiltre:
|
||||
|
||||
type_filtrage, date = val_filtre
|
||||
|
||||
match (type_filtrage):
|
||||
match type_filtrage:
|
||||
# On garde uniquement les dates supérieures au filtre
|
||||
case 2:
|
||||
query_filtree = query_filtree.filter(
|
||||
|
Loading…
Reference in New Issue
Block a user