Exemplo n.º 1
0
 def get_context_data(self, *args, **kwargs):
     context = super().get_context_data(*args, **kwargs)
     search = self.request.GET.get('search')
     context['search'] = search
     context['trends'] = Questions.get_trends()
     if self.request.user.is_authenticated:
         profile = UserProfile.objects.get(user=self.request.user)
         context['photo'] = profile.photo
     return context
Exemplo n.º 2
0
 def get_context_data(self, *args, **kwargs):
     context = super().get_context_data(*args, **kwargs)
     if self.request.user.is_authenticated:
         context['photo'] = self.request.user.userprofile.photo
     if self.request.session.get('order') == 'date':
         context['order_date'] = 'active'
     else:
         context['order_popular'] = 'active'
     tag = self.request.GET.get('tag')
     if tag:
         context['tag_value'] = f'tag:{tag}'
     context['trends'] = Questions.get_trends()
     return context
Exemplo n.º 3
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     data = {}
     photo_url = None
     if self.request.user.is_authenticated:
         data['login'] = self.request.user.username
         data['email'] = self.request.user.email
         profile = UserProfile.objects.filter(user=self.request.user)
         if profile is not None:
             photo_url = profile[0].photo.url
     context['form'] = UserProfileForm(initial=data)
     context['photo_url'] = photo_url
     context['trends'] = Questions.get_trends()
     return context
Exemplo n.º 4
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     number_question_votes = QuestionVotes.objects.filter(
         question=self.question).count()
     context['number_question_votes'] = number_question_votes
     context['question'] = self.question
     if self.request.user.is_authenticated:
         context['photo'] = self.request.user.userprofile.photo
         if self.request.user != self.question.author:
             context['disabled_correct_answer'] = 'disabled'
     else:
         context['disabled_correct_answer'] = 'disabled'
         context['disabled'] = 'disabled'
     form = AnswerCreateForm()
     context['form'] = form
     tag = self.request.GET.get('tag')
     if tag:
         context['tag_value'] = f'tag:{tag}'
     context['trends'] = Questions.get_trends()
     return context
Exemplo n.º 5
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     if self.request.user.is_authenticated:
         context['photo'] = self.request.user.userprofile.photo
     context['trends'] = Questions.get_trends()
     return context
Exemplo n.º 6
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     context['trends'] = Questions.get_trends()
     return context
Exemplo n.º 7
0
 def list(self, request, *args, **kwargs):
     response = super().list(request)
     trends = Questions.get_trends()
     trends_ser = TrendsSerializer(trends, many=True)
     response.data['trends'] = trends_ser.data
     return response