Anonymous avatar Anonymous committed a8738e2

Couple small tweaks

Comments (0)

Files changed (3)

 A registration profile model and associated manager.
 
 The RegistrationProfile model and especially its custom manager
-implement nearly all the logic needed to handle user registration
-and account activation, so before implementing something in a view
-or form, check here to see if they can take care of it for you.
+implement nearly all the logic needed to handle user registration and
+account activation, so before implementing something in a view or
+form, check here to see if they can take care of it for you.
 
-Also, be sure to see the note on RegistrationProfile about use of
-the ``AUTH_PROFILE_MODULE`` setting.
+Also, be sure to see the note on RegistrationProfile about use of the
+``AUTH_PROFILE_MODULE`` setting.
 
 """
 
     """
     def activate_user(self, activation_key):
         """
-        Given the activation key, makes a User's account active if
-        the activation key is valid and has not expired.
+        Given the activation key, makes a User's account active if the
+        activation key is valid and has not expired.
         
         Returns the User if successful, or False if the account was
         not found or the key had expired.
     
     def create_inactive_user(self, username, password, email, send_email=True):
         """
-        Creates a new User and a new RegistrationProfile
-        for that User, generates an activation key, and mails
-        it.
+        Creates a new User and a new RegistrationProfile for that
+        User, generates an activation key, and mails it.
         
         Pass ``send_email=False`` to disable sending the email.
         
         """
         Removes unused profiles and their associated accounts.
 
-        This is provided largely as a convenience for maintenance purposes;
-        if a RegistrationProfile's key expires without the account being
-        activated, then both the RegistrationProfile and the associated User
-        become clutter in the database, and (more importantly) it won't be
-        possible for anyone to ever come back and claim the username. For best
-        results, set this up to run regularly as a cron job.
+        This is provided largely as a convenience for maintenance
+        purposes; if a RegistrationProfile's key expires without the
+        account being activated, then both the RegistrationProfile and
+        the associated User become clutter in the database, and (more
+        importantly) it won't be possible for anyone to ever come back
+        and claim the username. For best results, set this up to run
+        regularly as a cron job.
         
-        If you have a User whose account you want to keep in the database even
-        though it's inactive (say, to prevent a troublemaker from accessing or
-        re-creating his account), just delete that User's RegistrationProfile
-        and this method will leave it alone.
+        If you have a User whose account you want to keep in the
+        database even though it's inactive (say, to prevent a
+        troublemaker from accessing or re-creating his account), just
+        delete that User's RegistrationProfile and this method will
+        leave it alone.
         
         """
         for profile in self.all():
-            user = profile.user
-            if profile.activation_key_expired and not user.is_active:
-                user.delete() # Removing the User will remove the RegistrationProfile, too.
+            if profile.activation_key_expired:
+                user = profile.user
+                if not user.is_active:
+                    user.delete() # Removing the User will remove the RegistrationProfile, too.
 
 
 class RegistrationProfile(models.Model):
     """
-    Simple profile model for a User, storing a registration
-    date and an activation key for the account.
+    Simple profile model for a User, storing a registration date and
+    an activation key for the account.
     
     While it is possible to use this model as the value of the
-    ``AUTH_PROFILE_MODULE`` setting, it's not recommended that
-    you do so. This model is intended solely to store some data
-    needed for user registration, and can do that regardless of
-    what you set in ``AUTH_PROFILE_MODULE``, so if you want to
-    use user profiles in a project, it's far better to develop
-    a customized model for that purpose and just let this one
-    handle registration.
+    ``AUTH_PROFILE_MODULE`` setting, it's not recommended that you do
+    so. This model is intended solely to store some data needed for
+    user registration, and can do that regardless of what you set in
+    ``AUTH_PROFILE_MODULE``, so if you want to use user profiles in a
+    project, it's far better to develop a customized model for that
+    purpose and just let this one handle registration.
     
     """
     user = models.ForeignKey(User, unique=True)
     
     def activation_key_expired(self):
         """
-        Determines whether this Profile's activation key has expired, based
-        on the value of the setting ``ACCOUNT_ACTIVATION_DAYS``.
+        Determines whether this Profile's activation key has expired,
+        based on the value of the setting ``ACCOUNT_ACTIVATION_DAYS``.
         
         """
-        return self.key_generated + datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS) <= datetime.datetime.now()
+        expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS)
+        return self.key_generated + expiration_date <= datetime.datetime.now()
 """
 URLConf for Django user registration.
 
-Recommended usage is to use a call to ``include()`` in your
-project's root URLConf to include this URLConf for any URL
-begninning with '/accounts/'.
+Recommended usage is to use a call to ``include()`` in your project's
+root URLConf to include this URLConf for any URL begninning with
+'/accounts/'.
 
 """
 
 
 def activate(request, activation_key):
     """
-    Activates a user's account, if their key is valid
-    and hasn't expired.
+    Activates a user's account, if their key is valid and hasn't
+    expired.
 
     Context::
         account
     """
     Allows a new user to register an account.
 
-    On successful registration, an email will be sent to the new
-    user with an activation link to click to make the account
-    active. This view will then redirect to ``success_url``,
-    which defaults to '/accounts/register/complete/'. This
-    application has a URL pattern for that URL and routes it to
-    the ``direct_to_template`` generic view to display a short
-    message telling the user to check their email for the
-    account activation link.
+    On successful registration, an email will be sent to the new user
+    with an activation link to click to make the account active. This
+    view will then redirect to ``success_url``, which defaults to
+    '/accounts/register/complete/'. This application has a URL pattern
+    for that URL and routes it to the ``direct_to_template`` generic
+    view to display a short message telling the user to check their
+    email for the account activation link.
     
     Context::
         form
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.