File: models.py

package info (click to toggle)
django-auth-ldap 1.2.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 712 kB
  • ctags: 493
  • sloc: python: 1,961; makefile: 89
file content (32 lines) | stat: -rw-r--r-- 903 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from django.conf import settings
from django.db import models


# Support for testing Django 1.5's custom user models.
try:
    from django.contrib.auth.models import AbstractBaseUser
except ImportError:
    from django.contrib.auth.models import User

    TestUser = User
else:
    class TestUser(AbstractBaseUser):
        identifier = models.CharField(max_length=40, unique=True, db_index=True)

        USERNAME_FIELD = 'identifier'

        def get_full_name(self):
            return self.identifier

        def get_short_name(self):
            return self.identifier


class TestProfile(models.Model):
    """
    A user profile model for use by unit tests. This has nothing to do with the
    authentication backend itself.
    """
    user = models.OneToOneField(settings.AUTH_USER_MODEL)
    is_special = models.BooleanField(default=False)
    populated = models.BooleanField(default=False)