Simplified task eve hooks.
This commit is contained in:
@@ -86,26 +86,11 @@ def _parent_name(task):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
@only_for_task
|
def register_task_activity(task, descr):
|
||||||
def activity_after_replacing_task(task, original):
|
|
||||||
user_id = pillar.api.utils.authentication.current_user_id()
|
user_id = pillar.api.utils.authentication.current_user_id()
|
||||||
pillar.api.activities.register_activity(
|
pillar.api.activities.register_activity(
|
||||||
user_id,
|
user_id,
|
||||||
('edited task "%s"' % task['name']) + _parent_name(task),
|
descr + _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),
|
|
||||||
'node', task['_id'],
|
'node', task['_id'],
|
||||||
'node', task.get('parent'),
|
'node', task.get('parent'),
|
||||||
task['project'],
|
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):
|
def activity_after_creating_tasks(nodes):
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
activity_after_creating_task(node)
|
activity_after_creating_task(node)
|
||||||
@@ -120,15 +117,7 @@ def activity_after_creating_tasks(nodes):
|
|||||||
|
|
||||||
@only_for_task
|
@only_for_task
|
||||||
def activity_after_deleting_task(task):
|
def activity_after_deleting_task(task):
|
||||||
user_id = pillar.api.utils.authentication.current_user_id()
|
register_task_activity(task, 'deleted task "%s"' % task['name'])
|
||||||
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'],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def setup_app(app):
|
def setup_app(app):
|
||||||
|
Reference in New Issue
Block a user