Example #1
0
    def get_context_data(self, *args, **kwargs):
        query = str(self.request.GET.get('q')).strip()

        context = super().get_context_data(*args, **kwargs)

        context['q'] = query
        context['title'] = _('Search')
        context['title_page_suffix'] = query
        context['movies_title'] = _('Movies')
        context['movies'] = Movie.objects.filter(name__icontains=query)
        context['celebs_title'] = _('Celebrities')
        context['celebs'] = Celebrity.objects.filter(name__icontains=query)

        context['duties'] = Duty.objects.filter(name__icontains=query)
        context['genres'] = Genre.objects.filter(name__icontains=query)
        context['pg_ratings'] = PgRating.objects.filter(name__icontains=query)
        """
        # TODO: this part is for fast search with postgreSQL.search

        context['movies'] = Movie.objects.annotate(rank=SearchRank(
            F('name_vector'), SearchQuery(query))).filter(
                rank__gt=0.0).order_by('-rank')
        context['celebs'] = Celebrity.objects.annotate(rank=SearchRank(
            F('name_vector'), SearchQuery(query))).filter(
                rank__gt=0.0).order_by('-rank')
        """

        context['random_movies'] = get_random_movies(3)
        context['random_celebs'] = get_random_celebs(3)

        return context
Example #2
0
 def get_context_data(self, *args, **kwargs):
     context = super().get_context_data(*args, **kwargs)
     context['title'] = _('Top Movies')
     context['description'] = _('Top Rated Movies of IMDB')
     context['random_celebs'] = get_random_celebs(3)
     context['random_movies'] = get_random_movies_limited(3)
     return context
Example #3
0
 def get_context_data(self, *args, **kwargs):
     context = super().get_context_data(*args, **kwargs)
     context['title'] = self.object.name
     context['title_alt'] = _('Movie')
     context['random_celebs'] = get_random_celebs(3)
     context['random_movies'] = get_random_movies_limited(3)
     return context
Example #4
0
 def get_context_data(self, *args, **kwargs):
     context = super().get_context_data(*args, **kwargs)
     context['title'] = _('Genres')
     context['description'] = _('Movie genres used to categorize movies \
         on this wesite is listed below.')
     context['random_celebs'] = get_random_celebs(3)
     context['random_movies'] = get_random_movies_limited(3)
     return context
Example #5
0
 def get_context_data(self, *args, **kwargs):
     context = super().get_context_data(*args, **kwargs)
     context['title'] = _('Parental Guidance (PG) Ratings')
     context['description'] = _('Motion picture content & TV content \
         is rated with Parental Guidance (PG) rating system.')
     context['random_celebs'] = get_random_celebs(3)
     context['random_movies'] = get_random_movies_limited(3)
     return context
Example #6
0
 def get_context_data(self, *args, **kwargs):
     context = super().get_context_data(*args, **kwargs)
     context['title'] = self.object.name
     context['title_alt'] = _('Genre')
     context['title_page_prefix'] = _('Genre')
     context['movies'] = Movie.objects.only(
         'name', 'slug', 'image', 'imdb_rating', 'duration',
         'release_date').filter(genres__id=self.get_object().id)
     context['random_celebs'] = get_random_celebs(3)
     context['random_movies'] = get_random_movies_limited(3)
     return context