1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
Usage
=====
There are two primary ways to use `django-invitations` described below.
Generic Invitation flow:
* Privileged user invites prospective user by email (via either Django admin, form post, JSON post or programmatically)
* User receives invitation email with confirmation link
* User clicks link and is redirected to a preconfigured url (default is accounts/signup)
Allauth Invitation flow:
* As above but..
* User clicks link, their email is confirmed and they are redirected to signup
* The signup URL has the email prefilled and upon signing up the user is logged into the site
Further details can be found in the following sections.
Allauth Integration
-------------------
As above but note that invitations must come after allauth in the INSTALLED_APPS
Set the allauth ``ACCOUNT_ADAPTER`` setting
.. code-block:: python
ACCOUNT_ADAPTER = 'invitations.models.InvitationsAdapter'
Sending Invites
---------------
First import the model:
.. code-block:: python
from invitations.utils import get_invitation_model
Make an instance of the model:
.. code-block:: python
Invitation = get_invitation_model()
Then finally pass the recipient to the model and send.
.. code-block:: python
# inviter argument is optional
invite = Invitation.create('email@example.com', inviter=request.user)
invite.send_invitation(request)
To send invites via django admin, just add an invite and save.
Bulk Invites
------------
Bulk invites are supported via JSON. Post a list of comma separated emails to the dedicated URL and Invitations will return a data object containing a list of valid and invalid invitations.
Signals
-------
The following signals are emitted:
* ``invite_url_sent``
* ``invite_accepted``
Management Commands
-------------------
Expired and accepted invites can be cleared with the ``clear_expired_invitations`` management command:
.. code-block:: sh
python manage.py clear_expired_invitations
|