~ubuntu-branches/ubuntu/utopic/python-django-registration/utopic-proposed

« back to all changes in this revision

Viewing changes to registration/models.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2014-08-06 23:46:28 UTC
  • Revision ID: package-import@ubuntu.com-20140806234628-k1lgla90d5swvm6m
Tags: 1.0+dfsg-2
* Fix and enable the test suite with fix-testsuite.patch. Ensure
  it works with Django 1.6.
* Apply two patches for Django 1.7 compatibility:
  - django-1.7-compat.patch grabbed in an upstream pull request
  - more-django-1.7-fixes.patch authored by myself
  Closes: #755653

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import re
5
5
 
6
6
from django.conf import settings
7
 
from django.contrib.auth.models import User
8
7
from django.db import models
9
8
from django.db import transaction
10
9
from django.template.loader import render_to_string
11
10
from django.utils.translation import ugettext_lazy as _
 
11
from django.contrib.auth import get_user_model
12
12
 
13
 
try:
14
 
    from django.contrib.auth import get_user_model
15
 
    User = get_user_model()
16
 
except ImportError:
17
 
    from django.contrib.auth.models import User
18
13
 
19
14
try:
20
15
    from django.utils.timezone import now as datetime_now
81
76
        user. To disable this, pass ``send_email=False``.
82
77
        
83
78
        """
 
79
        User = get_user_model()
 
80
 
84
81
        new_user = User.objects.create_user(username, email, password)
85
82
        new_user.is_active = False
86
83
        new_user.save()
151
148
        be deleted.
152
149
        
153
150
        """
 
151
        User = get_user_model()
 
152
 
154
153
        for profile in self.all():
155
154
            try:
156
155
                if profile.activation_key_expired():
179
178
    """
180
179
    ACTIVATED = u"ALREADY_ACTIVATED"
181
180
    
182
 
    user = models.ForeignKey(User, unique=True, verbose_name=_('user'))
 
181
    user = models.ForeignKey(settings.AUTH_USER_MODEL, unique=True, verbose_name=_('user'))
183
182
    activation_key = models.CharField(_('activation key'), max_length=40)
184
183
    
185
184
    objects = RegistrationManager()