From b7c6402453f5b816c0c7b2c60597d92dfef44107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 11 Oct 2016 15:36:24 +0200 Subject: [PATCH] Remove "create task" buttons when user has no rights to create tasks. Has some dirty hacks to infer the permissions based on the allowed methods on shots/project. --- src/templates/attract/shots/for_project.jade | 3 +++ src/templates/attract/tasks/for_project.jade | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/templates/attract/shots/for_project.jade b/src/templates/attract/shots/for_project.jade index e75f2a5..c4034ab 100644 --- a/src/templates/attract/shots/for_project.jade +++ b/src/templates/attract/shots/for_project.jade @@ -53,11 +53,14 @@ class="status-{{ task.properties.status }} task-link", title="Task: {{ task.name }}") | {% endfor %} + //- Dirty hack, assume a user can create a task for a shot if they can edit the shot. + | {% if 'PUT' in shot.allowed_methods %} a.task-add( title="Add a new '{{ task_type }}' task", class="task-add-link {% if tasks_for_shots[shot._id][task_type] %}hidden{% endif %}" href="javascript:task_create('{{ shot._id }}', '{{ task_type }}');") | + Task + | {% endif %} | {% endfor %} | {% endfor %} diff --git a/src/templates/attract/tasks/for_project.jade b/src/templates/attract/tasks/for_project.jade index 7e4f33b..310a78b 100644 --- a/src/templates/attract/tasks/for_project.jade +++ b/src/templates/attract/tasks/for_project.jade @@ -6,9 +6,10 @@ .col_header.task-list-header | Tasks a.task-project(href="{{url_for('projects.view', project_url=project.url)}}") {{ project.name }} - + //- Dirty hack, assume a user can create a task if they can edit the project. + | {% if 'PUT' in project.allowed_methods %} a#task-add(href="javascript:task_create(undefined, 'generic');") + Create Task - + | {% endif %} #task-list.col-list | {% for task in tasks %} //- NOTE: this is tightly linked to the JS in tasks.js, function task_add()