# Path: saas/models.py
# class Customer(models.Model):
#     created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
#     updated_on = models.DateTimeField(_("Updated on"), auto_now=True)
#     name = models.CharField(_('Customer name'), max_length=255, blank=False)
#     email = models.EmailField(_('Email address'), blank=True)
#     phone = PhoneNumberField(_('Phone Number'), max_length=255, blank=True)
#     is_active = models.BooleanField(_('Active'), default=True,
#                                     help_text=_('Designates whether this customer should be treated as '
#                                                 'active.'))
# 
#     class Meta:
#         verbose_name = _("Customer")
#         verbose_name_plural = _("Customers")
# 
#     def __str__(self):
#         return self.name


from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible
from saas.models import Customer
from users import signals
    A group of users e.g. a department in an organisation
    """
    created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
    updated_on = models.DateTimeField(_("Updated on"), auto_now=True)
    customer = models.ForeignKey(Customer, verbose_name=_(
        "Customer"), on_delete=models.PROTECT, blank=True, null=True, default=None)
    name = models.CharField(_("Group Name"), max_length=300, blank=False)
    parent = models.ForeignKey(
        "self", verbose_name=_('Parent Group'), blank=True, null=True, default=None, on_delete=models.PROTECT)
    manager = models.ForeignKey(
        "UserProfile", verbose_name=_('Group Manager'), blank=True, null=True, default=None, on_delete=models.PROTECT)

    class Meta:
        verbose_name = _("User Group")
        verbose_name_plural = _("User Groups")
        ordering = ['name']

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class UserProfile(models.Model):

    """
    Model used to store more information on users
    """
    created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
    updated_on = models.DateTimeField(_("Updated on"), auto_now=True)
    user = models.OneToOneField(User, verbose_name=_("User"))

# Path: saas/models.py
# class Customer(models.Model):
#     created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
#     updated_on = models.DateTimeField(_("Updated on"), auto_now=True)
#     name = models.CharField(_('Customer name'), max_length=255, blank=False)
#     email = models.EmailField(_('Email address'), blank=True)
#     phone = PhoneNumberField(_('Phone Number'), max_length=255, blank=True)
#     is_active = models.BooleanField(_('Active'), default=True,
#                                     help_text=_('Designates whether this customer should be treated as '
#                                                 'active.'))
# 
#     class Meta:
#         verbose_name = _("Customer")
#         verbose_name_plural = _("Customers")
# 
#     def __str__(self):
#         return self.name


# Path: users/models.py
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible
from saas.models import Customer
from users import signals

    A group of users e.g. a department in an organisation
    """
    created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
    updated_on = models.DateTimeField(_("Updated on"), auto_now=True)
    customer = models.ForeignKey(Customer, verbose_name=_(
        "Customer"), on_delete=models.PROTECT, blank=True, null=True, default=None)
    name = models.CharField(_("Group Name"), max_length=300, blank=False)
    parent = models.ForeignKey(
        "self", verbose_name=_('Parent Group'), blank=True, null=True, default=None, on_delete=models.PROTECT)
    manager = models.ForeignKey(
        "UserProfile", verbose_name=_('Group Manager'), blank=True, null=True, default=None, on_delete=models.PROTECT)

    class Meta:
        verbose_name = _("User Group")
        verbose_name_plural = _("User Groups")
        ordering = ['name']

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class UserProfile(models.Model):

    """
    Model used to store more information on users
    """
    created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
    updated_on = models.DateTimeField(_("Updated on"), auto_now=True)
    user = models.OneToOneField(User, verbose_name=_("User"))

    customer = models.ForeignKey(Customer, verbose_name=_(