Produce activities for task changes.
These activities do not show any details yet, so the activity stream can't show _what_ changed in the task, just that the task changed.
This commit is contained in:
@@ -4,6 +4,8 @@ from flask import current_app
|
|||||||
|
|
||||||
from attract.node_types.task import node_type_task
|
from attract.node_types.task import node_type_task
|
||||||
from pillar.api.nodes import only_for_node_type_decorator
|
from pillar.api.nodes import only_for_node_type_decorator
|
||||||
|
import pillar.api.activities
|
||||||
|
import pillar.api.utils.authentication
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
only_for_task = only_for_node_type_decorator(node_type_task['name'])
|
only_for_task = only_for_node_type_decorator(node_type_task['name'])
|
||||||
@@ -68,6 +70,56 @@ def fetch_tasks_parent_info(nodes):
|
|||||||
fetch_task_extra_info(node)
|
fetch_task_extra_info(node)
|
||||||
|
|
||||||
|
|
||||||
|
# Activity logging
|
||||||
|
@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',
|
||||||
|
'node', task['_id'],
|
||||||
|
'project',
|
||||||
|
task['project'],
|
||||||
|
task['project'],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@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',
|
||||||
|
'node', task['_id'],
|
||||||
|
'project',
|
||||||
|
task['project'],
|
||||||
|
task['project'],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def activity_after_creating_tasks(nodes):
|
||||||
|
for node in nodes:
|
||||||
|
activity_after_creating_task(node)
|
||||||
|
|
||||||
|
|
||||||
|
@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',
|
||||||
|
'node', task['_id'],
|
||||||
|
'project',
|
||||||
|
task['project'],
|
||||||
|
task['project'],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_app(app):
|
def setup_app(app):
|
||||||
app.on_fetched_item_nodes += fetch_task_extra_info
|
app.on_fetched_item_nodes += fetch_task_extra_info
|
||||||
app.on_fetched_resource_nodes += fetch_tasks_parent_info
|
app.on_fetched_resource_nodes += fetch_tasks_parent_info
|
||||||
|
|
||||||
|
app.on_replaced_nodes += activity_after_replacing_task
|
||||||
|
app.on_inserted_nodes += activity_after_creating_tasks
|
||||||
|
app.on_deleted_item_nodes += activity_after_deleting_task
|
||||||
|
app.on_deleted_resource_nodes += activity_after_deleting_task
|
||||||
|
Reference in New Issue
Block a user