Example #1
0
def twitter_followers_on_drawquest(request, twitter_access_token,
                                   twitter_access_token_secret):
    """ Returns one field, `users`, a list of `User` dicts. """
    twitter_user = TwitterUser.get_or_create_from_access_token(
        twitter_access_token, twitter_access_token_secret)
    twitter_friends = twitter_user.followers_on_drawquest(
        twitter_access_token, twitter_access_token_secret)
    twitter_friends = list(twitter_friends.select_related('user'))

    twitter_friend_uids = dict(
        (friend.user_id, friend.twitter_uid) for friend in twitter_friends)

    users = CachedCall.multicall([
        User.details_by_id(twitter_friend.user_id)
        for twitter_friend in twitter_friends
        if twitter_friend.user_id is not None
    ])

    for user in users:
        user.twitter_uid = twitter_friend_uids[user.id]

        if request.user.is_authenticated() and request.user.id != user.id:
            user.viewer_is_following = request.user.is_following(user.id)

    return {
        'users': users,
    }
 def get_stars(self):
     """
     Returns a list of `{username, timestamp, id}` dicts.
     """
     stickers = CommentSticker.objects.filter(comment=self, type_id=settings.STAR_STICKER_TYPE_ID)
     stickers = stickers.values("user_id", "timestamp", "id")
     return [
         {"user": User.details_by_id(sticker["user_id"])(), "timestamp": sticker["timestamp"], "id": sticker["id"]}
         for sticker in stickers
     ]
Example #3
0
 def get_stars(self):
     """
     Returns a list of `{username, timestamp, id}` dicts.
     """
     stickers = CommentSticker.objects.filter(
         comment=self, type_id=settings.STAR_STICKER_TYPE_ID)
     stickers = stickers.values('user_id', 'timestamp', 'id')
     return [{
         'user': User.details_by_id(sticker['user_id'])(),
         'timestamp': sticker['timestamp'],
         'id': sticker['id'],
     } for sticker in stickers]
Example #4
0
 def get_stars(self):
     """
     Returns a list of `{username, timestamp, id}` dicts.
     """
     stickers = CommentSticker.objects.filter(comment=self, type_id=settings.STAR_STICKER_TYPE_ID)
     stickers = stickers.values('user_id', 'timestamp', 'id')
     return [
         {
             'user': User.details_by_id(sticker['user_id'])(),
             'timestamp': sticker['timestamp'],
             'id': sticker['id'],
         }
         for sticker in stickers
     ]
Example #5
0
def twitter_followers_on_drawquest(request, twitter_access_token, twitter_access_token_secret):
    """ Returns one field, `users`, a list of `User` dicts. """
    twitter_user = TwitterUser.get_or_create_from_access_token(twitter_access_token, twitter_access_token_secret)
    twitter_friends = twitter_user.followers_on_drawquest(twitter_access_token, twitter_access_token_secret)
    twitter_friends = list(twitter_friends.select_related('user'))

    twitter_friend_uids = dict((friend.user_id, friend.twitter_uid) for friend in twitter_friends)

    users = CachedCall.multicall([User.details_by_id(twitter_friend.user_id) for twitter_friend in twitter_friends
                                  if twitter_friend.user_id is not None])

    for user in users:
        user.twitter_uid = twitter_friend_uids[user.id]

        if request.user.is_authenticated() and request.user.id != user.id:
            user.viewer_is_following = request.user.is_following(user.id)

    return {
        'users': users,
    }
Example #6
0
def facebook_friends_on_drawquest(request, facebook_access_token):
    """ Returns one field, `users`, a list of `User` dicts. """
    fb_user = FacebookUser.get_or_create_from_access_token(facebook_access_token)
    fb_friends = fb_user.friends_on_drawquest(facebook_access_token).select_related('user')

    fb_friend_uids = dict((friend.user_id, friend.fb_uid) for friend in fb_friends)

    users = CachedCall.multicall([User.details_by_id(fb_friend.user_id) for fb_friend in fb_friends
                                  if fb_friend.user_id is not None])


    for user in users:
        user.fb_uid = fb_friend_uids[user.id]

        if request.user.is_authenticated() and request.user.id != user.id:
            user.viewer_is_following = request.user.is_following(user.id)

    return {
        'users': users,
    }
Example #7
0
def facebook_friends_on_drawquest(request, facebook_access_token):
    """ Returns one field, `users`, a list of `User` dicts. """
    fb_user = FacebookUser.get_or_create_from_access_token(
        facebook_access_token)
    fb_friends = fb_user.friends_on_drawquest(
        facebook_access_token).select_related('user')

    fb_friend_uids = dict(
        (friend.user_id, friend.fb_uid) for friend in fb_friends)

    users = CachedCall.multicall([
        User.details_by_id(fb_friend.user_id) for fb_friend in fb_friends
        if fb_friend.user_id is not None
    ])

    for user in users:
        user.fb_uid = fb_friend_uids[user.id]

        if request.user.is_authenticated() and request.user.id != user.id:
            user.viewer_is_following = request.user.is_following(user.id)

    return {
        'users': users,
    }
 def from_ids(cls, user_ids):
     from drawquest.apps.drawquest_auth.models import User
     return CachedCall.multicall([
         User.details_by_id(user_id, promoter=cls) for user_id in user_ids
     ])
 def from_id(cls, user_id):
     from drawquest.apps.drawquest_auth.models import User
     return User.details_by_id(user_id, promoter=cls)()
Example #10
0
 def from_id(cls, user_id):
     from drawquest.apps.drawquest_auth.models import User
     return User.details_by_id(user_id, promoter=cls)()
 def from_ids(cls, user_ids):
     from drawquest.apps.drawquest_auth.models import User
     return CachedCall.multicall([User.details_by_id(user_id, promoter=cls)
                                  for user_id in user_ids])