Skip to content

Commit

Permalink
[#2536] Only check for details if certain activity type
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Aug 10, 2012
1 parent 3aa964d commit e491daf
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions ckan/lib/activity_streams.py
Expand Up @@ -144,29 +144,33 @@ def activity_stream_string_new_related_item():
'new related item': activity_stream_string_new_related_item,
}

# A list of activity types that may have details
activity_stream_actions_with_detail = ['changed package']

def activity_list_to_html(context, activity_stream):
'''Return the given activity stream as a snippet of HTML.'''

activity_list = [] # These are the activity stream messages.
for activity in activity_stream:
detail = None
activity_type = activity['activity_type']

# If an activity has just one activity detail then render the detail
# instead of the activity.
details = logic.get_action('activity_detail_list')(context=context,
data_dict={'id': activity['id']})
if len(details) == 1:
detail = details[0]
object_type = detail['object_type']

if object_type == 'PackageExtra':
object_type = 'package_extra'

new_activity_type = '%s %s' % (detail['activity_type'],
object_type.lower())
if new_activity_type in activity_stream_string_functions:
activity_type = new_activity_type
# Some activity types may have details.
if activity_type in activity_stream_actions_with_detail:
details = logic.get_action('activity_detail_list')(context=context,
data_dict={'id': activity['id']})
# If an activity has just one activity detail then render the
# detail instead of the activity.
if len(details) == 1:
detail = details[0]
object_type = detail['object_type']

if object_type == 'PackageExtra':
object_type = 'package_extra'

new_activity_type = '%s %s' % (detail['activity_type'],
object_type.lower())
if new_activity_type in activity_stream_string_functions:
activity_type = new_activity_type

if not activity_type in activity_stream_string_functions:
raise NotImplementedError("No activity renderer for activity "
Expand Down

1 comment on commit e491daf

@seanh
Copy link
Contributor

@seanh seanh commented on e491daf Aug 10, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, do you mind merging it yourself? I'm in the middle of debugging something on another branch

Please sign in to comment.