From 4d448b614e0e84b3c8ad004744601bf19728ea19 Mon Sep 17 00:00:00 2001 From: piernov Date: Sat, 28 Feb 2015 23:25:05 +0100 Subject: Staff task name mandatory --- jm2l/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jm2l/forms.py b/jm2l/forms.py index acb60f1..304a060 100644 --- a/jm2l/forms.py +++ b/jm2l/forms.py @@ -57,7 +57,7 @@ class EditStaffArea(StaffArea): uid = HiddenField() class StaffTasks(MyBaseForm): - name = TextField(u'Nom de la tâche') + name = TextField(u'Nom de la tâche', [validators.Required()]) area_uid = SelectField(u'Pôle concerné', coerce=int ) closed_by = SelectField(u'Assigné à', coerce=int ) due_date = DateField(u'Date prévue', format='%d/%m/%Y') -- cgit v1.2.3-70-g09d2 From 3bef68914eeda2605ea1fbf7cad2d99ed3cbfb79 Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 1 Mar 2015 01:25:09 +0100 Subject: Add date picker using webshim --- jm2l/forms.py | 2 +- jm2l/static/css/jm2l.css | 10 ++++++++++ jm2l/templates/Staff/tasks.mako | 15 +++++++++++++++ jm2l/templates/helpers.mako | 8 ++++---- jm2l/views.py | 1 + 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/jm2l/forms.py b/jm2l/forms.py index 304a060..4109527 100644 --- a/jm2l/forms.py +++ b/jm2l/forms.py @@ -60,7 +60,7 @@ class StaffTasks(MyBaseForm): name = TextField(u'Nom de la tâche', [validators.Required()]) area_uid = SelectField(u'Pôle concerné', coerce=int ) closed_by = SelectField(u'Assigné à', coerce=int ) - due_date = DateField(u'Date prévue', format='%d/%m/%Y') + due_date = DateField(u'Date prévue', format='%Y-%m-%d') description = TextAreaField('Description', [validators.optional(), validators.Length(max=1000000)], filters=[strip_filter]) diff --git a/jm2l/static/css/jm2l.css b/jm2l/static/css/jm2l.css index 016073c..33df5da 100644 --- a/jm2l/static/css/jm2l.css +++ b/jm2l/static/css/jm2l.css @@ -143,3 +143,13 @@ a { text-align: right; display: inline-block; } + +/* Fix calendar button vertical pos */ +.date-input-buttons { + margin-bottom: 0.7em; +} + +/* Calendar button looks better without that gray background */ +.ws-popover-opener { + background: none; +} diff --git a/jm2l/templates/Staff/tasks.mako b/jm2l/templates/Staff/tasks.mako index 375d241..0f26c54 100644 --- a/jm2l/templates/Staff/tasks.mako +++ b/jm2l/templates/Staff/tasks.mako @@ -5,6 +5,21 @@ + + + <%def name="cssAddOn()"> diff --git a/jm2l/templates/helpers.mako b/jm2l/templates/helpers.mako index 525ea62..a8623d7 100644 --- a/jm2l/templates/helpers.mako +++ b/jm2l/templates/helpers.mako @@ -39,12 +39,12 @@ TabJs = {'select':[], 'desc':[]} <% PlaceHolder = DicFormat[Field.name].get("PlaceHolder") FieldStyle = DicFormat[Field.name].get("FieldStyle") - Class = [None,"ckeditor"][ DicFormat[Field.name].has_key("ckeditor") ] + Class = [False,"ckeditor"][ "ckeditor" in DicFormat[Field.name] ] %> - % if PlaceHolder: - ${Field(placeholder=PlaceHolder, style=FieldStyle, class_=Class)} + % if Field.type == "DateField": + ${Field(placeholder=PlaceHolder or False, style=FieldStyle, class_=Class, type = "date")} % else: - ${Field(style=FieldStyle, class_=Class)} + ${Field(placeholder=PlaceHolder or False, style=FieldStyle, class_=Class)} % endif % else: ${Field()} diff --git a/jm2l/views.py b/jm2l/views.py index e3485ae..7c89c40 100644 --- a/jm2l/views.py +++ b/jm2l/views.py @@ -294,6 +294,7 @@ def tasks(request): .order_by('nom').all() form.closed_by.choices = [(u.uid, "%s %s" % (u.nom, u.prenom)) for u in Users] + form.due_date.type = "date" if request.method == 'POST' and form.validate(): form.populate_obj(Task) Task.closed = False -- cgit v1.2.3-70-g09d2 From 85c3f9068fae9c153edcff6579fd6e50f051b1d9 Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 1 Mar 2015 03:05:46 +0100 Subject: "Retour à la liste" link now goes back to the previous area + current area now being selected when creating new task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jm2l/templates/Staff/list.mako | 4 ++-- jm2l/templates/Staff/tasks.mako | 4 ++-- jm2l/views.py | 25 +++++++++++++++++++------ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/jm2l/templates/Staff/list.mako b/jm2l/templates/Staff/list.mako index a7abbf9..fbee9e5 100644 --- a/jm2l/templates/Staff/list.mako +++ b/jm2l/templates/Staff/list.mako @@ -32,7 +32,7 @@ from slugify import slugify - + Ajouter une tâche Liste des tâches @@ -95,4 +95,4 @@ from slugify import slugify $('a[href="' + location.hash + '"]').tab('show'); } - \ No newline at end of file + diff --git a/jm2l/templates/Staff/tasks.mako b/jm2l/templates/Staff/tasks.mako index 0f26c54..30da49d 100644 --- a/jm2l/templates/Staff/tasks.mako +++ b/jm2l/templates/Staff/tasks.mako @@ -30,7 +30,7 @@ -Retour à la liste +Retour à la liste % if 'uid' in form._fields.keys():

