# Path: deck/models.py
# class Proposal(Activity):
#     is_approved = models.BooleanField(_('Is approved'), default=False)
#     more_information = models.TextField(
#         _('More information'), max_length=10000, null=True, blank=True)
#     slides_url = models.CharField(
#         _('speakerdeck.com/'), max_length=250, null=True, blank=True)
# 
#     def get_full_slides_url(self):
#         if self.slides_url:
#             return 'http://www.speakerdeck.com/{0}'.format(self.slides_url)
# 
#     # relations
#     event = models.ForeignKey(to='deck.Event', related_name='proposals')
# 
#     class Meta:
#         ordering = ['title']
#         verbose_name = _('Proposal')
#         verbose_name_plural = _('Proposals')
# 
#     def save(self, *args, **kwargs):
#         if not self.pk and self.event.closing_date_is_passed:
#             raise ValidationError(
#                 _("This Event doesn't accept Proposals anymore."))
#         return super(Proposal, self).save(*args, **kwargs)
# 
#     @property
#     def get_rate(self):
#         rate = None
#         try:
#             rate = self.votes__rate__sum
#         except AttributeError:
#             rate = self.votes.aggregate(Sum('rate'))['rate__sum']
#         finally:
#             return rate or 0
# 
#     def rate(self, user, rate):
#         rate_int = [r[0] for r in Vote.VOTE_RATES if rate in r][0]
#         with transaction.atomic():
#             self.votes.update_or_create(user=user, defaults={'rate': rate_int})
# 
#     def user_already_voted(self, user):
#         if isinstance(user, AnonymousUser):
#             return False
#         return self.votes.filter(user=user).exists()
# 
#     def user_can_vote(self, user):
#         can_vote = False
#         if self.author == user and not self.event.author == user:
#             pass
#         elif self.event.allow_public_voting:
#             can_vote = True
#         elif user.is_superuser:
#             can_vote = True
#         elif self.event.jury.users.filter(pk=user.pk).exists():
#             can_vote = True
#         return can_vote
# 
#     def user_can_approve(self, user):
#         can_approve = False
#         if user.is_superuser:
#             can_approve = True
#         elif self.event.jury.users.filter(pk=user.pk).exists():
#             can_approve = True
#         return can_approve
# 
#     def get_absolute_url(self):
#         return reverse('view_event', kwargs={'slug': self.event.slug}) + \
#             '#' + self.slug
# 
#     def approve(self):
#         if self.is_approved:
#             raise ValidationError(_("This Proposal was already approved."))
#         self.is_approved = True
#         self.save()
# 
#     def disapprove(self):
#         if not self.is_approved:
#             raise ValidationError(_("This Proposal was already disapproved."))
#         self.is_approved = False
#         self.save()


from django.core.exceptions import AppRegistryNotReady
from django.core.urlresolvers import reverse_lazy
from django.conf import settings
from django.db import models
from django.db.models.signals import post_save, pre_save
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext as _
from deck.models import Proposal
    from django.contrib.auth import get_user_model
    from django.contrib.auth.models import User

    class Meta:
        verbose_name = _('Profile')

    def __str__(self):
        return self.user.get_full_name()

    def get_absolute_url(self):
        return reverse_lazy(
            'user_profile', kwargs={'user__username': self.user.username})

    def get_github_url(self):
        if self.github:
            return 'https://github.com/{}'.format(self.github)

    def get_facebook_url(self):
        if self.facebook:
            return 'https://facebook.com/{}'.format(self.facebook)

    def get_twitter_url(self):
        if self.twitter:
            return 'https://twitter.com/{}'.format(self.twitter)

    def get_site_url(self):
        return self.site

    def get_profile_events(self):
        return self.user.events.filter(is_published=True)

    def get_profile_proposals(self):

# Path: deck/models.py
# class Proposal(Activity):
#     is_approved = models.BooleanField(_('Is approved'), default=False)
#     more_information = models.TextField(
#         _('More information'), max_length=10000, null=True, blank=True)
#     slides_url = models.CharField(
#         _('speakerdeck.com/'), max_length=250, null=True, blank=True)
# 
#     def get_full_slides_url(self):
#         if self.slides_url:
#             return 'http://www.speakerdeck.com/{0}'.format(self.slides_url)
# 
#     # relations
#     event = models.ForeignKey(to='deck.Event', related_name='proposals')
# 
#     class Meta:
#         ordering = ['title']
#         verbose_name = _('Proposal')
#         verbose_name_plural = _('Proposals')
# 
#     def save(self, *args, **kwargs):
#         if not self.pk and self.event.closing_date_is_passed:
#             raise ValidationError(
#                 _("This Event doesn't accept Proposals anymore."))
#         return super(Proposal, self).save(*args, **kwargs)
# 
#     @property
#     def get_rate(self):
#         rate = None
#         try:
#             rate = self.votes__rate__sum
#         except AttributeError:
#             rate = self.votes.aggregate(Sum('rate'))['rate__sum']
#         finally:
#             return rate or 0
# 
#     def rate(self, user, rate):
#         rate_int = [r[0] for r in Vote.VOTE_RATES if rate in r][0]
#         with transaction.atomic():
#             self.votes.update_or_create(user=user, defaults={'rate': rate_int})
# 
#     def user_already_voted(self, user):
#         if isinstance(user, AnonymousUser):
#             return False
#         return self.votes.filter(user=user).exists()
# 
#     def user_can_vote(self, user):
#         can_vote = False
#         if self.author == user and not self.event.author == user:
#             pass
#         elif self.event.allow_public_voting:
#             can_vote = True
#         elif user.is_superuser:
#             can_vote = True
#         elif self.event.jury.users.filter(pk=user.pk).exists():
#             can_vote = True
#         return can_vote
# 
#     def user_can_approve(self, user):
#         can_approve = False
#         if user.is_superuser:
#             can_approve = True
#         elif self.event.jury.users.filter(pk=user.pk).exists():
#             can_approve = True
#         return can_approve
# 
#     def get_absolute_url(self):
#         return reverse('view_event', kwargs={'slug': self.event.slug}) + \
#             '#' + self.slug
# 
#     def approve(self):
#         if self.is_approved:
#             raise ValidationError(_("This Proposal was already approved."))
#         self.is_approved = True
#         self.save()
# 
#     def disapprove(self):
#         if not self.is_approved:
#             raise ValidationError(_("This Proposal was already disapproved."))
#         self.is_approved = False
#         self.save()


# Path: core/models.py
from django.core.exceptions import AppRegistryNotReady
from django.core.urlresolvers import reverse_lazy
from django.conf import settings
from django.db import models
from django.db.models.signals import post_save, pre_save
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext as _
from deck.models import Proposal
    from django.contrib.auth import get_user_model
    from django.contrib.auth.models import User


    class Meta:
        verbose_name = _('Profile')

    def __str__(self):
        return self.user.get_full_name()

    def get_absolute_url(self):
        return reverse_lazy(
            'user_profile', kwargs={'user__username': self.user.username})

    def get_github_url(self):
        if self.github:
            return 'https://github.com/{}'.format(self.github)

    def get_facebook_url(self):
        if self.facebook:
            return 'https://facebook.com/{}'.format(self.facebook)

    def get_twitter_url(self):
        if self.twitter:
            return 'https://twitter.com/{}'.format(self.twitter)

    def get_site_url(self):
        return self.site

    def get_profile_events(self):
        return self.user.events.filter(is_published=True)

    def get_profile_proposals(self):

        return Proposal.objects.filter(