aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jm2l/forms.py4
-rw-r--r--jm2l/static/css/jm2l.css10
-rw-r--r--jm2l/templates/Staff/list.mako2
-rw-r--r--jm2l/templates/Staff/tasks.mako19
-rw-r--r--jm2l/templates/helpers.mako8
-rw-r--r--jm2l/views.py26
6 files changed, 54 insertions, 15 deletions
diff --git a/jm2l/forms.py b/jm2l/forms.py
index acb60f1..4109527 100644
--- a/jm2l/forms.py
+++ b/jm2l/forms.py
@@ -57,10 +57,10 @@ 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')
+ 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/list.mako b/jm2l/templates/Staff/list.mako
index 6746bea..712e488 100644
--- a/jm2l/templates/Staff/list.mako
+++ b/jm2l/templates/Staff/list.mako
@@ -32,7 +32,7 @@ from slugify import slugify
<thead>
<tr>
<th colspan="2" style="text-align:center;">
- <a style="float:right;" class="btn btn-mini btn-info" role="button" href="/Staff/tasks">
+ <a style="float:right;" class="btn btn-mini btn-info" role="button" href="${request.route_path('handle_task', sep="", task_id="", _query={"pole_id":Entity.uid})}">
<i class="icon-plus-sign icon-white"></i> Ajouter une tâche
</a>
Liste des tâches
diff --git a/jm2l/templates/Staff/tasks.mako b/jm2l/templates/Staff/tasks.mako
index 375d241..30da49d 100644
--- a/jm2l/templates/Staff/tasks.mako
+++ b/jm2l/templates/Staff/tasks.mako
@@ -5,6 +5,21 @@
<script src="/js/jm2l.js"></script>
<script src="/vendor/ckeditor/ckeditor.js"></script>
<script src="/vendor/select2/js/select2.js"></script>
+
+ <script src="//cdn.jsdelivr.net/webshim/1.15.7/polyfiller.js"></script>
+ <script type="text/javascript">
+ webshim.setOptions('forms-ext', {
+ replaceUI: 'auto',
+ types: 'date',
+ date: {
+ startView: 2,
+ classes: 'hide-spinbtns',
+ }
+ });
+
+ //start polyfilling
+ webshim.polyfill('forms-ext');
+ </script>
</%def>
<%def name="cssAddOn()">
<link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload.css">
@@ -15,7 +30,7 @@
<noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-noscript.css"></noscript>
<noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-ui-noscript.css"></noscript>
</%def>
-<a style="float:right;" href="/Staff">Retour à la liste</a>
+<a style="float:right;" href="${request.route_path('list_task', _anchor=area)}">Retour à la liste</a>
% if 'uid' in form._fields.keys():
<h3>Editer une tâche</h3>
% else:
@@ -42,4 +57,4 @@ DicForm = {
</form>
% 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/templates/helpers.mako b/jm2l/templates/helpers.mako
index 0f7007f..78a5262 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"][ "ckeditor" in DicFormat[Field.name] ]
+ 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 32ee9a5..6889a1e 100644
--- a/jm2l/views.py
+++ b/jm2l/views.py
@@ -275,6 +275,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:
@@ -282,17 +296,17 @@ 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)
Task.closed = False
@@ -302,7 +316,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')