Adding extra info to timeline API

remotes/origin/enhancement/email-actions
Alejandro Alonso 2015-04-14 14:01:04 +02:00 committed by David Barragán Merino
parent c77ee9f0ad
commit c5b268aa75
3 changed files with 10 additions and 1 deletions

View File

@ -225,3 +225,10 @@ def extract_wiki_page_info(instance):
"id": instance.pk, "id": instance.pk,
"slug": instance.slug, "slug": instance.slug,
} }
def extract_role_info(instance):
return {
"id": instance.pk,
"name": instance.name,
}

View File

@ -95,6 +95,7 @@ def on_new_history_entry(sender, instance, created, **kwargs):
"values_diff": instance.values_diff, "values_diff": instance.values_diff,
"user": extract_user_info(user), "user": extract_user_info(user),
"comment": instance.comment, "comment": instance.comment,
"comment_html": instance.comment_html,
} }
_push_to_timelines(project, user, obj, event_type, extra_data=extra_data) _push_to_timelines(project, user, obj, event_type, extra_data=extra_data)

View File

@ -94,10 +94,11 @@ def wiki_page_timeline(instance, extra_data={}):
@register_timeline_implementation("projects.membership", "create") @register_timeline_implementation("projects.membership", "create")
@register_timeline_implementation("projects.membership", "delete") @register_timeline_implementation("projects.membership", "delete")
def membership_create_timeline(instance, extra_data={}): def membership_timeline(instance, extra_data={}):
result = { result = {
"user": service.extract_user_info(instance.user), "user": service.extract_user_info(instance.user),
"project": service.extract_project_info(instance.project), "project": service.extract_project_info(instance.project),
"role": service.extract_role_info(instance.role),
} }
result.update(extra_data) result.update(extra_data)
return result return result