1 3
from __future__ import unicode_literals
2

3 3
from django.db import models
4 3
from django.core.mail import send_mail
5 3
from django.contrib.auth.models import PermissionsMixin
6 3
from django.contrib.auth.base_user import AbstractBaseUser
7 3
from django.utils.translation import ugettext_lazy as _
8

9 3
from cyborgbackup.main.managers import UserManager
10

11

12 3
class User(AbstractBaseUser, PermissionsMixin):
13 3
    email = models.EmailField(_('email address'), unique=True)
14 3
    first_name = models.CharField(_('first name'), max_length=30, blank=True)
15 3
    last_name = models.CharField(_('last name'), max_length=30, blank=True)
16 3
    date_joined = models.DateTimeField(_('date joined'), auto_now_add=True)
17 3
    is_active = models.BooleanField(_('active'), default=True)
18 3
    is_agent = models.BooleanField(
19
        default=False
20
    )
21 3
    notify_backup_failed = models.BooleanField(
22
        default=False
23
    )
24 3
    notify_backup_success = models.BooleanField(
25
        default=False
26
    )
27 3
    notify_backup_summary = models.BooleanField(
28
        default=False
29
    )
30 3
    notify_backup_daily = models.BooleanField(
31
        default=False
32
    )
33 3
    notify_backup_weekly = models.BooleanField(
34
        default=False
35
    )
36 3
    notify_backup_monthly = models.BooleanField(
37
        default=False
38
    )
39
    # avatar = models.ImageField(upload_to='avatars/', null=True, blank=True)
40

41 3
    objects = UserManager()
42

43 3
    USERNAME_FIELD = 'email'
44 3
    REQUIRED_FIELDS = []
45

46 3
    class Meta:
47 3
        verbose_name = _('user')
48 3
        verbose_name_plural = _('users')
49

50 3
    def get_full_name(self):
51
        '''
52
        Returns the first_name plus the last_name, with a space in between.
53
        '''
54 0
        full_name = '%s %s' % (self.first_name, self.last_name)
55 0
        return full_name.strip()
56

57 3
    def get_short_name(self):
58
        '''
59
        Returns the short name for the user.
60
        '''
61 0
        return self.first_name
62

63 3
    def email_user(self, subject, message, from_email=None, **kwargs):
64
        '''
65
        Sends an email to this User.
66
        '''
67 0
        send_mail(subject, message, from_email, [self.email], **kwargs)

Read our documentation on viewing source code .

Loading