Commit 896bfbbe authored by Gabriel Detraz's avatar Gabriel Detraz

Popup mineur

parent 9bceee60
......@@ -379,7 +379,7 @@ class Dialog(object):
)
@tailcaller
def get_timestamp(self, title, text, cont, hour=-1, minute=-1, second=-1, day=0, month=0, year=0):
def get_timestamp(self, title, text, cont, hour=-1, minute=-1, second=-1, day=0, month=0, year=0, date_only=False):
"""Fait choisir une date et une heure et retourne le tuple (year, month, day, hour, minute, second)"""
retry_cont = TailCall(self.get_timestamp, title=title, text=text, cont=cont, hour=hour,
minute=minute, second=second, day=day, month=month, year=year)
......@@ -404,7 +404,10 @@ class Dialog(object):
else:
raise EnvironmentError("Pourquoi je n'ai pas d'horaire ?")
(year, month, day) = get_date(day, month, year)
(hour, minute, second) = get_time(hour, minute, second, day, month, year)
if date_only:
(hour, minute, second) = (0, 0, 0)
else:
(hour, minute, second) = get_time(hour, minute, second, day, month, year)
return (year, month, day) + (hour, minute, second)
def confirm(self, text, title, defaultno=False, width=0, height=0):
......
......@@ -30,6 +30,8 @@ import lc_ldap.crans_utils as lc_utils
from lc_ldap.attributs import UniquenessError
import datetime
from dateutil.relativedelta import relativedelta
import machine
import blacklist
......@@ -892,6 +894,17 @@ class Dialog(machine.Dialog, blacklist.Dialog):
else:
make_compte_crans = False
debut_tuple = self.get_timestamp(title="Création d'un utilisateur", text="Choisir la date de naissance", cont=cont, date_only=True)
naissance_date = datetime.date(debut_tuple[0], debut_tuple[1], debut_tuple[2])
if relativedelta(datetime.date.today(), naissance_date).years < 18:
if self.dialog.yesno(
text="\Zr\Z1AVERTISSEMENT :\Zn \nL'adhérent est mineur, vous DEVEZ disposer d'une autorisation parentale écrite\n\n\n\ZnContinuer ?",
title="Création d'un utilisateur",
defaultno=True,
width=70,
colors=True, timeout=self.timeout) != self.dialog.DIALOG_OK:
raise Continue(cont)
fields = [(
"%s %s:" % (a.legend, '(optionnel) ' if a.optional else ''),
fields_attrs.get(a, separateur.join(attrs.get(a.ldap_name, [a.default] if a.default else []))),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment