Start of activity stream.

This commit is contained in:
2016-10-12 14:30:58 +02:00
parent 7a3a11fa07
commit 32400b34e9
6 changed files with 86 additions and 39 deletions

View File

@@ -11,7 +11,7 @@ import pillar.api.utils
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, subquery
blueprint = Blueprint('attract.tasks', __name__, url_prefix='/tasks')
perproject_blueprint = Blueprint('attract.tasks.perproject', __name__,
@@ -51,24 +51,6 @@ def for_project(project, task_id=None):
project=project)
def _get_user_info(user_id):
"""Returns email & full name of the user.
Only returns those two fields, so the return value is the same
for authenticated & non-authenticated users, which is why we're
allowed to cache it globally.
Returns None when the user cannot be found.
"""
user = pillarsdk.User.find(user_id, api=pillar_api())
if not user:
return user
return {'email': user.email,
'full_name': user.full_name}
@perproject_blueprint.route('/<task_id>')
@attract_project_view(extension_props=True)
def view_task(project, attract_props, task_id):
@@ -88,12 +70,7 @@ def view_task(project, attract_props, task_id):
users = project.get_users(api=api)
project.users = users['_items']
else:
# Cache user info for 5 minutes.
@current_app.cache.memoize(timeout=300, make_name='%s._cached_user_info' % __name__)
def _cached_user_info(user_id):
return _get_user_info(user_id)
task.properties.assigned_to.users = [_cached_user_info(uid)
task.properties.assigned_to.users = [subquery.get_user_info(uid)
for uid in task.properties.assigned_to.users]
return render_template('attract/tasks/view_task_embed.html',