forked from ScoDoc/ScoDoc
Fix: édition heures assiduité. Introduces ScoDateField/ScoTimeField.
This commit is contained in:
parent
5ab733c1c6
commit
c38b8aa297
@ -1,7 +1,9 @@
|
||||
"""WTF Forms for ScoDoc
|
||||
"""
|
||||
|
||||
import re
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, validators
|
||||
|
||||
|
||||
class ScoDocForm(FlaskForm):
|
||||
@ -21,3 +23,51 @@ class ScoDocForm(FlaskForm):
|
||||
self.error_messages.append(err_msg)
|
||||
if field:
|
||||
field.errors.append(err_msg)
|
||||
|
||||
|
||||
class ScoDateField(StringField):
|
||||
"""A WTF field for date, using datepicker"""
|
||||
|
||||
def __init__(self, label: str, field_id: str, *args, **kwargs):
|
||||
render_kw = {
|
||||
"class": "datepicker",
|
||||
"size": 10,
|
||||
"id": field_id,
|
||||
}
|
||||
if "render_kw" in kwargs:
|
||||
render_kw.update(kwargs["render_kw"])
|
||||
super().__init__(
|
||||
label,
|
||||
validators=[validators.Length(max=10)],
|
||||
render_kw=render_kw,
|
||||
*args,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
||||
class ScoTimeField(StringField):
|
||||
"""A WTF field for time, accept 12:34, 12h34, 12H34
|
||||
Uses timepicker
|
||||
"""
|
||||
|
||||
def __init__(self, label: str, field_id: str, *args, **kwargs):
|
||||
render_kw = {
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": field_id,
|
||||
}
|
||||
if "render_kw" in kwargs:
|
||||
render_kw.update(kwargs["render_kw"])
|
||||
super().__init__(
|
||||
label,
|
||||
validators=[validators.Length(max=5)],
|
||||
default="",
|
||||
render_kw=render_kw,
|
||||
filters=[
|
||||
lambda x: (
|
||||
re.sub(r"(^\d{2})[hH](\d{2}$)", r"\1:\2", x.strip()) if x else None
|
||||
)
|
||||
],
|
||||
*args,
|
||||
**kwargs
|
||||
)
|
||||
|
@ -34,14 +34,13 @@ from flask_wtf.file import MultipleFileField
|
||||
from wtforms import (
|
||||
BooleanField,
|
||||
SelectField,
|
||||
StringField,
|
||||
SubmitField,
|
||||
RadioField,
|
||||
TextAreaField,
|
||||
validators,
|
||||
)
|
||||
from wtforms.validators import DataRequired
|
||||
from app.scodoc import sco_utils as scu
|
||||
from app.forms import ScoDateField, ScoTimeField
|
||||
|
||||
|
||||
class AjoutAssiOrJustForm(FlaskForm):
|
||||
@ -67,64 +66,15 @@ class AjoutAssiOrJustForm(FlaskForm):
|
||||
for field in self:
|
||||
field.render_kw = {"disabled": True}
|
||||
|
||||
date_debut = StringField(
|
||||
"Date de début",
|
||||
validators=[validators.Length(max=10)],
|
||||
render_kw={
|
||||
"class": "datepicker",
|
||||
"size": 10,
|
||||
"id": "assi_date_debut",
|
||||
},
|
||||
)
|
||||
heure_debut = StringField(
|
||||
"Heure début",
|
||||
default="",
|
||||
validators=[validators.Length(max=5)],
|
||||
render_kw={
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": "assi_heure_debut",
|
||||
},
|
||||
)
|
||||
heure_fin = StringField(
|
||||
"Heure fin",
|
||||
default="",
|
||||
validators=[validators.Length(max=5)],
|
||||
render_kw={
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": "assi_heure_fin",
|
||||
},
|
||||
)
|
||||
date_fin = StringField(
|
||||
"Date de fin (si plusieurs jours)",
|
||||
validators=[validators.Length(max=10)],
|
||||
render_kw={
|
||||
"class": "datepicker",
|
||||
"size": 10,
|
||||
"id": "assi_date_fin",
|
||||
},
|
||||
)
|
||||
date_debut = ScoDateField("Date de début", "assi_date_debut")
|
||||
heure_debut = ScoTimeField("Heure début", "assi_heure_debut")
|
||||
heure_fin = ScoTimeField("Heure fin", "assi_heure_fin")
|
||||
|
||||
date_fin = ScoDateField("Date de fin (si plusieurs jours)", "assi_date_fin")
|
||||
|
||||
entry_date = ScoDateField("Date de dépôt ou saisie", "entry_date")
|
||||
entry_time = ScoTimeField("Heure dépôt", "entry_time")
|
||||
|
||||
entry_date = StringField(
|
||||
"Date de dépôt ou saisie",
|
||||
validators=[validators.Length(max=10)],
|
||||
render_kw={
|
||||
"class": "datepicker",
|
||||
"size": 10,
|
||||
"id": "entry_date",
|
||||
},
|
||||
)
|
||||
entry_time = StringField(
|
||||
"Heure dépôt",
|
||||
default="",
|
||||
validators=[validators.Length(max=5)],
|
||||
render_kw={
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": "assi_heure_fin",
|
||||
},
|
||||
)
|
||||
submit = SubmitField("Enregistrer")
|
||||
cancel = SubmitField("Annuler", render_kw={"formnovalidate": True})
|
||||
|
||||
|
@ -1,14 +1,9 @@
|
||||
""" """
|
||||
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import (
|
||||
StringField,
|
||||
SelectField,
|
||||
RadioField,
|
||||
TextAreaField,
|
||||
validators,
|
||||
SubmitField,
|
||||
)
|
||||
from wtforms import SelectField, RadioField, TextAreaField, validators, SubmitField
|
||||
|
||||
from app.forms import ScoDateField, ScoTimeField
|
||||
from app.scodoc.sco_utils import EtatAssiduite
|
||||
|
||||
|
||||
@ -60,63 +55,13 @@ class EditAssiForm(FlaskForm):
|
||||
"maxlength": 500,
|
||||
},
|
||||
)
|
||||
date_debut = StringField(
|
||||
"Date de début",
|
||||
validators=[validators.Length(max=10)],
|
||||
render_kw={
|
||||
"class": "datepicker",
|
||||
"size": 10,
|
||||
"id": "assi_date_debut",
|
||||
},
|
||||
)
|
||||
heure_debut = StringField(
|
||||
"Heure début",
|
||||
default="",
|
||||
validators=[validators.Length(max=5)],
|
||||
render_kw={
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": "assi_heure_debut",
|
||||
},
|
||||
)
|
||||
heure_fin = StringField(
|
||||
"Heure fin",
|
||||
default="",
|
||||
validators=[validators.Length(max=5)],
|
||||
render_kw={
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": "assi_heure_fin",
|
||||
},
|
||||
)
|
||||
date_fin = StringField(
|
||||
"Date de fin",
|
||||
validators=[validators.Length(max=10)],
|
||||
render_kw={
|
||||
"class": "datepicker",
|
||||
"size": 10,
|
||||
"id": "assi_date_fin",
|
||||
},
|
||||
)
|
||||
entry_date = StringField(
|
||||
"Date de dépôt ou saisie",
|
||||
validators=[validators.Length(max=10)],
|
||||
render_kw={
|
||||
"class": "datepicker",
|
||||
"size": 10,
|
||||
"id": "entry_date",
|
||||
},
|
||||
)
|
||||
entry_time = StringField(
|
||||
"Heure dépôt",
|
||||
default="",
|
||||
validators=[validators.Length(max=5)],
|
||||
render_kw={
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": "assi_heure_fin",
|
||||
},
|
||||
)
|
||||
date_debut = ScoDateField("Date de début", "assi_date_debut")
|
||||
heure_debut = ScoTimeField("Heure début", "assi_heure_debut")
|
||||
heure_fin = ScoTimeField("Heure fin", "assi_heure_fin")
|
||||
|
||||
date_fin = ScoDateField("Date de fin", "assi_date_fin")
|
||||
entry_date = ScoDateField("Date de dépôt ou saisie", "entry_date")
|
||||
entry_time = ScoTimeField("Heure dépôt", "entry_time")
|
||||
|
||||
submit = SubmitField("Enregistrer")
|
||||
cancel = SubmitField("Annuler", render_kw={"formnovalidate": True})
|
||||
|
@ -28,7 +28,6 @@
|
||||
"""
|
||||
Formulaire configuration Module Assiduités
|
||||
"""
|
||||
import datetime
|
||||
import re
|
||||
|
||||
from flask_wtf import FlaskForm
|
||||
@ -36,7 +35,7 @@ from wtforms import DecimalField, SubmitField, ValidationError
|
||||
from wtforms.fields.simple import StringField
|
||||
from wtforms.validators import Optional, Length
|
||||
|
||||
from wtforms.widgets import TimeInput
|
||||
from app.forms import ScoDateField, ScoTimeField
|
||||
|
||||
|
||||
def check_tick_time(form, field):
|
||||
@ -77,36 +76,11 @@ def check_ics_regexp(form, field):
|
||||
|
||||
class ConfigAssiduitesForm(FlaskForm):
|
||||
"Formulaire paramétrage Module Assiduité"
|
||||
assi_morning_time = StringField(
|
||||
"Début de la journée",
|
||||
default="",
|
||||
validators=[Length(max=5)],
|
||||
render_kw={
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": "assi_morning_time",
|
||||
},
|
||||
)
|
||||
assi_lunch_time = StringField(
|
||||
"Heure de midi (date pivot entre matin et après-midi)",
|
||||
default="",
|
||||
validators=[Length(max=5)],
|
||||
render_kw={
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": "assi_lunch_time",
|
||||
},
|
||||
)
|
||||
assi_afternoon_time = StringField(
|
||||
"Fin de la journée",
|
||||
validators=[Length(max=5)],
|
||||
default="",
|
||||
render_kw={
|
||||
"class": "timepicker",
|
||||
"size": 5,
|
||||
"id": "assi_afternoon_time",
|
||||
},
|
||||
assi_morning_time = ScoTimeField("Début de la journée", "assi_morning_time")
|
||||
assi_lunch_time = ScoTimeField(
|
||||
"Heure de midi (date pivot entre matin et après-midi)", "assi_lunch_time"
|
||||
)
|
||||
assi_afternoon_time = ScoTimeField("Fin de la journée", "assi_afternoon_time")
|
||||
|
||||
assi_tick_time = DecimalField(
|
||||
"Granularité de la timeline (temps en minutes)",
|
||||
|
@ -6,8 +6,9 @@
|
||||
{{ super() }}
|
||||
|
||||
<style>
|
||||
td.ue_s1 {
|
||||
color: red;
|
||||
table.gt_table {
|
||||
border: 2px solid rgb(193, 165, 165);
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
/* bordures entre semestres */
|
||||
@ -32,7 +33,7 @@ table.dataTable tbody tr:nth-child(odd) td.dtfc-fixed-start {
|
||||
}
|
||||
table.dataTable tbody tr:nth-child(even),
|
||||
table.dataTable tbody tr:nth-child(even) td.dtfc-fixed-start {
|
||||
background-color: rgb(253, 255, 240);
|
||||
background-color: rgb(254, 255, 246);
|
||||
}
|
||||
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user