Simplified task eve hooks.
This commit is contained in:
@@ -86,26 +86,11 @@ def _parent_name(task):
|
||||
return ''
|
||||
|
||||
|
||||
@only_for_task
|
||||
def activity_after_replacing_task(task, original):
|
||||
def register_task_activity(task, descr):
|
||||
user_id = pillar.api.utils.authentication.current_user_id()
|
||||
pillar.api.activities.register_activity(
|
||||
user_id,
|
||||
('edited task "%s"' % task['name']) + _parent_name(task),
|
||||
'node', task['_id'],
|
||||
'project', task['project'],
|
||||
task['project'],
|
||||
node_type=task['node_type'],
|
||||
)
|
||||
|
||||
|
||||
@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 "%s"' % task['name']) + _parent_name(task),
|
||||
descr + _parent_name(task),
|
||||
'node', task['_id'],
|
||||
'node', task.get('parent'),
|
||||
task['project'],
|
||||
@@ -113,6 +98,18 @@ def activity_after_creating_task(task):
|
||||
)
|
||||
|
||||
|
||||
@only_for_task
|
||||
def activity_after_replacing_task(task, original):
|
||||
# TODO: compare to original, and either mention the things that changed,
|
||||
# or (if they are equal) don't log an activity at all.
|
||||
register_task_activity(task, 'edited task "%s"' % task['name'])
|
||||
|
||||
|
||||
@only_for_task
|
||||
def activity_after_creating_task(task):
|
||||
register_task_activity(task, 'created a new task "%s"' % task['name'])
|
||||
|
||||
|
||||
def activity_after_creating_tasks(nodes):
|
||||
for node in nodes:
|
||||
activity_after_creating_task(node)
|
||||
@@ -120,15 +117,7 @@ def activity_after_creating_tasks(nodes):
|
||||
|
||||
@only_for_task
|
||||
def activity_after_deleting_task(task):
|
||||
user_id = pillar.api.utils.authentication.current_user_id()
|
||||
pillar.api.activities.register_activity(
|
||||
user_id,
|
||||
('deleted task "%s"' % task['name']) + _parent_name(task),
|
||||
'node', task['_id'],
|
||||
'project', task['project'],
|
||||
task['project'],
|
||||
node_type=task['node_type'],
|
||||
)
|
||||
register_task_activity(task, 'deleted task "%s"' % task['name'])
|
||||
|
||||
|
||||
def setup_app(app):
|
||||
|
Reference in New Issue
Block a user