From bf9a73ff006c5567f5c22d88742b4799472a672b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 15 Jun 2017 10:34:53 +0200 Subject: [PATCH] Fixed project property loss when setting up for Attract This was caused by attract_project_view() not passing the full project to the decorated function. Now you can pass full_project=True to avoid projections at all, and get the full thing. --- attract/routes.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/attract/routes.py b/attract/routes.py index 689102d..58c43f6 100644 --- a/attract/routes.py +++ b/attract/routes.py @@ -72,7 +72,8 @@ def error_project_not_setup_for_attract(): return render_template('attract/errors/project_not_setup.html') -def attract_project_view(extra_project_projections=None, extension_props=False): +def attract_project_view(extra_project_projections: dict=None, extension_props=False, *, + full_project=False): """Decorator, replaces the first parameter project_url with the actual project. Assumes the first parameter to the decorated function is 'project_url'. It then @@ -84,10 +85,9 @@ def attract_project_view(extra_project_projections=None, extension_props=False): :param extra_project_projections: extra projections to use on top of the ones already used by this decorator. - :type extra_project_projections: dict :param extension_props: whether extension properties should be included. Includes them in the projections, and verifies that they are there. - :type extension_props: bool + :param full_project: skip projections altogether, fetching the whole project. """ from . import EXTENSION_NAME @@ -119,9 +119,10 @@ def attract_project_view(extra_project_projections=None, extension_props=False): api = pillar_api() + projection_param = None if full_project else {'projection': projections} project = pillarsdk.Project.find_by_url( project_url, - {'projection': projections}, + projection_param, api=api) is_attract = current_attract.is_attract_project(project, @@ -190,7 +191,7 @@ def project_settings(project: pillarsdk.Project, **template_args: dict): @blueprint.route('///set-task-types', methods=['POST']) -@attract_project_view(extension_props=True) +@attract_project_view(extension_props=True, full_project=True) def save_task_types(project, attract_props, node_type_name: str): from . import EXTENSION_NAME from . import setup