More detailed "verb" for task action logging.

This commit is contained in:
2016-10-12 15:08:06 +02:00
parent 32400b34e9
commit 363f1f6110
3 changed files with 30 additions and 12 deletions

View File

@@ -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,

View File

@@ -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'],

View File

@@ -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