diff --git a/jm2l/__init__.py b/jm2l/__init__.py index bc33bfb..8ee5921 100644 --- a/jm2l/__init__.py +++ b/jm2l/__init__.py @@ -111,12 +111,12 @@ def main(global_config, **settings): # HTML Routes - Staff config.add_route('Live', '/Live') - config.add_route('list_expenses', '/Staff/compta') - config.add_route('list_task', '/Staff') - config.add_route('handle_pole', '/Staff/poles{sep:/*}{pole_id:(\d+)?}') - config.add_route('handle_task', '/Staff/tasks{sep:/*}{task_id:(\d+)?}') - config.add_route('action_task', '/Staff/{action:(\w+)}/{task_id:(\d+)}') - config.add_route('action_task_area', '/Staff/pole/{action:(\w+)}/{pole_id:(\d+)}') + config.add_route('list_expenses', '/{year:\d+}/Staff/compta') + config.add_route('list_task', '/{year:\d+}/Staff') + config.add_route('handle_pole', '/{year:\d+}/Staff/poles{sep:/*}{pole_id:(\d+)?}') + config.add_route('handle_task', '/{year:\d+}/Staff/tasks{sep:/*}{task_id:(\d+)?}') + config.add_route('action_task', '/{year:\d+}/Staff/{action:(\w+)}/{task_id:(\d+)}') + config.add_route('action_task_area', '/{year:\d+}/Staff/pole/{action:(\w+)}/{pole_id:(\d+)}') config.add_route('list_salles', '/ListSalles') config.add_route('handle_salle', '/Salles{sep:/*}{salle_id:(\d+)?}') diff --git a/jm2l/forms.py b/jm2l/forms.py index d743af3..f87f56e 100644 --- a/jm2l/forms.py +++ b/jm2l/forms.py @@ -8,13 +8,14 @@ from wtforms.validators import ValidationError strip_filter = lambda x: x.strip() if x else None from wtforms.csrf.session import SessionCSRF from datetime import timedelta +from jm2l.const import CurrentYear class MyBaseForm(Form): class Meta: csrf = True csrf_class = SessionCSRF csrf_secret = b'lJDQtOAMC2qe89doIn8u3Mch_DgeLSKO' - csrf_time_limit = timedelta(minutes=20) + csrf_time_limit = timedelta(minutes=60) class BlogCreateForm(MyBaseForm): title = TextField('Entry title', [validators.Length(min=1, max=255)], @@ -53,6 +54,7 @@ class StaffArea(MyBaseForm): description = TextAreaField('Description', [validators.optional(), validators.Length(max=1000000)], filters=[strip_filter] ) + year_uid = HiddenField('year', default=str(CurrentYear)) class EditStaffArea(StaffArea): uid = HiddenField() @@ -64,12 +66,13 @@ class StaffTasks(MyBaseForm): due_date = DateField(u'Date prévue', format='%d/%m/%Y') description = TextAreaField('Description', [validators.optional(), validators.Length(max=1000000)], filters=[strip_filter]) + year_uid = HiddenField('year', default=str(CurrentYear)) class EditStaffTasks(StaffTasks): uid = HiddenField() class DossPresse(MyBaseForm): - year_uid = HiddenField() + year_uid = HiddenField() doss_presse = TextAreaField('Dossier de Presse', [validators.optional(), validators.Length(max=1000000)], filters=[strip_filter]) @@ -82,7 +85,7 @@ class TiersMember(MyBaseForm): class Meta: csrf = False - year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,2016),range(2006,2016))) + year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,CurrentYear+1),range(2006,CurrentYear+1))) user_uid = TextField(u'user') role = TextField(u'Role') @@ -90,7 +93,7 @@ class TiersRole(MyBaseForm): class Meta: csrf = False - year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,2016),range(2006,2016))) + year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,CurrentYear+1),range(2006,CurrentYear+1))) tiers_role = SelectField(u'Role', choices=TIERS_ROLE) class TiersChoice(MyBaseForm): diff --git a/jm2l/models.py b/jm2l/models.py index ec6800a..cd1f5d8 100644 --- a/jm2l/models.py +++ b/jm2l/models.py @@ -39,6 +39,7 @@ Base = declarative_base() class TasksArea(Base): __tablename__ = 'staff_tasks_area' uid = Column(Integer, primary_key=True) + year_uid = Column(Integer, ForeignKey('jm2l_year.year_uid'), default=CurrentYear) name = Column(Unicode(80)) description = Column(UnicodeText) @@ -50,6 +51,7 @@ class Tasks(Base): __tablename__ = 'staff_tasks' uid = Column(Integer, primary_key=True) area_uid = Column(Integer, ForeignKey('staff_tasks_area.uid') ) + year_uid = Column(Integer, ForeignKey('jm2l_year.year_uid'), default=CurrentYear) due_date = Column(DateTime, default=None) closed_by = Column(Integer, ForeignKey('users.uid') ) closed_date = Column(DateTime, default=None) diff --git a/jm2l/templates/Staff/list.mako b/jm2l/templates/Staff/list.mako index 0efb6f9..12d1e5b 100644 --- a/jm2l/templates/Staff/list.mako +++ b/jm2l/templates/Staff/list.mako @@ -3,7 +3,7 @@ <% from slugify import slugify %> - + Ajouter un Pôle d'activité