Skip to content

Commit

Permalink
improvements to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tschellenbach committed Dec 3, 2013
1 parent ff37b8c commit 04bdf09
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 24 deletions.
16 changes: 16 additions & 0 deletions django_facebook/registration_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,29 @@ class NooptRegistrationBackend(object):
'''

def get_form_class(self, request):
'''
Returns the form class to use for registration
:param request: the request object
'''
return FacebookRegistrationFormUniqueEmail

def get_registration_template(self):
'''
Returns the template to use for registration
'''
template = facebook_settings.FACEBOOK_REGISTRATION_TEMPLATE
return template

def register(self, request, form=None, **kwargs):
'''
Implement your registration logic in this method
:param request: the request object
:param form: the form with the users data
:param kwargs: additional data
'''
pass

def activate(self, **kwargs):
Expand Down
8 changes: 5 additions & 3 deletions docs/customizing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Now it's time to customize things a little. For a full example you can look at c

1.) First load the css and javascript:

::
.. code-block:: django
<link href="{{ STATIC_URL }}css/facebook.css" type="text/css" rel="stylesheet" media="all" />
{% include 'django_facebook/_facebook_js.html' %}
Expand All @@ -17,7 +17,8 @@ If you encounter issues here you probably don't have django static files setup c
2.) Next design the form

You can control redirects using next, register_next and error_next.
::

.. code-block:: django
<form action="{% url 'facebook_connect' %}?facebook_login=1" method="post">
<input type="hidden" value="{{ request.path }}" name="next" />
Expand All @@ -33,7 +34,8 @@ You can control redirects using next, register_next and error_next.
Usually you'll also want to offer your users the ability to connect their existing account to Facebook.
You can control this by setting connect_facebook=1. The default behaviour is not to connect automatically.
(As this previously caused users to connect their accounts to Facebook by accident)
::

.. code-block:: django
<form action="{% url 'facebook_connect' %}?facebook_login=1" method="post">
<input type="hidden" value="1" name="connect" />
Expand Down
28 changes: 21 additions & 7 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,34 @@

.. include :: ../README.rest
API Docs
========
Basic documentation
===================

.. toctree::
:maxdepth: 2

canvas
celery
customizing
installation
mobile
registration_backend
customizing
settings
registration_backend

Advanced documentation
======================

.. toctree::
:maxdepth: 2

mobile
celery
signals
canvas

API documentation
===================

.. toctree::
:maxdepth: 2

django_facebook/index
open_facebook/index

Expand Down
7 changes: 4 additions & 3 deletions docs/mobile.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Mobile usage
------------

Expand All @@ -6,6 +7,6 @@ In the view you can use the token to get a user.

.. code-block:: python
from django_facebook.connect import connect_user
access_token = request.POST['access_token']
action, user = connect_user(request, access_token)
from django_facebook.connect import connect_user
access_token = request.POST['access_token']
action, user = connect_user(request, access_token)
4 changes: 3 additions & 1 deletion docs/registration_backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@ It provides a clear example of how to configure Userena and Django Facebook to w

Supporting any other registration system is quite easy.
Adjust the above settings to point to your own code.
Note that the form's save method needs to return the new user object.
Note that the form's save method needs to return the new user object.

Also have a look at the API docs for :class:`.FacebookRegistrationBackend`
20 changes: 10 additions & 10 deletions docs/signals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ Django-facebook ships with a few signals that you can use to easily accommodate

``facebook_user_registered`` signal is sent whenever a new user is registered by Django-facebook, for example:

::
.. code-block:: python
from django_facebook.utils import get_user_model
from django_facebook import signals
def fb_user_registered_handler(sender, user, facebook_data, \*\*kwargs):
def fb_user_registered_handler(sender, user, facebook_data, **kwargs):
# Do something involving user here
signals.facebook_user_registered.connect(user_registered, sender=get_user_model())
``facebook_pre_update`` signal is sent just before Django-facebook updates the profile model with Facebook data. If you want to manipulate Facebook or profile information before it gets saved, this is where you should do it. For example:

::
.. code-block:: python
from django_facebook import signals
from django_facebook.utils import get_user_model
def pre_facebook_update(sender, user, profile, facebook_data, \*\*kwargs):
def pre_facebook_update(sender, user, profile, facebook_data, **kwargs):
profile.facebook_information_updated = datetime.datetime.now()
# Manipulate facebook_data here
Expand All @@ -32,36 +32,36 @@ Django-facebook ships with a few signals that you can use to easily accommodate
``facebook_post_update`` signal is sent after Django-facebook finishes updating the profile model with Facebook data. You can perform other Facebook connect or registration related processing here.

::
.. code-block:: python
from django_facebook import signals
from django_facebook.utils import get_user_model
def post_facebook_update(sender, user, profile, facebook_data, \*\*kwargs):
def post_facebook_update(sender, user, profile, facebook_data, **kwargs):
# Do other stuff
signals.facebook_post_update.connect(post_facebook_update, sender=get_user_model())
``facebook_post_store_friends`` signal is sent after Django-facebook finishes storing the user's friends.

::
.. code-block:: python
from django_facebook import signals
from django_facebook.utils import get_user_model
def post_friends(sender, user, friends, current_friends, inserted_friends, \*\*kwargs):
def post_friends(sender, user, friends, current_friends, inserted_friends, **kwargs):
# Do other stuff
facebook_post_store_friends.connect(post_friends, sender=get_user_model())
``facebook_post_store_likes`` signal is sent after Django-facebook finishes storing the user's likes. This is usefull if you want to customize what topics etc to follow.

::
.. code-block:: python
from django_facebook import signals
from django_facebook.utils import get_user_model
def post_likes(sender, user, likes, current_likes, inserted_likes, \*\*kwargs):
def post_likes(sender, user, likes, current_likes, inserted_likes, **kwargs):
# Do other stuff
facebook_post_store_likes.connect(post_likes, sender=get_user_model())

0 comments on commit 04bdf09

Please sign in to comment.