GithubHelp home page GithubHelp logo

barszczmm / django-easy-friends Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pinax/django-friends

28.0 6.0 16.0 379 KB

friendship, contact and invitation management for the Django web framework

Python 89.67% HTML 10.33%

django-easy-friends's Introduction

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.

django-easy-friends's People

Contributors

alex avatar alibrahim avatar amarpreetsaini avatar barszczmm avatar brosner avatar deepinder19 avatar empty avatar jezdez avatar jtauber avatar tmc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-easy-friends's Issues

error in invitations_list.html

In templates\friends\invitations_list.html

{% url profile_detail username=to_user.username %}

should be

{% url profile_detail username=invitation.to_user.username %}

The same for from_user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.