Start of activity stream.
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import functools
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, render_template
|
||||
from flask import Blueprint, render_template, url_for
|
||||
import flask_login
|
||||
|
||||
from pillar.api.utils import jsonify
|
||||
from pillar.web.system_util import pillar_api
|
||||
import pillarsdk
|
||||
|
||||
from attract import current_attract
|
||||
from attract import current_attract, subquery
|
||||
from attract.node_types.task import node_type_task
|
||||
from attract.node_types.shot import node_type_shot
|
||||
|
||||
blueprint = Blueprint('attract', __name__)
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -23,15 +25,44 @@ def index():
|
||||
else:
|
||||
tasks = None
|
||||
|
||||
# TODO: add projections.
|
||||
projects = current_attract.attract_projects()
|
||||
projs_with_summaries = [
|
||||
(proj, current_attract.shot_manager.shot_status_summary(proj['_id']))
|
||||
for proj in projects['_items']
|
||||
]
|
||||
|
||||
# Fetch all activities for all Attract projects.
|
||||
api = pillar_api()
|
||||
id_to_proj = {p['_id']: p for p in projects['_items']}
|
||||
activities = pillarsdk.Activity.all({
|
||||
'where': {
|
||||
'project': {'$in': list(id_to_proj.keys())},
|
||||
},
|
||||
'sort': [('_created', -1)],
|
||||
'max_results': 20,
|
||||
}, api=api)
|
||||
|
||||
# Fetch more info for each activity.
|
||||
node_type_task_name = node_type_task['name']
|
||||
node_type_shot_name = node_type_shot['name']
|
||||
for act in activities['_items']:
|
||||
act.actor_user = subquery.get_user_info(act.actor_user)
|
||||
act.project = id_to_proj[act.project]
|
||||
|
||||
if act.node_type == node_type_task_name:
|
||||
act.link = url_for('attract.tasks.perproject.view_task',
|
||||
project_url=act.project.url,
|
||||
task_id=act.object)
|
||||
elif act.node_type == node_type_shot_name:
|
||||
act.link = url_for('attract.shots.perproject.view_shot',
|
||||
project_url=act.project.url,
|
||||
shot_id=act.object)
|
||||
|
||||
return render_template('attract/index.html',
|
||||
tasks=tasks,
|
||||
projs_with_summaries=projs_with_summaries)
|
||||
projs_with_summaries=projs_with_summaries,
|
||||
activities=activities)
|
||||
|
||||
|
||||
def error_project_not_setup_for_attract():
|
||||
|
Reference in New Issue
Block a user