registration.backends.default package¶
Module contents¶
-
class
registration.backends.default.DefaultRegistrationBackend[source]¶ Bases:
registration.backends.base.RegistrationBackendBaseDefault 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
registrationbe listed in theINSTALLED_APPSsettings (since this backend makes use of models defined in this application).django.contrib.adminbe listed in theINSTALLED_APPSsettings- The setting
ACCOUNT_ACTIVATION_DAYSbe 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.txtregistration/registration_email_subject.txtregistration/acceptance_email.txtregistration/acceptance_email_subject.txtregistration/rejection_email.txtregistration/rejection_email_subject.txtregistration/activation_email.txtregistration/activation_email_subject.txt
Additinally, registration can be temporarily closed by adding the setting
REGISTRATION_OPENand 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
profileGiven a profile, accept account registration, which will set inspection status of
profiletoacceptedand 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_EMAILof settings isNone, no acceptance email will be sent.After successful acceptance, the signal
registration.signals.user_acceptedwill be sent, with the newly acceptedUseras the keyword argumentuesr, theRegistrationProfileof theUseras the keyword argumentprofileand 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_keyandpasswordGiven an activation key, password, look up and activate the user account corresponding to that key (if possible) and set its password.
If
passwordis 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_EMAILof settings isNone, no activation email will be sent.After successful activation, the signal
registration.signals.user_activatedwill be sent, with the newly activatedUseras the keyword argumentuesr, the password of theUseras the keyword argumentpassword, whether the password has generated or not as the keyword argumentis_generatedand 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
usernameandemailGiven a username, email address, register a new user account, which will initially be inactive and has unusable password.
Along with the new
Userobject, a newregistration.models.RegistrationProfilewill 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_EMAILof settings isNone, no registration email will be sent.After the
UserandRegistrationProfileare created and the registration email is sent, the signalregistration.signals.user_registeredwill be sent, with the newUseras the keyword argumentuser, theRegistrationProfileof the newUseras the keyword argumentprofileand 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_OPENis not specified in settings, or is set toTrue, registration is permitted. - If
REGISTRATION_OPENis both specified and set toFalse, registration is not permitted.
- If
-
reject(profile, request, send_email=None, message=None)[source]¶ reject the account registration of
profileGiven a profile, reject account registration, which will set inspection status of
profiletorejectedand delete activation key ofprofileif 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_EMAILof settings isNone, no rejection email will be sent.After successful rejection, the signal
registration.signals.user_rejectedwill be sent, with the newly rejectedUseras the keyword argumentuesr, theRegistrationProfileof theUseras the keyword argumentprofileand the class of this backend as the sender