Exemplo n.º 1
0
 def get_context_data(self, lang_name, **kwargs):
     if lang_name in languages:
         queryset = Content.objects.filter(language=lang_name, status="approved")
         info_of_cards = paginator(self.request, queryset)
         context = super(Languages, self).get_context_data(**kwargs)
         context["content"] = info_of_cards
         context["language"] = lang_name
         return context
     raise Http404
Exemplo n.º 2
0
 def get_context_data(self, hashtag, **kwargs):
     queryset = Content.objects.filter(tags__contains=hashtag, status="approved")
     if queryset.exists():
         info_of_cards = paginator(self.request, queryset)
         context = super(Hashtag, self).get_context_data(**kwargs)
         context["content"] = info_of_cards
         context["nameofhashtag"] = hashtag
         return context
     raise Http404
Exemplo n.º 3
0
 def get_context_data(self, username, **kwargs):
     user = authenticate(
         username=username)  # this line for creating new user
     queryset = Content.objects.filter(user=user, status="approved")
     info_of_cards = paginator(self.request, queryset)
     context = super(Home, self).get_context_data(**kwargs)
     context["content"] = info_of_cards
     context["content_user"] = user
     context["user_follow"] = OtherAddressesOfUsers(user=user).get_addresses
     context["topics"] = UTopic.objects.filter(user=user)
     return context
Exemplo n.º 4
0
 def get_context_data(self, cat_name, **kwargs):
     category = Category.objects.filter(name=cat_name)
     if category.exists():
         queryset = Content.objects.filter(
             category=category[0], status="approved"
         )
         context = super(Categories, self).get_context_data(**kwargs)
         info_of_cards = paginator(self.request, queryset)
         context["content"] = info_of_cards
         context["category"] = cat_name
         return context
     raise Http404
Exemplo n.º 5
0
 def get_context_data(self, topic, *args, **kwargs):
     topic = Topic.objects.filter(name=topic)[0]
     queryset = Content.objects.filter(topic=topic, status="approved")
     if queryset.exists():
         info_of_cards = paginator(self.request, queryset)
         context = super(TopicView, self).get_context_data(**kwargs)
         context["content"] = info_of_cards
         topic_query = Topic.objects.filter(name=topic)
         if topic_query.exists():
             context["topic"] = topic_query[0]
             context["topic_users"] = self.get_users(queryset)
         else:
             Topic(name=topic).save()
         return context
     raise Http404
Exemplo n.º 6
0
 def get_context_data(self, **kwargs):
     context = super(Home, self).get_context_data(**kwargs)
     queryset = Content.objects.filter(status="approved")
     url_name = resolve(self.request.path_info).url_name
     is_authenticated = self.request.user.is_authenticated
     if not is_authenticated and url_name == "home":
         self.template_name = "home/introduction.html"
         check, posts = [], []
         for query in queryset:
             if query.user not in check:
                 check.append(query.user)
                 posts.append(query)
             if len(posts) == settings.PAGE_SIZE:
                 break
         context["introduction"] = True
         queryset = posts
     context["content"] = paginator(self.request, queryset)
     return context
Exemplo n.º 7
0
 def get_context_data(self, **kwargs):
     context = super(Search, self).get_context_data(**kwargs)
     context["content"] = paginator(self.request, self.search_algorithm())
     return context
Exemplo n.º 8
0
 def get_context_data(self, **kwargs):
     context = super(Review, self).get_context_data(**kwargs)
     q = Q(status="shared") | Q(status="changed")
     queryset = Content.objects.filter(q)
     context["content"] = paginator(self.request, queryset)
     return context
Exemplo n.º 9
0
 def get_context_data(self, **kwargs):
     filtered = content_by_filter(self.request.GET.items(), self.queryset)
     context = super(Filter, self).get_context_data(**kwargs)
     context["content"] = paginator(self.request, filtered.get("queryset"))
     context["filter"] = filtered.get("filter")
     return context