text: from __future__ import unicode_literals
  
  from django.db import models
  from django.core.mail import send_mail
  from django.contrib.auth.models import PermissionsMixin
  from django.contrib.auth.base_user import AbstractBaseUser
  from django.utils.translation import ugettext_lazy as _
  
  from .managers import UserManager
  
  
  class User(AbstractBaseUser, PermissionsMixin):
      email = models.EmailField(_('email address'), unique=True)
      first_name = models.CharField(_('first name'), max_length=30, blank=True)
      last_name = models.CharField(_('last name'), max_length=30, blank=True)
      date_joined = models.DateTimeField(_('date joined'), auto_now_add=True)
      is_active = models.BooleanField(_('active'), default=True)
      avatar = models.ImageField(upload_to='avatars/', null=True, blank=True)
  
      objects = UserManager()
  
      USERNAME_FIELD = 'email'
      REQUIRED_FIELDS = []
  
      class Meta:
          verbose_name = _('user')
          verbose_name_plural = _('users')
  
      def is_staff(self):
          return self.is_superuser
      def get_full_name(self):
          full_name = '%s %s' % (self.first_name, self.last_name)
          return full_name.strip()
  
      def get_short_name(self):
          return self.first_name
  
  class ImageItem(models.Model):
      name = models.CharField(_('name'), max_length=30, blank=False)
      description = models.CharField(_('description'), max_length=300, blank=True)
      image = models.ImageField(upload_to='images', null=False, blank=False)
      public = models.BooleanField(default=True)
      uploaded_by = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
      def __str__(self):
          return self.name
  