From cc59c029b0057f76d4d336b5f28081bcc756e80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 11 Oct 2016 14:16:30 +0200 Subject: [PATCH] Show tasks as read-only when user has no PUT access. Still pretty rough. Most importantly, users are shown as hashes rather than their names. --- .../attract/tasks/view_task_embed.jade | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/templates/attract/tasks/view_task_embed.jade b/src/templates/attract/tasks/view_task_embed.jade index 109f097..48f374e 100644 --- a/src/templates/attract/tasks/view_task_embed.jade +++ b/src/templates/attract/tasks/view_task_embed.jade @@ -2,14 +2,19 @@ class="status-{{ task.properties.status }}") form#task_form(onsubmit="return task_save('{{task._id}}', '{{ url_for('attract.tasks.perproject.save', project_url=project['url'], task_id=task._id) }}')") input(type='hidden',name='_etag',value='{{ task._etag }}') + //- NOTE: if you add fields here, also add them read-only below. .input-transparent-group + | {% if 'PUT' in task.allowed_methods %} input.input-transparent.item-name( name="name", type="text", placeholder='Name', value="{{ task.name | hide_none }}") + | {% else %} + h2 {{ task.name | hide_none }} + | {% endif %} - .dropdown + .dropdown(style='margin-left: auto') button#item-dropdown.btn.btn-default.dropdown-toggle( type='button', data-toggle='dropdown', @@ -28,6 +33,7 @@ | Delete Task | {% endif %} + | {% if 'PUT' in task.allowed_methods %} .input-transparent-group textarea.input-transparent( name="description", @@ -67,17 +73,28 @@ | | {% endfor %} - - | {% if 'PUT' in task.allowed_methods %} .input-group-separator .input-transparent-group button.btn.btn-default.btn-block(type='submit') i.pi-check | Save Task + | {% else %} + //- NOTE: read-only versions of the fields above. + p {{ task.description | hide_none }} + dl.dl-horizontal.item-properties + dt Type: + dd {{ task.properties.task_type | undertitle }} + dt Status: + dd {{ task.properties.status | undertitle }} + dt Assignees: + | {% for u in task.properties.assigned_to['users'] %} + dd {{ u }} + | {% else %} + dd not assigned + | {% endfor %} | {% endif %} - #item-view-feed | Task updated {{ task._updated | pretty_date }} | {% if config.DEBUG %}