Editer une tâche

% else: @@ -57,4 +57,4 @@ DicForm = { % if 'uid' in form._fields.keys(): ${helpers.uploader("tasks", form.uid.data, u"une pièce jointe" )} -%endif \ No newline at end of file +%endif diff --git a/jm2l/views.py b/jm2l/views.py index 7c89c40..f6bae52 100644 --- a/jm2l/views.py +++ b/jm2l/views.py @@ -276,6 +276,20 @@ def list_view(request): @view_config(route_name='handle_task', renderer='jm2l:templates/Staff/tasks.mako') def tasks(request): task_id = request.matchdict.get('task_id') + # Convert the pole_id GET parameter to int or 0 + try: + pole_id = int(request.params.get('pole_id')) + except (ValueError, TypeError): + pole_id = 0 + + # Get areas from db + Areas = DBSession.query(TasksArea.uid, TasksArea.name)\ + .order_by('name').all() + # Get users from db + Users = DBSession.query(User)\ + .filter(User.Staff==1)\ + .order_by('nom').all() + if task_id: Task = Tasks.by_id(int(task_id)) if not Task: @@ -283,17 +297,16 @@ def tasks(request): form = EditStaffTasks(request.POST, Task, meta={'csrf_context': request.session}) else: Task = Tasks() + # Check if the supplied pole_id is in the Areas' range + Task.area_uid = pole_id if 1 < pole_id <= len(Areas) else 1 form = StaffTasks(request.POST, Task, meta={'csrf_context': request.session}) + # Put some areas on form - Areas = DBSession.query(TasksArea.uid, TasksArea.name)\ - .order_by('name').all() form.area_uid.choices = Areas # Put some users on form - Users = DBSession.query(User)\ - .filter(User.Staff==1)\ - .order_by('nom').all() form.closed_by.choices = [(u.uid, "%s %s" % (u.nom, u.prenom)) for u in Users] + form.due_date.type = "date" if request.method == 'POST' and form.validate(): form.populate_obj(Task) @@ -304,7 +317,7 @@ def tasks(request): DBSession.add(Task) DBSession.flush() return HTTPFound(location=request.route_url('list_task')+"#"+slugify(Task.area.name)) - return {'form':form } + return {'form':form, 'area':slugify(Areas[Task.area_uid-1].name)} @view_config(route_name='handle_pole', renderer='jm2l:templates/Staff/pole.mako') -- cgit v1.2.3-70-g09d2