Cleanup style of filter_by_subscriptions.

(imported from commit 4bc62dcc97eeb98147dd73163c75a142eaf5d3c9)
This commit is contained in:
Tim Abbott 2012-09-07 13:53:24 -04:00
parent 7f6d085ab6
commit f39c203d2c
1 changed files with 6 additions and 3 deletions

View File

@ -188,11 +188,14 @@ def get_huddle(id_list):
def filter_by_subscriptions(zephyrs, user): def filter_by_subscriptions(zephyrs, user):
userprofile = UserProfile.objects.get(user=user) userprofile = UserProfile.objects.get(user=user)
subscribed_zephyrs = [] subscribed_zephyrs = []
subscriptions = [sub.recipient for sub in Subscription.objects.filter(userprofile=userprofile, active=True)] subscriptions = [sub.recipient for sub in
Subscription.objects.filter(userprofile=userprofile, active=True)]
for zephyr in zephyrs: for zephyr in zephyrs:
# If you are subscribed to the personal or class, or if you sent the personal, you can see the zephyr. # If you are subscribed to the personal or class, or if you
# sent the personal, you can see the zephyr.
if (zephyr.recipient in subscriptions) or \ if (zephyr.recipient in subscriptions) or \
(zephyr.recipient.type == "personal" and zephyr.sender == userprofile): (zephyr.recipient.type == "personal" and
zephyr.sender == userprofile):
subscribed_zephyrs.append(zephyr) subscribed_zephyrs.append(zephyr)
return subscribed_zephyrs return subscribed_zephyrs