Return a dictionary in subscriptions/list instead of a tuple.

This will give us flexibility in the future to add new properties to the
list.

In order to support that, we now do a list comprehension rather than just
returning the gather_subscriptions list in get_stream_colors.

(imported from commit a3c0f749a3320f647440f800105942434da08111)
This commit is contained in:
Luke Faraone
2013-01-29 15:40:16 -05:00
parent 1c3c3cc33f
commit e8afaa8b8e
4 changed files with 23 additions and 20 deletions

View File

@@ -373,9 +373,10 @@ def gather_subscriptions(user_profile):
with_color = StreamColor.objects.filter(subscription__in = subs).select_related()
no_color = subs.exclude(id__in = with_color.values('subscription_id')).select_related()
result = [(get_display_recipient(sc.subscription.recipient), sc.color)
for sc in with_color]
result.extend((get_display_recipient(sub.recipient), StreamColor.DEFAULT_STREAM_COLOR)
for sub in no_color)
result = [{'name': get_display_recipient(sc.subscription.recipient),
'color': sc.color} for sc in with_color]
result.extend({'name': get_display_recipient(sub.recipient),
'color': StreamColor.DEFAULT_STREAM_COLOR} for sub in no_color)
return sorted(result)