Added node URL finders for tasks and shots
This commit is contained in:
@@ -81,7 +81,7 @@ class AttractExtension(PillarExtension):
|
|||||||
return os.path.join(os.path.dirname(__file__), 'static')
|
return os.path.join(os.path.dirname(__file__), 'static')
|
||||||
|
|
||||||
def setup_app(self, app):
|
def setup_app(self, app):
|
||||||
"""Connects Blinker signals."""
|
"""Connects Blinker signals and sets up other app-dependent stuff in submodules."""
|
||||||
|
|
||||||
from . import subversion, tasks, eve_hooks, subquery, shots
|
from . import subversion, tasks, eve_hooks, subquery, shots
|
||||||
|
|
||||||
@@ -91,6 +91,9 @@ class AttractExtension(PillarExtension):
|
|||||||
eve_hooks.setup_app(app)
|
eve_hooks.setup_app(app)
|
||||||
subquery.setup_app(app)
|
subquery.setup_app(app)
|
||||||
|
|
||||||
|
# Imports for side-effects
|
||||||
|
from . import node_url_finders
|
||||||
|
|
||||||
def attract_projects(self):
|
def attract_projects(self):
|
||||||
"""Returns projects set up for Attract.
|
"""Returns projects set up for Attract.
|
||||||
|
|
||||||
|
23
attract/node_url_finders.py
Normal file
23
attract/node_url_finders.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from flask import url_for
|
||||||
|
|
||||||
|
from pillar.web.nodes.finders import register_node_finder
|
||||||
|
|
||||||
|
from attract.node_types.shot import node_type_shot
|
||||||
|
from attract.node_types.task import node_type_task
|
||||||
|
|
||||||
|
|
||||||
|
@register_node_finder(node_type_shot['name'])
|
||||||
|
def find_for_shot(project, node):
|
||||||
|
return url_for('attract.shots.perproject.view_shot',
|
||||||
|
project_url=project['url'],
|
||||||
|
shot_id=node['_id'])
|
||||||
|
|
||||||
|
|
||||||
|
@register_node_finder(node_type_task['name'])
|
||||||
|
def find_for_task(project, node):
|
||||||
|
if node['parent']:
|
||||||
|
endpoint = 'attract.shots.perproject.with_task'
|
||||||
|
else:
|
||||||
|
endpoint = 'attract.tasks.perproject.view_task'
|
||||||
|
|
||||||
|
return url_for(endpoint, project_url=project['url'], task_id=node['_id'])
|
Reference in New Issue
Block a user