# Path: twobuntu/utils.py
# def uuid():
#     """
#     Generate a new UUID.
#     """
#     return uuid4().hex


from django.contrib.auth.models import User
from django.db import models
from django.dispatch import receiver
from django.template.defaultfilters import slugify
from django.utils.encoding import python_2_unicode_compatible
from django.utils.timezone import now
from twobuntu.utils import uuid
        if not self.birthday:
            return None
        n, b = now().date(), self.birthday
        return n.year - b.year - (0 if n.month > b.month or n.month == b.month and n.day >= b.day else 1)

    class Meta:
        ordering = ('-user__last_login',)


@receiver(models.signals.post_save, sender=User)
def create_profile(instance, created, **kwargs):
    """
    Create a profile whenever a user is created.
    """
    if created:
        Profile.objects.create(user=instance)


@python_2_unicode_compatible
class ConfirmationKey(models.Model):
    """
    Unique token for confirming a user account or resetting a password.
    """

    user = models.OneToOneField(
        User,
        primary_key=True,
    )
    key = models.CharField(
        max_length=32,

# Path: twobuntu/utils.py
# def uuid():
#     """
#     Generate a new UUID.
#     """
#     return uuid4().hex


# Path: twobuntu/accounts/models.py
from django.contrib.auth.models import User
from django.db import models
from django.dispatch import receiver
from django.template.defaultfilters import slugify
from django.utils.encoding import python_2_unicode_compatible
from django.utils.timezone import now
from twobuntu.utils import uuid

        if not self.birthday:
            return None
        n, b = now().date(), self.birthday
        return n.year - b.year - (0 if n.month > b.month or n.month == b.month and n.day >= b.day else 1)

    class Meta:
        ordering = ('-user__last_login',)


@receiver(models.signals.post_save, sender=User)
def create_profile(instance, created, **kwargs):
    """
    Create a profile whenever a user is created.
    """
    if created:
        Profile.objects.create(user=instance)


@python_2_unicode_compatible
class ConfirmationKey(models.Model):
    """
    Unique token for confirming a user account or resetting a password.
    """

    user = models.OneToOneField(
        User,
        primary_key=True,
    )
    key = models.CharField(
        max_length=32,

        default=uuid,