Beispiel #1
0
 def profile_or_self(self):
     user_or_profile_model = get_model_for_attribute('facebook_id')
     user_model = get_user_model()
     if user_or_profile_model == user_model:
         return self
     else:
         return self.get_profile()
def _get_old_connections(facebook_id, current_user_id=None):
    """
    Gets other accounts connected to this facebook id, which are not
    attached to the current user
    """
    user_or_profile_model = get_model_for_attribute("facebook_id")
    other_facebook_accounts = user_or_profile_model.objects.filter(facebook_id=facebook_id)
    kwargs = {}

    if current_user_id:
        # if statement since we need to support both
        user_model = get_user_model()
        if user_or_profile_model == user_model:
            kwargs["id"] = current_user_id
        else:
            kwargs["user"] = current_user_id
        other_facebook_accounts = other_facebook_accounts.exclude(**kwargs)
    return other_facebook_accounts
Beispiel #3
0
def _get_old_connections(facebook_id, current_user_id=None):
    '''
    Gets other accounts connected to this facebook id, which are not
    attached to the current user
    '''
    user_or_profile_model = get_model_for_attribute('facebook_id')
    other_facebook_accounts = user_or_profile_model.objects.filter(
        facebook_id=facebook_id)
    kwargs = {}

    if current_user_id:
        # if statement since we need to support both
        user_model = get_user_model()
        if user_or_profile_model == user_model:
            kwargs['id'] = current_user_id
        else:
            kwargs['user'] = current_user_id
        other_facebook_accounts = other_facebook_accounts.exclude(**kwargs)
    return other_facebook_accounts