aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2015-03-01 03:05:46 +0100
committerpiernov <piernov@piernov.org>2015-03-01 03:05:46 +0100
commit85c3f9068fae9c153edcff6579fd6e50f051b1d9 (patch)
tree914ed798b58ea8a4751373956c9bab0d495367fa
parent3bef68914eeda2605ea1fbf7cad2d99ed3cbfb79 (diff)
downloadjm2l-85c3f9068fae9c153edcff6579fd6e50f051b1d9.tar.gz
jm2l-85c3f9068fae9c153edcff6579fd6e50f051b1d9.tar.bz2
jm2l-85c3f9068fae9c153edcff6579fd6e50f051b1d9.tar.xz
jm2l-85c3f9068fae9c153edcff6579fd6e50f051b1d9.zip
"Retour à la liste" link now goes back to the previous area + current area now being selected when creating new task
-rw-r--r--jm2l/templates/Staff/list.mako4
-rw-r--r--jm2l/templates/Staff/tasks.mako4
-rw-r--r--jm2l/views.py25
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
<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
@@ -95,4 +95,4 @@ from slugify import slugify
$('a[href="' + location.hash + '"]').tab('show');
}
</script>
-</%def> \ No newline at end of file
+</%def>
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 @@
<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:
@@ -57,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/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')