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.
This commit is contained in:
@@ -72,7 +72,8 @@ def error_project_not_setup_for_attract():
|
|||||||
return render_template('attract/errors/project_not_setup.html')
|
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.
|
"""Decorator, replaces the first parameter project_url with the actual project.
|
||||||
|
|
||||||
Assumes the first parameter to the decorated function is 'project_url'. It then
|
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
|
:param extra_project_projections: extra projections to use on top of the ones already
|
||||||
used by this decorator.
|
used by this decorator.
|
||||||
:type extra_project_projections: dict
|
|
||||||
:param extension_props: whether extension properties should be included. Includes them
|
:param extension_props: whether extension properties should be included. Includes them
|
||||||
in the projections, and verifies that they are there.
|
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
|
from . import EXTENSION_NAME
|
||||||
@@ -119,9 +119,10 @@ def attract_project_view(extra_project_projections=None, extension_props=False):
|
|||||||
|
|
||||||
api = pillar_api()
|
api = pillar_api()
|
||||||
|
|
||||||
|
projection_param = None if full_project else {'projection': projections}
|
||||||
project = pillarsdk.Project.find_by_url(
|
project = pillarsdk.Project.find_by_url(
|
||||||
project_url,
|
project_url,
|
||||||
{'projection': projections},
|
projection_param,
|
||||||
api=api)
|
api=api)
|
||||||
|
|
||||||
is_attract = current_attract.is_attract_project(project,
|
is_attract = current_attract.is_attract_project(project,
|
||||||
@@ -190,7 +191,7 @@ def project_settings(project: pillarsdk.Project, **template_args: dict):
|
|||||||
|
|
||||||
|
|
||||||
@blueprint.route('/<project_url>/<node_type_name>/set-task-types', methods=['POST'])
|
@blueprint.route('/<project_url>/<node_type_name>/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):
|
def save_task_types(project, attract_props, node_type_name: str):
|
||||||
from . import EXTENSION_NAME
|
from . import EXTENSION_NAME
|
||||||
from . import setup
|
from . import setup
|
||||||
|
Reference in New Issue
Block a user