Skip to content
Snippets Groups Projects
Commit 2ab6dfac authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[ui][registration][docs] Pre-commit cleanup

parent e00b840f
No related branches found
No related tags found
2 merge requests!367Cleanup ui registration,!342Django 3 migration
...@@ -32,7 +32,7 @@ so. This model's sole purpose is to store data temporarily during ...@@ -32,7 +32,7 @@ so. This model's sole purpose is to store data temporarily during
account registration and activation, and a mechanism for automatically account registration and activation, and a mechanism for automatically
creating an instance of a site-specific profile model is provided via creating an instance of a site-specific profile model is provided via
the ``create_inactive_user`` on ``RegistrationManager``. the ``create_inactive_user`` on ``RegistrationManager``.
``RegistrationProfile`` objects have the following fields: ``RegistrationProfile`` objects have the following fields:
``activation_key`` ``activation_key``
...@@ -47,15 +47,15 @@ the ``create_inactive_user`` on ``RegistrationManager``. ...@@ -47,15 +47,15 @@ the ``create_inactive_user`` on ``RegistrationManager``.
``activation_key_expired()`` ``activation_key_expired()``
Determines whether this ``RegistrationProfile``'s activation key Determines whether this ``RegistrationProfile``'s activation key
has expired. has expired.
Returns ``True`` if the key has expired, ``False`` otherwise. Returns ``True`` if the key has expired, ``False`` otherwise.
Key expiration is determined by a two-step process: Key expiration is determined by a two-step process:
1. If the user has already activated, the key will have been reset 1. If the user has already activated, the key will have been reset
to the string constant ``ACTIVATED``. Re-activating is not to the string constant ``ACTIVATED``. Re-activating is not
permitted, and so this method returns ``True`` in this case. permitted, and so this method returns ``True`` in this case.
2. Otherwise, the date the user signed up is incremented by the 2. Otherwise, the date the user signed up is incremented by the
number of days specified in the setting number of days specified in the setting
``ACCOUNT_ACTIVATION_DAYS`` (which should be the number of days ``ACCOUNT_ACTIVATION_DAYS`` (which should be the number of days
...@@ -68,25 +68,25 @@ The ``RegistrationManager`` ...@@ -68,25 +68,25 @@ The ``RegistrationManager``
=========================== ===========================
Custom manager for the ``RegistrationProfile`` model. Custom manager for the ``RegistrationProfile`` model.
The methods defined here provide shortcuts for account creation and The methods defined here provide shortcuts for account creation and
activation (including generation and emailing of activation keys), and activation (including generation and emailing of activation keys), and
for cleaning out expired inactive accounts. for cleaning out expired inactive accounts.
Methods: Methods:
``activate_user(activation_key)`` ``activate_user(activation_key)``
Validate an activation key and activate the corresponding Validate an activation key and activate the corresponding
``User`` if valid. ``User`` if valid.
If the key is valid and has not expired, return the ``User`` If the key is valid and has not expired, return the ``User``
after activating. after activating.
If the key is not valid or has expired, return ``False``. If the key is not valid or has expired, return ``False``.
If the key is valid but the ``User`` is already active, If the key is valid but the ``User`` is already active,
return ``False``. return ``False``.
To prevent reactivation of an account which has been To prevent reactivation of an account which has been
deactivated by site administrators, the activation key is deactivated by site administrators, the activation key is
reset to the string constant ``RegistrationProfile.ACTIVATED`` reset to the string constant ``RegistrationProfile.ACTIVATED``
...@@ -102,7 +102,7 @@ Methods: ...@@ -102,7 +102,7 @@ Methods:
Create a new, inactive ``User``, generate a Create a new, inactive ``User``, generate a
``RegistrationProfile`` and email its activation key to the ``RegistrationProfile`` and email its activation key to the
``User``, returning the new ``User``. ``User``, returning the new ``User``.
To disable the email, call with ``send_email=False``. To disable the email, call with ``send_email=False``.
The activation email will make use of two templates: The activation email will make use of two templates:
...@@ -133,11 +133,11 @@ Methods: ...@@ -133,11 +133,11 @@ Methods:
argument ``user``) after the ``User`` and argument ``user``) after the ``User`` and
``RegistrationProfile`` have been created, and after the email (if ``RegistrationProfile`` have been created, and after the email (if
any) has been sent. any) has been sent.
``create_profile(user)`` ``create_profile(user)``
Creates a ``RegistrationProfile`` for a given ``User``. Returns Creates a ``RegistrationProfile`` for a given ``User``. Returns
the ``RegistrationProfile``. the ``RegistrationProfile``.
The activation key for the ``RegistrationProfile`` will be a SHA1 The activation key for the ``RegistrationProfile`` will be a SHA1
hash, generated from a combination of the ``User``'s username and hash, generated from a combination of the ``User``'s username and
a random salt. a random salt.
...@@ -145,34 +145,34 @@ Methods: ...@@ -145,34 +145,34 @@ Methods:
``deleted_expired_users()`` ``deleted_expired_users()``
Removes expired instances of ``RegistrationProfile`` and their Removes expired instances of ``RegistrationProfile`` and their
associated ``User`` objects. associated ``User`` objects.
Accounts to be deleted are identified by searching for instances Accounts to be deleted are identified by searching for instances
of ``RegistrationProfile`` with expired activation keys, and then of ``RegistrationProfile`` with expired activation keys, and then
checking to see if their associated ``User`` instances have the checking to see if their associated ``User`` instances have the
field ``is_active`` set to ``False``; any ``User`` who is both field ``is_active`` set to ``False``; any ``User`` who is both
inactive and has an expired activation key will be deleted. inactive and has an expired activation key will be deleted.
It is recommended that this method be executed regularly as part It is recommended that this method be executed regularly as part
of your routine site maintenance; this application provides a of your routine site maintenance; this application provides a
custom management command which will call this method, accessible custom management command which will call this method, accessible
as ``manage.py cleanupregistration``. as ``manage.py cleanupregistration``.
Regularly clearing out accounts which have never been activated Regularly clearing out accounts which have never been activated
serves two useful purposes: serves two useful purposes:
1. It alleviates the ocasional need to reset a 1. It alleviates the ocasional need to reset a
``RegistrationProfile`` and/or re-send an activation email when ``RegistrationProfile`` and/or re-send an activation email when
a user does not receive or does not act upon the initial a user does not receive or does not act upon the initial
activation email; since the account will be deleted, the user activation email; since the account will be deleted, the user
will be able to simply re-register and receive a new activation will be able to simply re-register and receive a new activation
key. key.
2. It prevents the possibility of a malicious user registering one 2. It prevents the possibility of a malicious user registering one
or more accounts and never activating them (thus denying the or more accounts and never activating them (thus denying the
use of those usernames to anyone else); since those accounts use of those usernames to anyone else); since those accounts
will be deleted, the usernames will become available for use will be deleted, the usernames will become available for use
again. again.
If you have a troublesome ``User`` and wish to disable their If you have a troublesome ``User`` and wish to disable their
account while keeping it in the database, simply delete the account while keeping it in the database, simply delete the
associated ``RegistrationProfile``; an inactive ``User`` which associated ``RegistrationProfile``; an inactive ``User`` which
......
...@@ -127,7 +127,7 @@ need to do the following: ...@@ -127,7 +127,7 @@ need to do the following:
for details). for details).
4. Add this line to your site's root URLConf:: 4. Add this line to your site's root URLConf::
(r'^accounts/', include('registration.urls')), (r'^accounts/', include('registration.urls')),
5. Link people to ``/accounts/register/`` so they can start signing 5. Link people to ``/accounts/register/`` so they can start signing
......
...@@ -23,7 +23,7 @@ change this, pass the name of a template as the keyword argument ...@@ -23,7 +23,7 @@ change this, pass the name of a template as the keyword argument
``activation_key`` ``activation_key``
The activation key to validate and use for activating the The activation key to validate and use for activating the
``User``. ``User``.
**Optional arguments** **Optional arguments**
``extra_context`` ``extra_context``
...@@ -40,7 +40,7 @@ change this, pass the name of a template as the keyword argument ...@@ -40,7 +40,7 @@ change this, pass the name of a template as the keyword argument
The ``User`` object corresponding to the account, if the The ``User`` object corresponding to the account, if the
activation was successful. ``False`` if the activation was not activation was successful. ``False`` if the activation was not
successful. successful.
``expiration_days`` ``expiration_days``
The number of days for which activation keys stay valid after The number of days for which activation keys stay valid after
registration. registration.
...@@ -49,7 +49,7 @@ Any extra variables supplied in the ``extra_context`` argument (see ...@@ -49,7 +49,7 @@ Any extra variables supplied in the ``extra_context`` argument (see
above). above).
**Template:** **Template:**
registration/activate.html or ``template_name`` keyword argument. registration/activate.html or ``template_name`` keyword argument.
...@@ -57,14 +57,14 @@ registration/activate.html or ``template_name`` keyword argument. ...@@ -57,14 +57,14 @@ registration/activate.html or ``template_name`` keyword argument.
============ ============
Allow a new user to register an account. Allow a new user to register an account.
Following successful registration, issue a redirect; by default, this Following successful registration, issue a redirect; by default, this
will be whatever URL corresponds to the named URL pattern will be whatever URL corresponds to the named URL pattern
``registration_complete``, which will be ``registration_complete``, which will be
``/accounts/register/complete/`` if using the included URLConf. To ``/accounts/register/complete/`` if using the included URLConf. To
change this, point that named pattern at another URL, or pass your change this, point that named pattern at another URL, or pass your
preferred URL as the keyword argument ``success_url``. preferred URL as the keyword argument ``success_url``.
By default, ``registration.forms.RegistrationForm`` will be used as By default, ``registration.forms.RegistrationForm`` will be used as
the registration form; to change this, pass a different form class as the registration form; to change this, pass a different form class as
the ``form_class`` keyword argument. The form class you specify must the ``form_class`` keyword argument. The form class you specify must
...@@ -98,7 +98,7 @@ None. ...@@ -98,7 +98,7 @@ None.
``form`` ``form``
The registration form. The registration form.
Any extra variables supplied in the ``extra_context`` argument (see Any extra variables supplied in the ``extra_context`` argument (see
above). above).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment