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é

Liste des tâches JM2L Staff

@@ -24,7 +24,7 @@ from slugify import slugify % for Num, Entity in enumerate(sorted(tasks.keys(), key=lambda x:x.name)):
- + Editer le pôle

${Entity.name}

@@ -35,7 +35,7 @@ from slugify import slugify - + Ajouter une tâche Liste des tâches @@ -54,11 +54,11 @@ from slugify import slugify % if task.closed: - + ${task.name} % else: - + ${task.name} @@ -70,9 +70,9 @@ from slugify import slugify
% if task.closed: - [ ré-ouvrir ] + [ ré-ouvrir ] % else: - [ c'est fait ] + [ c'est fait ] % endif
@@ -97,7 +97,7 @@ from slugify import slugify $('a[data-toggle="tab"]') .on('shown', function(e) { //stateObj = { tab: $(e.target).attr('href').substr(1) }; - //history.replaceState(stateObj, "", "/Staff" + $(e.target).attr('href') ); + //history.replaceState(stateObj, "", "/${year}/Staff" + $(e.target).attr('href') ); location.hash = $(e.target).attr('href'); }); diff --git a/jm2l/templates/Staff/new.mako b/jm2l/templates/Staff/new.mako index 6c2c3b1..37e44dd 100644 --- a/jm2l/templates/Staff/new.mako +++ b/jm2l/templates/Staff/new.mako @@ -6,7 +6,8 @@

Add a new task

-
+ +
diff --git a/jm2l/templates/Staff/pole.mako b/jm2l/templates/Staff/pole.mako index 9a00cde..eef53c6 100644 --- a/jm2l/templates/Staff/pole.mako +++ b/jm2l/templates/Staff/pole.mako @@ -19,11 +19,11 @@
- + Retour à la liste % if 'uid' in form._fields.keys(): - + Supprimer ce pôle

Editer un Pôle

@@ -38,10 +38,10 @@ DicForm = { %> % if 'uid' in form._fields.keys(): -
+ ${form.uid()} %else: - + %endif ${helpers.DisplayForm(form, DicForm)} diff --git a/jm2l/templates/Staff/tasks.mako b/jm2l/templates/Staff/tasks.mako index 772f0aa..696962d 100644 --- a/jm2l/templates/Staff/tasks.mako +++ b/jm2l/templates/Staff/tasks.mako @@ -29,11 +29,11 @@
- + Retour à la liste % if 'uid' in form._fields.keys(): - + Supprimer cette tâche %endif @@ -56,10 +56,10 @@ DicForm = { %> % if 'uid' in form._fields.keys(): - + ${form.uid()} %else: - + %endif ${helpers.DisplayForm(form, DicForm)} diff --git a/jm2l/templates/layout.mako b/jm2l/templates/layout.mako index 734c8da..a9b541b 100644 --- a/jm2l/templates/layout.mako +++ b/jm2l/templates/layout.mako @@ -120,12 +120,12 @@ ${helpers.uploader_js()}