# Path: pytask/profile/models.py
# GENDER_CHOICES = (
#   ('Male', 'Male'),
#   ('Female', 'Female'),
# )
# 
# class Profile(models.Model):
#     full_name = models.CharField(
#       max_length=50, verbose_name="Name as on bank account",
#       help_text="Any DD/Cheque will be issued on this name")
# 
#     user = models.ForeignKey(User, unique = True)
# 
#     role = models.CharField(max_length=255,
#                             choices=ROLES_CHOICES,
#                             default=u"Contributor")
# 
#     pynts = models.PositiveSmallIntegerField(default=0)
# 
#     aboutme = models.TextField(
#       blank = True,
#       help_text="This information will be used to judge the eligibility "
#         "for any task")
# 
#     dob = models.DateField(verbose_name=u"Date of Birth",
#                            help_text="YYYY-MM-DD")
# 
#     gender = models.CharField(verbose_name=u'Gender',
#                               max_length=24, choices=GENDER_CHOICES)
# 
#     address = models.TextField(
#       blank=False, help_text="This information will be used to send "
#         "any DDs/Cheques.")
# 
#     phonenum = models.CharField(max_length = 15, blank = True,
#                                 verbose_name = u"Phone Number")
# 
#     def __unicode__(self):
#         return unicode(self.user.username)


import re
from django import forms
from django.utils.translation import ugettext
from registration.forms import RegistrationFormUniqueEmail
from registration.forms import attrs_dict
from registration.models import RegistrationProfile
from pytask.profile.models import GENDER_CHOICES, Profile

    def clean_address(self):
        """ Empty not allowed """

        data = self.cleaned_data['address']
        if not data.strip():
            raise forms.ValidationError("Please enter an address")
        
        return data

    def clean_phonenum(self):
        """ should be of 10 digits """

        data = self.cleaned_data['phonenum']

        if (not data.strip()) or \
           (data.strip("1234567890")) or \
           (len(data)!= 10):
               raise forms.ValidationError("This is not a valid phone number")

        return data

    
    def save(self, profile_callback=None):

        new_user = RegistrationProfile.objects.create_inactive_user(
                       username=self.cleaned_data['username'],
                       password=self.cleaned_data['password1'],
                       email=self.cleaned_data['email'])
        

# Path: pytask/profile/models.py
# GENDER_CHOICES = (
#   ('Male', 'Male'),
#   ('Female', 'Female'),
# )
# 
# class Profile(models.Model):
#     full_name = models.CharField(
#       max_length=50, verbose_name="Name as on bank account",
#       help_text="Any DD/Cheque will be issued on this name")
# 
#     user = models.ForeignKey(User, unique = True)
# 
#     role = models.CharField(max_length=255,
#                             choices=ROLES_CHOICES,
#                             default=u"Contributor")
# 
#     pynts = models.PositiveSmallIntegerField(default=0)
# 
#     aboutme = models.TextField(
#       blank = True,
#       help_text="This information will be used to judge the eligibility "
#         "for any task")
# 
#     dob = models.DateField(verbose_name=u"Date of Birth",
#                            help_text="YYYY-MM-DD")
# 
#     gender = models.CharField(verbose_name=u'Gender',
#                               max_length=24, choices=GENDER_CHOICES)
# 
#     address = models.TextField(
#       blank=False, help_text="This information will be used to send "
#         "any DDs/Cheques.")
# 
#     phonenum = models.CharField(max_length = 15, blank = True,
#                                 verbose_name = u"Phone Number")
# 
#     def __unicode__(self):
#         return unicode(self.user.username)


# Path: pytask/profile/forms.py
import re
from django import forms
from django.utils.translation import ugettext
from registration.forms import RegistrationFormUniqueEmail
from registration.forms import attrs_dict
from registration.models import RegistrationProfile
from pytask.profile.models import GENDER_CHOICES, Profile


    def clean_address(self):
        """ Empty not allowed """

        data = self.cleaned_data['address']
        if not data.strip():
            raise forms.ValidationError("Please enter an address")
        
        return data

    def clean_phonenum(self):
        """ should be of 10 digits """

        data = self.cleaned_data['phonenum']

        if (not data.strip()) or \
           (data.strip("1234567890")) or \
           (len(data)!= 10):
               raise forms.ValidationError("This is not a valid phone number")

        return data

    
    def save(self, profile_callback=None):

        new_user = RegistrationProfile.objects.create_inactive_user(
                       username=self.cleaned_data['username'],
                       password=self.cleaned_data['password1'],
                       email=self.cleaned_data['email'])
        

        new_profile = Profile(user=new_user,