From e9233ff7c07e15c904145f66b6f22ed6c103247f Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Sat, 30 Sep 2017 22:13:10 +0200 Subject: [PATCH] Introducing embed_project By specifying the 'embed_project' argument, the node's Project will be fetched and embedded in the document. This is useful in specific cases, where a project property needs to be accessed when rendering the view_embed template. --- pillar/web/nodes/routes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pillar/web/nodes/routes.py b/pillar/web/nodes/routes.py index 58b4f75c..a9b29d5a 100644 --- a/pillar/web/nodes/routes.py +++ b/pillar/web/nodes/routes.py @@ -201,6 +201,9 @@ def view(node_id): if node.file and node.file_variations: node.file.length = max(var.length for var in node.file_variations) + if request.args.get('embed_project') == '1': + node.project = Project.find(node.project, api=api) + if request.args.get('format') == 'json': node = node.to_dict() node['url_edit'] = url_for('nodes.edit', node_id=node['_id'])