Skip to content

friendship, contact and invitation management for the Django web framework

Notifications You must be signed in to change notification settings

barszczmm/django-easy-friends

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Easy Friends

Django Easy Friends is a friendship tool for Django framework. It has features like sending invitations, friendship creation, blocking users, importing contacts from external services and auto suggesting friends based on imported contacts. It consist of two applications: friends and friends.contrib.suggestions.

friends application

Features

  • Sending invitations
  • Accepting and declining invitations
  • Blocking users from sending invitations
  • Listing friends
  • Listing friends of friend (optional)

Requirements

Installation

  • Add to your INSTALLED_APPS and run syncdb:

    INSTALLED_APPS = (
        ...,
        'friends',
    )
    
  • Add to your urlpatterns in projects urls.py file:

    urlpatterns = patterns('',
        ...
        url(r'^friends/', include('friends.urls')),
    )
    
  • Overwrite friends/base.html template and insert {% block friends_title %}{% endblock %} into block where page title should be and {% block friends_content %}{% endblock %} into block where page content should be.

Configuration

Availale settings:

FRIENDS_USE_NOTIFICATION_APP (default: True)
By default notification app is used if it is enabled in INSTALLED_APPS, if this setting is set to False notification app will not be used.
SHOW_FRIENDS_OF_FRIEND (default: False)
Allow users to view list of friends of their friends.
NOTIFY_ABOUT_NEW_FRIENDS_OF_FRIEND (default: False)
If notification app is enabled and FRIENDS_USE_NOTIFICATION_APP is set to True and this setting is set to True users will be notified when one of their friends have new friend.
NOTIFY_ABOUT_FRIENDS_REMOVAL (default: False)
If notification app is enabled and FRIENDS_USE_NOTIFICATION_APP is set to True and this setting is set to True users will be notified when one of their friends removes them from friends.

Advanced usage

If you want to take some actions when invitation or friendship is created or deleted then check sample signals usage in file friends/models.py.

Credits

This app is a fork of django-friends app.

friends.contrib.suggestions application

Features

  • Importing contacts from:
    • Facebook
    • Google
    • Yahoo
    • Twitter
    • LinkedIn
  • Creating friendship suggestions based on imported contacts

Requirements

  • httplib2 (pip install httplib2)
  • python-oauth2 (pip install -e git://github.com/simplegeo/python-oauth2.git#egg=python-oauth2)
  • django-oauth-access (pip install -e git://github.com/eldarion/django-oauth-access.git#egg=django-oauth-access)
  • gdata (pip install gdata)
  • facebook-sdk (pip install -e git://github.com/pythonforfacebook/facebook-sdk.git#egg=facebook-sdk)
  • python-twitter (pip install python-twitter)
  • django-celery (pip install django-celery) (optional but highly recommended)

Installation

  • friends app must be installed already (read above)

  • Add to your INSTALLED_APPS and run syncdb:

    INSTALLED_APPS = (
        ...,
        'friends.contrib.suggestions',
    )
    
  • Add to your urlpatterns in projects urls.py file:

    urlpatterns = patterns('',
        ...
        url(r'^friends/suggestions/', include('friends.contrib.suggestions.urls')),
    )
    

Configuration

Available settings:

FRIENDS_SUGGESTIONS_IMPORT_RUNNER (default: friends.contrib.suggestions.backends.runners.SynchronousRunner)
This is class that is used for importing contacts. Default is synchronous runner but you should really use Celery (and django-celery) so this setting should be set to friends.contrib.suggestions.backends.runners.AsyncRunner.

There is one setting that is needed for django-oauth-access:

OAUTH_ACCESS_SETTINGS = {
    'facebook': {
        'keys': {
            'KEY': 'YOURAPPKEY',
            'SECRET': 'yourappsecretcode',
        },
       'endpoints': {
            #'authorize': 'https://graph.facebook.com/oauth/authorize',
            'authorize': 'https://www.facebook.com/dialog/oauth/', # url above may be blocked in user browser by something like Ghostery so this one is safer
            'access_token': 'https://graph.facebook.com/oauth/access_token',
            'callback': 'friends.contrib.suggestions.views.import_facebook_contacts',
        },
    },
    'twitter': {
        'keys': {
            'KEY': 'YOURAPPKEY',
            'SECRET': 'yourappsecretcode',
        },
        'endpoints': {
            'request_token': 'https://api.twitter.com/oauth/request_token',
            'authorize': 'http://twitter.com/oauth/authorize',
            'access_token': 'https://twitter.com/oauth/request_token',
            'callback': 'friends.contrib.suggestions.views.import_twitter_contacts',
        },
    },
    'yahoo': {
        'keys': {
            'KEY': 'YOURAPPKEY',
            'SECRET': 'yourappsecretcode',
        },
        'endpoints': {
            'request_token': 'https://api.login.yahoo.com/oauth/v2/get_request_token',
            'authorize': 'https://api.login.yahoo.com/oauth/v2/request_auth',
            'access_token': 'https://api.login.yahoo.com/oauth/v2/get_token',
            'callback': 'friends.contrib.suggestions.views.import_yahoo_contacts',
        },
    },
    'linkedin': {
        'keys': {
            'KEY': 'YOURAPPKEY',
            'SECRET': 'yourappsecretcode',
        },
        'endpoints': {
            'request_token': 'https://api.linkedin.com/uas/oauth/requestToken',
            'authorize': 'https://api.linkedin.com/uas/oauth/authorize',
            'access_token': 'https://api.linkedin.com/uas/oauth/accessToken',
            'callback': 'friends.contrib.suggestions.views.import_linkedin_contacts',
        },
    },
}

Remember to change YOURAPPKEY and yourappsecretcode for each service. You can get them by registering your applications on this sites:

Advanced usage

By default friends suggestions are created after each contacts import but there are other situations when you could want to create friends suggestions. One example is when new user is registered on your site. This new user has no imported contacts yet but other users have some imported contacts and maybe new user matches some of the already imported contact. Here is how to create friends suggestions on user activation using some signals:

First create signal receiver:

def find_friends_suggestions(sender, user, **kwargs):
    from friends.contrib.suggestions.models import FriendshipSuggestion
    FriendshipSuggestion.objects.create_suggestions_for_user_using_imported_contacts(user)

If django-easy-userena (or django-userena) app is used for managing users registration use this code:

from userena.signals import activation_complete
activation_complete.connect(find_friends_suggestions, dispatch_uid="find_friends_suggestions_on_activation_complete")

If django-registration app is used use this code:

from registration.signals import user_activated
user_activated.connect(find_friends_suggestions, dispatch_uid="find_friends_suggestions_on_user_activated")

Credits

This app is based on django-contacts-import app with some code taken from some of its forks.

About

friendship, contact and invitation management for the Django web framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 89.7%
  • HTML 10.3%