Exemplo n.º 1
0
from social_friends_finder.backends import BaseFriendsProvider
from social_friends_finder.utils import setting
if not setting("SOCIAL_FRIENDS_USING_ALLAUTH", False):
    from social_auth.backends.contrib.vk import VKOAuth2Backend
    USING_ALLAUTH = False
else:
    from allauth.socialaccount.models import SocialToken, SocialAccount, SocialApp
    USING_ALLAUTH = True
import vkontakte


class VKontakteFriendsProvider(BaseFriendsProvider):
    def fetch_friends(self, user):
        """
        fethces friends from VKontakte using the access_token
        fethched by django-social-auth.

        Note - user isn't a user - it's a UserSocialAuth if using social auth, or a SocialAccount if using allauth

        Returns:
            collection of friend objects fetched from VKontakte
        """

        if USING_ALLAUTH:
            raise NotImplementedError(
                "VKontakte support is not implemented for django-allauth")
            #social_app = SocialApp.objects.get_current('vkontakte')
            #oauth_token = SocialToken.objects.get(account=user, app=social_app).token
        else:
            social_auth_backend = VKOAuth2Backend()
Exemplo n.º 2
0
from social_friends_finder.models import SocialFriendList
from social_friends_finder.utils import setting

# Allauth Models
import allauth.socialaccount.models

# Favit Models
from favit.models import Favorite

#################################################
# Config
#################################################

pages_dir = "pages/"

if setting("SOCIAL_FRIENDS_USING_ALLAUTH", False):
    USING_ALLAUTH = True
else:
    USING_ALLAUTH = False
    
REDIRECT_IF_NO_ACCOUNT = setting('SF_REDIRECT_IF_NO_SOCIAL_ACCOUNT_FOUND', False)
REDIRECT_URL = setting('SF_REDIRECT_URL', "/")

#################################################

class FriendListView(ListView):
  
    model = List
    template_name = pages_dir + "index.html"
    
    def get(self, request, provider=None):
Exemplo n.º 3
0
from social_friends_finder.models import SocialFriendList
from social_friends_finder.utils import setting

# Allauth Models
import allauth.socialaccount.models

# Favit Models
from favit.models import Favorite

#################################################
# Config
#################################################

pages_dir = "pages/"

if setting("SOCIAL_FRIENDS_USING_ALLAUTH", False):
    USING_ALLAUTH = True
else:
    USING_ALLAUTH = False

REDIRECT_IF_NO_ACCOUNT = setting('SF_REDIRECT_IF_NO_SOCIAL_ACCOUNT_FOUND',
                                 False)
REDIRECT_URL = setting('SF_REDIRECT_URL', "/")

#################################################


class FriendListView(ListView):

    model = List
    template_name = pages_dir + "index.html"
from social_friends_finder.backends import BaseFriendsProvider
from social_friends_finder.utils import setting

if not setting("SOCIAL_FRIENDS_USING_ALLAUTH", False):
    from social_auth.backends.facebook import FacebookBackend

    USING_ALLAUTH = False
else:
    from allauth.socialaccount.models import SocialToken, SocialAccount, SocialApp

    USING_ALLAUTH = True
import facebook


class FacebookFriendsProvider(BaseFriendsProvider):
    def fetch_friends(self, user):
        """
        fethces friends from facebook using the oauth_token
        fethched by django-social-auth.

        Note - user isn't a user - it's a UserSocialAuth if using social auth, or a SocialAccount if using allauth

        Returns:
            collection of friend objects fetched from facebook
        """

        if USING_ALLAUTH:
            social_app = SocialApp.objects.get_current("facebook")
            oauth_token = SocialToken.objects.get(account=user, app=social_app).token
        else:
            social_auth_backend = FacebookBackend()