registration.backends.default package¶
Module contents¶
-
class
registration.backends.default.
DefaultRegistrationBackend
[source]¶ Bases:
registration.backends.base.RegistrationBackendBase
Default registration backend class
A registration backend which floows a simple workflow:
- User sigs up, inactive account with unusable password is created.
- Inspector accept or reject the account registration.
- Email is sent to user with/without activation link (without when rejected)
- User clicks activation link, enter password, account is now active
Using this backend requires that
registration
be listed in theINSTALLED_APPS
settings (since this backend makes use of models defined in this application).django.contrib.admin
be listed in theINSTALLED_APPS
settings- The setting
ACCOUNT_ACTIVATION_DAYS
be supplied, specifying (as an integer) the number of days from acceptance during which a user may activate their account (after that period expires, activation will be disallowed). Default is7
- The creation of the templates
registration/registration_email.txt
registration/registration_email_subject.txt
registration/acceptance_email.txt
registration/acceptance_email_subject.txt
registration/rejection_email.txt
registration/rejection_email_subject.txt
registration/activation_email.txt
registration/activation_email_subject.txt
Additinally, registration can be temporarily closed by adding the setting
REGISTRATION_OPEN
and setting it toFalse
. Omitting this setting, or setting it toTrue
, will be imterpreted as meaning that registration is currently open and permitted.Internally, this is accomplished via storing an activation key in an instance of
registration.models.RegistrationProfile
. See that model and its custom manager for full documentation of its fields and supported operations.-
accept
(profile, request, send_email=None, message=None, force=False)[source]¶ accept the account registration of
profile
Given a profile, accept account registration, which will set inspection status of
profile
toaccepted
and generate new activation key ofprofile
.An email will be sent to the supplied email address; The email will be rendered using two templates. See the documentation for
RegistrationProfile.send_acceptance_email()
for information about these templates and the contexts provided to them.If
REGISTRATION_acceptance_EMAIL
of settings isNone
, no acceptance email will be sent.After successful acceptance, the signal
registration.signals.user_accepted
will be sent, with the newly acceptedUser
as the keyword argumentuesr
, theRegistrationProfile
of theUser
as the keyword argumentprofile
and the class of this backend as the sender
-
activate
(activation_key, request, password=None, send_email=None, message=None, no_profile_delete=False)[source]¶ activate user with
activation_key
andpassword
Given an activation key, password, look up and activate the user account corresponding to that key (if possible) and set its password.
If
password
is not given, password will be generatedAn email will be sent to the supplied email address; The email will be rendered using two templates. See the documentation for
RegistrationProfile.send_activation_email()
for information about these templates and the contexts provided to them.If
REGISTRATION_ACTIVATION_EMAIL
of settings isNone
, no activation email will be sent.After successful activation, the signal
registration.signals.user_activated
will be sent, with the newly activatedUser
as the keyword argumentuesr
, the password of theUser
as the keyword argumentpassword
, whether the password has generated or not as the keyword argumentis_generated
and the class of this backend as the sender
-
get_activation_complete_url
(user)[source]¶ Return a url to redirect to after successful user activation
-
get_registration_complete_url
(user)[source]¶ Return a url to redirect to after successful user registration
-
get_supplement_form_class
()[source]¶ Return the default form class used for user registration supplement
-
register
(username, email, request, supplement=None, send_email=None)[source]¶ register new user with
username
andemail
Given a username, email address, register a new user account, which will initially be inactive and has unusable password.
Along with the new
User
object, a newregistration.models.RegistrationProfile
will be created, tied to thatUser
, containing the inspection status and activation key which will be used for this account (activation key is not generated untill its inspection status is set toaccepted
)An email will be sent to the supplied email address; The email will be rendered using two templates. See the documentation for
RegistrationProfile.send_registration_email()
for information about these templates and the contexts provided to them.If
REGISTRATION_REGISTRATION_EMAIL
of settings isNone
, no registration email will be sent.After the
User
andRegistrationProfile
are created and the registration email is sent, the signalregistration.signals.user_registered
will be sent, with the newUser
as the keyword argumentuser
, theRegistrationProfile
of the newUser
as the keyword argumentprofile
and the class of this backend as the sender.
-
registration_allowed
()[source]¶ Indicate whether account registration is currently permitted, based on the value of the setting
REGISTRATION_OEPN
. This is determined as follows:- If
REGISTRATION_OPEN
is not specified in settings, or is set toTrue
, registration is permitted. - If
REGISTRATION_OPEN
is both specified and set toFalse
, registration is not permitted.
- If
-
reject
(profile, request, send_email=None, message=None)[source]¶ reject the account registration of
profile
Given a profile, reject account registration, which will set inspection status of
profile
torejected
and delete activation key ofprofile
if exists.An email will be sent to the supplied email address; The email will be rendered using two templates. See the documentation for
RegistrationProfile.send_rejection_email()
for information about these templates and the contexts provided to them.If
REGISTRATION_REJECTION_EMAIL
of settings isNone
, no rejection email will be sent.After successful rejection, the signal
registration.signals.user_rejected
will be sent, with the newly rejectedUser
as the keyword argumentuesr
, theRegistrationProfile
of theUser
as the keyword argumentprofile
and the class of this backend as the sender