django-viter allows you to invite users to your Django application. Invited users are saved as inactive users in your database and activated upon registration.
pip install django-viter
Add viter, viter.storehandlers.dbstorehandler, django.contrib.sites to your INSTALLED_APPS
INSTALLED_APPS = (
'django.contrib.sites',
'viter'
'viter.sotrehandlers.dbstorehandler'
)
To invite people make use of viter.viter.Viter.invite_emails
from viter.viter import Viter
Viter.invite_emails(['foo@bar.com', 'bar@foo.com'], request.user)
You can keep track of who invites whom:
from django.contrib.auth.models import User
foo = User.objects.get(username='foo')
invitations = foo.invitations.all()
You can keep track of who use what invitations:
from viter.viter import Viter
from django.contrib.auth.models import User
foo_user = User.objects.get(username='foo')
bar_user = User.objects.get(username='bar')
invitation = foo_user.invitations.all()[0]
viter = Viter()
viter.register_usage(invitation, user=bar_user)
invitation_usages = invitation.usages.all()
bar_use_this_invitations = bar_user.invitations_used.all()
By default viter.viter.Viter.invite_emails will render viter/email/subject.txt and viter/email/body.txt for the email.
There are a couple of editable settings
Default : | viter.storehandlers.dbstorehandler.DBStoreHandler |
---|---|
Type : | str |
This indicate the Store Handler used to store the invitation objects.
Default : | viter.generatorhandlers.uuidgeneratorhandler.UUIDGeneratorHandler |
---|---|
Type : | str |
This indicate the Generator Handler used to generate unique ids.
Default : | viter.sendmailhandlers.plainsendmailhandler.PlainSendmailHandler |
---|---|
Type : | str |
This indicate the Sendmail Handler used to construct and send invitation emails.
Default : | '' |
---|
The url name to generate the emails urls with reverse(VITER_URL_NAME, args=hash) If not defined viter will use the VITER_URL_STRING.
Default : | '/?%(hash)s' |
---|
The url string to generate the emails urls with VITER_URL_STRING % { hash: hash }.
Default : | settings.DEFAULT_FROM_EMAIL |
---|
The email address used to send invites from