# Path: users/models.py
# 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=_(
#         "Customer"), on_delete=models.PROTECT, blank=True, null=True, default=None)
#     is_manager = models.BooleanField(
#         _("Is Manager"), help_text=_("Is this user a manager"), default=False)
#     manager = models.ForeignKey("self", verbose_name=_('Manager'), help_text=_(
#         "Select this user's manager"), blank=True, null=True, default=None, on_delete=models.PROTECT)
#     is_admin = models.BooleanField(
#         _("Is Administrator"), help_text=_("Should this user have administrative privileges"), default=False)
#     group = models.ManyToManyField(UserGroup, blank=True, default=None)
# 
#     class Meta:
#         verbose_name = _("User Profile")
#         verbose_name_plural = _("User Profiles")
#         ordering = ['user__first_name', 'created_on']
# 
#     def get_display_name(self):
#         if self.user.get_full_name():
#             return self.user.get_full_name()
#         return self.user.username
# 
#     def __str__(self):
#         return self.get_display_name()
# 
# class UserGroup(models.Model):
#     """
#     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


from django.forms import ModelForm
from django.utils.translation import ugettext as _
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit, HTML
from crispy_forms.bootstrap import Field, FormActions
from users.models import UserProfile, UserGroup
# -*- coding: utf-8 -*-




class UserProfileForm(ModelForm):

    class Meta:
        model = UserProfile
        fields = ['is_manager', 'is_admin', 'manager', 'group']

    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        super(UserProfileForm, self).__init__(*args, **kwargs)

# Path: users/models.py
# 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=_(
#         "Customer"), on_delete=models.PROTECT, blank=True, null=True, default=None)
#     is_manager = models.BooleanField(
#         _("Is Manager"), help_text=_("Is this user a manager"), default=False)
#     manager = models.ForeignKey("self", verbose_name=_('Manager'), help_text=_(
#         "Select this user's manager"), blank=True, null=True, default=None, on_delete=models.PROTECT)
#     is_admin = models.BooleanField(
#         _("Is Administrator"), help_text=_("Should this user have administrative privileges"), default=False)
#     group = models.ManyToManyField(UserGroup, blank=True, default=None)
# 
#     class Meta:
#         verbose_name = _("User Profile")
#         verbose_name_plural = _("User Profiles")
#         ordering = ['user__first_name', 'created_on']
# 
#     def get_display_name(self):
#         if self.user.get_full_name():
#             return self.user.get_full_name()
#         return self.user.username
# 
#     def __str__(self):
#         return self.get_display_name()
# 
# class UserGroup(models.Model):
#     """
#     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


# Path: users/forms.py
from django.forms import ModelForm
from django.utils.translation import ugettext as _
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit, HTML
from crispy_forms.bootstrap import Field, FormActions
from users.models import UserProfile, UserGroup

# -*- coding: utf-8 -*-




class UserProfileForm(ModelForm):

    class Meta:
        model = UserProfile
        fields = ['is_manager', 'is_admin', 'manager', 'group']

    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        super(UserProfileForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper()