# Path: userprofiles/settings.py
# class Settings(object):
#     def __init__(self, **kwargs):
#     def __getattr__(self, key):
# def validate_settings():


from datetime import timedelta
from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from userprofiles.settings import up_settings
import uuid




def generate_token():
    return str(uuid.uuid4())


def generate_confirm_expire_date():
    return timezone.now() + timedelta(days=up_settings.EMAIL_VERIFICATION_DAYS)


class EmailVerification(models.Model):
    user = models.ForeignKey(User, verbose_name=_('User'), blank=False)
    old_email = models.EmailField(_('Old e-mail address'))
    new_email = models.EmailField(_('New e-mail address'))

    token = models.CharField(_('Token'), max_length=40, default=generate_token)
    code = models.CharField(_('Code'), max_length=40, default=generate_token)

    is_approved = models.BooleanField(_('Approved'), default=False)
    is_expired = models.BooleanField(_('Expired'), default=False)

    expiration_date = models.DateTimeField(_('Expiration date'),
        default=generate_confirm_expire_date)

    def __unicode__(self):
        return '%s - %s/%s' % (self.user, self.old_email, self.new_email)

    def save(self, *args, **kwargs):

# Path: userprofiles/settings.py
# class Settings(object):
#     def __init__(self, **kwargs):
#     def __getattr__(self, key):
# def validate_settings():


# Path: userprofiles/contrib/emailverification/models.py
from datetime import timedelta
from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from userprofiles.settings import up_settings
import uuid





def generate_token():
    return str(uuid.uuid4())


def generate_confirm_expire_date():
    return timezone.now() + timedelta(days=up_settings.EMAIL_VERIFICATION_DAYS)


class EmailVerification(models.Model):
    user = models.ForeignKey(User, verbose_name=_('User'), blank=False)
    old_email = models.EmailField(_('Old e-mail address'))
    new_email = models.EmailField(_('New e-mail address'))

    token = models.CharField(_('Token'), max_length=40, default=generate_token)
    code = models.CharField(_('Code'), max_length=40, default=generate_token)

    is_approved = models.BooleanField(_('Approved'), default=False)
    is_expired = models.BooleanField(_('Expired'), default=False)

    expiration_date = models.DateTimeField(_('Expiration date'),
        default=generate_confirm_expire_date)

    def __unicode__(self):
        return '%s - %s/%s' % (self.user, self.old_email, self.new_email)

    def save(self, *args, **kwargs):

        if self.is_approved: