# Path: warp/users/models.py
# class User(AbstractUser):
# 
#     # First Name and Last Name do not cover name patterns
#     # around the globe.
#     name = models.CharField(_('Name of User'), blank=True, max_length=255)
# 
#     def __str__(self):
#         return self.username
# 
#     def get_profile_image_url(self):
#         social_image = None
#         if self.socialaccount_set.all():
#             social_image = self.socialaccount_set.all()[0].get_avatar_url()
#         if social_image:
#             return social_image
#         return '/static/images/default_profile.svg'
# 
#     def get_absolute_url(self):
#         return reverse('users:detail', kwargs={'username': self.username})


from django.contrib.postgres.search import SearchVector, SearchQuery
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import Manager
from django.db.models import QuerySet
from model_utils.models import TimeStampedModel
from taggit.managers import TaggableManager
from warp.users.models import User
        return self.filter(is_public=True)

    def authored_by(self, author):
        return self.filter(author__username=author)

    def search(self, query):
        return self.annotate(
            search=SearchVector('subject', 'tags__name', 'author__username', 'slide__markdown'))\
            .filter(search=SearchQuery(query))\
            .filter(is_public=True)\
            .distinct('id')\
            .select_related('author')


class PresentationManager(Manager):
    def get_queryset(self):
        return PresentationQuerySet(self.model, using=self._db).select_related('author')

    def public(self):
        return self.get_queryset().public()

    def authored_by(self, author):
        return self.get_queryset().authored_by(author)

    def search(self, query):
        return self.get_queryset().search(query)


class Presentation(TimeStampedModel):
    subject = models.CharField(max_length=50)

# Path: warp/users/models.py
# class User(AbstractUser):
# 
#     # First Name and Last Name do not cover name patterns
#     # around the globe.
#     name = models.CharField(_('Name of User'), blank=True, max_length=255)
# 
#     def __str__(self):
#         return self.username
# 
#     def get_profile_image_url(self):
#         social_image = None
#         if self.socialaccount_set.all():
#             social_image = self.socialaccount_set.all()[0].get_avatar_url()
#         if social_image:
#             return social_image
#         return '/static/images/default_profile.svg'
# 
#     def get_absolute_url(self):
#         return reverse('users:detail', kwargs={'username': self.username})


# Path: presentation/models.py
from django.contrib.postgres.search import SearchVector, SearchQuery
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import Manager
from django.db.models import QuerySet
from model_utils.models import TimeStampedModel
from taggit.managers import TaggableManager
from warp.users.models import User

        return self.filter(is_public=True)

    def authored_by(self, author):
        return self.filter(author__username=author)

    def search(self, query):
        return self.annotate(
            search=SearchVector('subject', 'tags__name', 'author__username', 'slide__markdown'))\
            .filter(search=SearchQuery(query))\
            .filter(is_public=True)\
            .distinct('id')\
            .select_related('author')


class PresentationManager(Manager):
    def get_queryset(self):
        return PresentationQuerySet(self.model, using=self._db).select_related('author')

    def public(self):
        return self.get_queryset().public()

    def authored_by(self, author):
        return self.get_queryset().authored_by(author)

    def search(self, query):
        return self.get_queryset().search(query)


class Presentation(TimeStampedModel):
    subject = models.CharField(max_length=50)

    author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='author')