Commits

John Costa  committed eb90284 Merge

merge

  • Participants
  • Parent commits 8f242e3, 4545f8d
  • Branches django15mine

Comments (0)

Files changed (3)

File registration/__init__.py

-VERSION = (1, 0, 0, 'final', 0)
+VERSION = (1, 0, 1, 'alpha', 0)
 
 
 def get_version():

File registration/models.py

 class RegistrationManager(models.Manager):
     """
     Custom manager for the ``RegistrationProfile`` model.
-    
+
     The methods defined here provide shortcuts for account creation
     and activation (including generation and emailing of activation
     keys), and for cleaning out expired inactive accounts.
-    
+
     """
     def activate_user(self, activation_key):
         """
         Validate an activation key and activate the corresponding
         ``User`` if valid.
-        
+
         If the key is valid and has not expired, return the ``User``
         after activating.
-        
+
         If the key is not valid or has expired, return ``False``.
-        
+
         If the key is valid but the ``User`` is already active,
         return ``False``.
-        
+
         To prevent reactivation of an account which has been
         deactivated by site administrators, the activation key is
         reset to the string constant ``RegistrationProfile.ACTIVATED``
                 profile.save()
                 return user
         return False
-    
+
     def create_inactive_user(self, username, email, password,
                              site, send_email=True):
         """
 
         By default, an activation email will be sent to the new
         user. To disable this, pass ``send_email=False``.
-        
+
         """
-        new_user = User.objects.create_user(username, email, password)
+        new_user = User.objects.create_user(
+                                            username=username,
+                                            email= email,
+                                            password=password)
         new_user.is_active = False
         new_user.save()
 
         """
         Create a ``RegistrationProfile`` for a given
         ``User``, and return the ``RegistrationProfile``.
-        
+
         The activation key for the ``RegistrationProfile`` will be a
         SHA1 hash, generated from a combination of the ``User``'s
         username and a random salt.
-        
+
         """
         salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
-        username = user.username
+        try:
+            # Django >= 1.5
+            username = user.get_username()
+        except AttributeError:
+            # Django < 1.5
+            username = user.username
         if isinstance(username, unicode):
             username = username.encode('utf-8')
         activation_key = hashlib.sha1(salt+username).hexdigest()
         return self.create(user=user,
                            activation_key=activation_key)
-        
+
     def delete_expired_users(self):
         """
         Remove expired instances of ``RegistrationProfile`` and their
         associated ``User``s.
-        
+
         Accounts to be deleted are identified by searching for
         instances of ``RegistrationProfile`` with expired activation
         keys, and then checking to see if their associated ``User``
         instances have the field ``is_active`` set to ``False``; any
         ``User`` who is both inactive and has an expired activation
         key will be deleted.
-        
+
         It is recommended that this method be executed regularly as
         part of your routine site maintenance; this application
         provides a custom management command which will call this
         method, accessible as ``manage.py cleanupregistration``.
-        
+
         Regularly clearing out accounts which have never been
         activated serves two useful purposes:
-        
+
         1. It alleviates the ocasional need to reset a
            ``RegistrationProfile`` and/or re-send an activation email
            when a user does not receive or does not act upon the
            initial activation email; since the account will be
            deleted, the user will be able to simply re-register and
            receive a new activation key.
-        
+
         2. It prevents the possibility of a malicious user registering
            one or more accounts and never activating them (thus
            denying the use of those usernames to anyone else); since
            those accounts will be deleted, the usernames will become
            available for use again.
-        
+
         If you have a troublesome ``User`` and wish to disable their
         account while keeping it in the database, simply delete the
         associated ``RegistrationProfile``; an inactive ``User`` which
         does not have an associated ``RegistrationProfile`` will not
         be deleted.
-        
+
         """
         for profile in self.all():
             try:
     """
     A simple profile which stores an activation key for use during
     user account registration.
-    
+
     Generally, you will not want to interact directly with instances
     of this model; the provided manager includes methods
     for creating and activating new accounts, as well as for cleaning
     out accounts which have never been activated.
-    
+
     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's sole purpose is to store data temporarily during
     account registration and activation.
-    
+
     """
     ACTIVATED = u"ALREADY_ACTIVATED"
-    
+
     user = models.ForeignKey(User, unique=True, verbose_name=_('user'))
     activation_key = models.CharField(_('activation key'), max_length=40)
-    
+
     objects = RegistrationManager()
-    
+
     class Meta:
         verbose_name = _('registration profile')
         verbose_name_plural = _('registration profiles')
-    
+
     def __unicode__(self):
         return u"Registration information for %s" % self.user
-    
+
     def activation_key_expired(self):
         """
         Determine whether this ``RegistrationProfile``'s activation
         key has expired, returning a boolean -- ``True`` if the key
         has expired.
-        
+
         Key expiration is determined by a two-step process:
-        
+
         1. If the user has already activated, the key will have been
            reset to the string constant ``ACTIVATED``. Re-activating
            is not permitted, and so this method returns ``True`` in
            activate their account); if the result is less than or
            equal to the current date, the key has expired and this
            method returns ``True``.
-        
+
         """
         expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS)
         return self.activation_key == self.ACTIVATED or \
         """
         Send an activation email to the user associated with this
         ``RegistrationProfile``.
-        
+
         The activation email will make use of two templates:
 
         ``registration/activation_email_subject.txt``
                                    ctx_dict)
         # Email subject *must not* contain newlines
         subject = ''.join(subject.splitlines())
-        
+
         message = render_to_string('registration/activation_email.txt',
                                    ctx_dict)
-        
+
         self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
-    
+
             data_files.append(os.path.join(prefix, f))
 
 
-setup(name='django-registration',
+LONG_DESCRIPTION = '''Experimental release of django-registration by Pebble.
+Developers should use James Bennett's release at django-registration.
+Contact details have been changed for this release to prevent unecessary emails
+being sent to the upstream developer.
+'''
+
+setup(name='django-registration-pebble',
       version=get_version().replace(' ', '-'),
-      description='An extensible user-registration application for Django',
-      author='James Bennett',
-      author_email='james@b-list.org',
-      url='http://www.bitbucket.org/ubernostrum/django-registration/',
-      download_url='https://bitbucket.org/ubernostrum/django-registration/downloads/django-registration-1.0.tar.gz',
+      description='Pebble experimental release of django-registration',
+      long_description=LONG_DESCRIPTION,
+      author='Scott Walton',
+      author_email='scw@talktopebble.co.uk',
+      url='http://www.bitbucket.org/scott_walton/django-registration/',
+      download_url='',
       package_dir={'registration': 'registration'},
       packages=packages,
       package_data={'registration': data_files},