# Path: bakery/auth/managers.py
# class BakeryUserManager(UserManager):
#     pass
# 
# Path: bakery/socialize/models.py
# def do_vote(user, cookie):
#     assert user and cookie
#     if not Vote.objects.has_voted(user, cookie):
#         with transaction.commit_on_success():
#             vote = Vote.objects.create(cookie=cookie, user=user)
#             candy_type = random.choice(CANDIES)
#             Candy.objects.create(candy_type=candy_type[0], user=user, vote=vote)
# 
# CANDIES = (
#     ('rice-cracker', _('Rice Cracker'), '&#x1f358;'),
#     ('candy', _('Candy'), '&#x1f36c;'),
#     ('lollipop', _('Lollipop'), '&#x1f36d;'),
#     ('chocolate-bar', _('Chocolate Bar'), '&#x1f36b;'),
#     ('doughnut', _('Doughnut'), '&#x1f369;'),
#     ('cookie', _('Cookie'), '&#x1f36a;'),
# )
# 
# Path: bakery/utils/gravatar.py
# def get_gravatar(email, secure=False, rating='g', size=80, default='mm'):
#     """Generate a link to the users' Gravatar."""
#     assert rating.lower() in RATINGS
#     assert MIN_SIZE <= size <= MAX_SIZE
# 
#     url = SECURE_BASE_URL if secure else BASE_URL
# 
#     options = {'s': size, 'r': rating, 'd': default}
#     url += email_hash(email) + '?' + urlencode(options)
#     return url


from django.core.urlresolvers import reverse_lazy
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from django.contrib.auth.models import AbstractBaseUser
from bakery.auth.managers import BakeryUserManager
from bakery.socialize.models import do_vote, CANDIES
from bakery.utils.gravatar import get_gravatar
    is_organization = models.BooleanField(_('Organization'))
    profile_url = models.URLField(_('Profile'), blank=True, null=True)
    date_joined = models.DateTimeField(_('date joined'), default=timezone.now)

    objects = BakeryUserManager()

    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = ['password']

    class Meta:
        verbose_name = _('User')
        verbose_name_plural = _('Users')

    def __str__(self):
        return self.username

    def get_absolute_url(self):
        return reverse_lazy('auth:profile', kwargs={'username': self.username})

    def get_full_name(self):
        return self.name

    def get_short_name(self):
        "Returns the short name for the user."
        return self.name

    def get_display_name(self):
        return self.name or self.username

    def get_gravatar(self):

# Path: bakery/auth/managers.py
# class BakeryUserManager(UserManager):
#     pass
# 
# Path: bakery/socialize/models.py
# def do_vote(user, cookie):
#     assert user and cookie
#     if not Vote.objects.has_voted(user, cookie):
#         with transaction.commit_on_success():
#             vote = Vote.objects.create(cookie=cookie, user=user)
#             candy_type = random.choice(CANDIES)
#             Candy.objects.create(candy_type=candy_type[0], user=user, vote=vote)
# 
# CANDIES = (
#     ('rice-cracker', _('Rice Cracker'), '&#x1f358;'),
#     ('candy', _('Candy'), '&#x1f36c;'),
#     ('lollipop', _('Lollipop'), '&#x1f36d;'),
#     ('chocolate-bar', _('Chocolate Bar'), '&#x1f36b;'),
#     ('doughnut', _('Doughnut'), '&#x1f369;'),
#     ('cookie', _('Cookie'), '&#x1f36a;'),
# )
# 
# Path: bakery/utils/gravatar.py
# def get_gravatar(email, secure=False, rating='g', size=80, default='mm'):
#     """Generate a link to the users' Gravatar."""
#     assert rating.lower() in RATINGS
#     assert MIN_SIZE <= size <= MAX_SIZE
# 
#     url = SECURE_BASE_URL if secure else BASE_URL
# 
#     options = {'s': size, 'r': rating, 'd': default}
#     url += email_hash(email) + '?' + urlencode(options)
#     return url


# Path: bakery/auth/models.py
from django.core.urlresolvers import reverse_lazy
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from django.contrib.auth.models import AbstractBaseUser
from bakery.auth.managers import BakeryUserManager
from bakery.socialize.models import do_vote, CANDIES
from bakery.utils.gravatar import get_gravatar

    is_organization = models.BooleanField(_('Organization'))
    profile_url = models.URLField(_('Profile'), blank=True, null=True)
    date_joined = models.DateTimeField(_('date joined'), default=timezone.now)

    objects = BakeryUserManager()

    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = ['password']

    class Meta:
        verbose_name = _('User')
        verbose_name_plural = _('Users')

    def __str__(self):
        return self.username

    def get_absolute_url(self):
        return reverse_lazy('auth:profile', kwargs={'username': self.username})

    def get_full_name(self):
        return self.name

    def get_short_name(self):
        "Returns the short name for the user."
        return self.name

    def get_display_name(self):
        return self.name or self.username

    def get_gravatar(self):

        return get_gravatar(self.email)