From 363f1f61101e7c6691d7fbf7d2dd6444386453ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 12 Oct 2016 15:08:06 +0200 Subject: [PATCH] More detailed "verb" for task action logging. --- attract/routes.py | 11 ++++++++--- attract/tasks/eve_hooks.py | 26 +++++++++++++++++++++----- src/templates/attract/index.jade | 5 +---- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/attract/routes.py b/attract/routes.py index 9c37a87..7664a7e 100644 --- a/attract/routes.py +++ b/attract/routes.py @@ -51,9 +51,14 @@ def index(): 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) + if act.context_object: + act.link = url_for('attract.shots.perproject.with_task', + project_url=act.project.url, + task_id=act.object) + else: + 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, diff --git a/attract/tasks/eve_hooks.py b/attract/tasks/eve_hooks.py index 80c086d..306301d 100644 --- a/attract/tasks/eve_hooks.py +++ b/attract/tasks/eve_hooks.py @@ -70,13 +70,28 @@ def fetch_tasks_parent_info(nodes): fetch_task_extra_info(node) -# Activity logging +# ### Activity logging ### # +def _parent_name(task): + """Returns 'for shot "shotname"' if the task is attached to the shot.""" + + parent = task.get('parent') + if not parent: + return '' + + nodes_coll = current_app.db()['nodes'] + shot = nodes_coll.find_one(parent) + if shot: + return ' for shot "%s"' % shot['name'] + + return '' + + @only_for_task def activity_after_replacing_task(task, original): user_id = pillar.api.utils.authentication.current_user_id() pillar.api.activities.register_activity( user_id, - 'edited task', + ('edited task "%s"' % task['name']) + _parent_name(task), 'node', task['_id'], 'project', task['project'], task['project'], @@ -87,11 +102,12 @@ def activity_after_replacing_task(task, original): @only_for_task def activity_after_creating_task(task): user_id = pillar.api.utils.authentication.current_user_id() + pillar.api.activities.register_activity( user_id, - 'created a new task', + ('created a new task "%s"' % task['name']) + _parent_name(task), 'node', task['_id'], - 'project', task['project'], + 'node', task.get('parent'), task['project'], node_type=task['node_type'], ) @@ -107,7 +123,7 @@ def activity_after_deleting_task(task): user_id = pillar.api.utils.authentication.current_user_id() pillar.api.activities.register_activity( user_id, - 'deleted task', + ('deleted task "%s"' % task['name']) + _parent_name(task), 'node', task['_id'], 'project', task['project'], task['project'], diff --git a/src/templates/attract/index.jade b/src/templates/attract/index.jade index 5a816a9..453f404 100644 --- a/src/templates/attract/index.jade +++ b/src/templates/attract/index.jade @@ -12,9 +12,6 @@ | {% include "attract/index_anon_left_column.html" %} | {% endif %} .col-md-6 - h3 Latest Edit - img.img-responsive(src="//placehold.it/500x250") - .d-activity h3 Activity @@ -23,7 +20,7 @@ li span.date {{ act._created | pretty_date_time }}:  a(href="{{ act.link }}") - | {{ act['actor_user']['full_name'] }} {{ act.verb }} {{ act.object }} + | {{ act['actor_user']['full_name'] }} {{ act.verb }} | {% endfor %} h3 Shot statistics