From 17dd73f4749dcb98cd64377c5e201a81544001d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 9 Nov 2016 17:01:03 +0100 Subject: [PATCH] Task types are now determined by the page context, not hard-coded to shot task types --- attract/setup.py | 3 ++- attract/tasks/routes.py | 13 ++++++++++++- src/templates/attract/tasks/view_task_embed.jade | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/attract/setup.py b/attract/setup.py index 4297ecc..3966719 100644 --- a/attract/setup.py +++ b/attract/setup.py @@ -67,7 +67,7 @@ def setup_for_attract(project_url, replace=False, svn_url=None): Returns the updated project. """ - from .node_types import NODE_TYPES, shot + from .node_types import NODE_TYPES, shot, asset # Copy permissions from the project, then give everyone with PUT # access also DELETE access. @@ -103,6 +103,7 @@ def setup_for_attract(project_url, replace=False, svn_url=None): # Set up task types task_types = attract_props.setdefault('task_types', {}) task_types.setdefault(shot.node_type_shot['name'], shot.task_types) + task_types.setdefault(asset.node_type_asset['name'], asset.task_types) _update_project(project) diff --git a/attract/tasks/routes.py b/attract/tasks/routes.py index 901e7e2..1c142f4 100644 --- a/attract/tasks/routes.py +++ b/attract/tasks/routes.py @@ -13,7 +13,7 @@ import pillar.web.subquery from attract.routes import attract_project_view from attract.node_types.task import node_type_task -from attract import current_attract, ROLES_REQUIRED_TO_VIEW_ITEMS +from attract import current_attract, ROLES_REQUIRED_TO_VIEW_ITEMS, EXTENSION_NAME blueprint = Blueprint('attract.tasks', __name__, url_prefix='/tasks') perproject_blueprint = Blueprint('attract.tasks.perproject', __name__, @@ -67,6 +67,16 @@ def view_task(project, attract_props, task_id): task = pillarsdk.Node.find(task_id, api=api) node_type = project.get_node_type(node_type_task['name']) + # Figure out which task types are available, defaulting to the shot task types. + context = request.args.get('context', None) or 'shot' + ctx_node_type_name = '%s_%s' % (EXTENSION_NAME, context) + try: + task_types = attract_props['task_types'][ctx_node_type_name] + except KeyError: + log.warning('Project %s does not have an Attract task type definition for %s', + project['_id'], ctx_node_type_name) + task_types = [] + if task.properties.due_date: task.properties.due_date = parser.parse('%s' % task.properties.due_date) @@ -87,6 +97,7 @@ def view_task(project, attract_props, task_id): task=task, project=project, task_node_type=node_type, + task_types=task_types, attract_props=attract_props.to_dict(), attract_context=request.args.get('context')) diff --git a/src/templates/attract/tasks/view_task_embed.jade b/src/templates/attract/tasks/view_task_embed.jade index 3dfbab0..173029b 100644 --- a/src/templates/attract/tasks/view_task_embed.jade +++ b/src/templates/attract/tasks/view_task_embed.jade @@ -57,10 +57,10 @@ .input-group.field-type label#task-task_type Type: select(name="task_type",aria-describedby="task-task_type") - | {% for task_type in attract_props.task_types.attract_shot %} + | {% for task_type in task_types %} | | {% endfor %} - | {% if task.properties.task_type not in attract_props.task_types.attract_shot %} + | {% if task.properties.task_type not in task_types %} option(value="{{ task.properties.task_type }}",selected).invalid_task {{ task.properties.task_type | undertitle }} | {% endif %}