# Path: apply/models.py
# class Organization(models.Model):
#     title = models.CharField(max_length=255)
#     website = models.CharField(max_length=255, null=True, blank=True)
#     email = models.EmailField(null=True, blank=True)
#     tag = models.SlugField(max_length=255, null=True, blank=True)
#     phone = models.CharField(max_length=255, null=True, blank=True)
#     users = models.ManyToManyField(User, blank=True)
# 
#     class Meta:
#         verbose_name = _("organization")
#         verbose_name_plural = _("organizations")
#         ordering = ["title"]
# 
#     def __unicode__(self):
#         return self.title
# 
# Path: accounts/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User)
#     first_login = models.BooleanField(default=True)
#     force_logout_date = models.DateTimeField(null=True, blank=True)
#     organization = models.ForeignKey(Organization, blank=True, null=True)
#     telephone = models.CharField(max_length=13, blank=True, null=True)
# 
#     def force_logout(self):
#         self.force_logout_date = datetime.datetime.now()
#         self.save()
# 
#     def is_owner(self, instance):
#         if self.user in instance.users:
#             return True
#         else:
#             for group in self.user.groups.all():
#                 if group in instance.groups:
#                     return True
#         return False
# 
#     def __unicode__(self):
#         return "%s profile" % self.user


from registration.backends.admin_approval.views import RegistrationView
from apply.models import Organization
from accounts.models import UserProfile
# -*- coding: utf-8 -*- vim:fileencoding=utf-8:
# Copyright (C) 2010-2014 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#



class CustomRegistrationView(RegistrationView):

    def register(self, form):

        new_user = super(RegistrationView, self).register(form)

        telephone = form.cleaned_data['phone']
        organization = form.cleaned_data['organization']


# Path: apply/models.py
# class Organization(models.Model):
#     title = models.CharField(max_length=255)
#     website = models.CharField(max_length=255, null=True, blank=True)
#     email = models.EmailField(null=True, blank=True)
#     tag = models.SlugField(max_length=255, null=True, blank=True)
#     phone = models.CharField(max_length=255, null=True, blank=True)
#     users = models.ManyToManyField(User, blank=True)
# 
#     class Meta:
#         verbose_name = _("organization")
#         verbose_name_plural = _("organizations")
#         ordering = ["title"]
# 
#     def __unicode__(self):
#         return self.title
# 
# Path: accounts/models.py
# class UserProfile(models.Model):
#     user = models.OneToOneField(User)
#     first_login = models.BooleanField(default=True)
#     force_logout_date = models.DateTimeField(null=True, blank=True)
#     organization = models.ForeignKey(Organization, blank=True, null=True)
#     telephone = models.CharField(max_length=13, blank=True, null=True)
# 
#     def force_logout(self):
#         self.force_logout_date = datetime.datetime.now()
#         self.save()
# 
#     def is_owner(self, instance):
#         if self.user in instance.users:
#             return True
#         else:
#             for group in self.user.groups.all():
#                 if group in instance.groups:
#                     return True
#         return False
# 
#     def __unicode__(self):
#         return "%s profile" % self.user


# Path: accounts/views.py
from registration.backends.admin_approval.views import RegistrationView
from apply.models import Organization
from accounts.models import UserProfile

# -*- coding: utf-8 -*- vim:fileencoding=utf-8:
# Copyright (C) 2010-2014 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#



class CustomRegistrationView(RegistrationView):

    def register(self, form):

        new_user = super(RegistrationView, self).register(form)

        telephone = form.cleaned_data['phone']
        organization = form.cleaned_data['organization']


        profile, created = UserProfile.objects.get_or_create(user=new_user)