More detailed "verb" for task action logging.
This commit is contained in:
@@ -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'],
|
||||
|
Reference in New Issue
Block a user