Beispiel #1
0
 def get(self, request):
     current_page = request.GET.get('p', '1')
     current_page = int(current_page)
     topic_obj = Topic.objects.select_related(
         'author', 'category').all().order_by('-create_time')
     page_obj = Paginator(current_page, topic_obj.count())
     topic_obj = topic_obj[page_obj.start:page_obj.end]
     page_str = page_obj.page_str(reverse('recent') + '?')
     return render(request, 'topic/recent.html', locals())
Beispiel #2
0
 def get(self, request):
     current_page = request.GET.get('p', '1')
     current_page = int(current_page)
     balance_info_obj = BalanceInfo.objects.filter(user_id=request.session.get('user_info')['uid']).order_by(
         '-create_time')
     page_obj = Paginator(current_page, balance_info_obj.count())
     balance_info_obj = balance_info_obj[page_obj.start:page_obj.end]
     page_str = page_obj.page_str(reverse('balance') + '?')
     return render(request, 'operation/balance.html', locals())
Beispiel #3
0
 def get(self, request):
     current_page = request.GET.get('p', '1')
     current_page = int(current_page)
     balance_info_obj = BalanceInfo.objects.filter(user_id=request.session.get('user_info')['uid']).order_by(
         '-add_time')
     page_obj = Paginator(current_page, balance_info_obj.count())
     balance_info_obj = balance_info_obj[page_obj.start:page_obj.end]
     page_str = page_obj.page_str(reverse('balance') + '?')
     return render(request, 'operation/balance.html', locals())
Beispiel #4
0
 def get(self, request):
     is_login = request.session.get('isLogin', None)
     user_info = request.session.get('user_info', None)
     current_page = request.GET.get('p', '1')
     current_page = int(current_page)
     topic_obj = Topic.objects.all().order_by('-add_time')
     page_obj = Paginator(current_page, topic_obj.count())
     topic_obj = topic_obj[page_obj.start:page_obj.end]
     page_str = page_obj.page_str(reverse('recent') + '?')
     return render(request, 'topic/recent.html', locals())
Beispiel #5
0
 def get(self, request, node_code):
     current_page = request.GET.get('p', '1')
     current_page = int(current_page)
     try:
         node_obj = TopicCategory.objects.get(code=node_code,
                                              category_type=2)
         if request.session.get('user_info'):
             node_obj.favorite = FavoriteNode.objects.values_list(
                 'favorite').filter(
                     user_id=request.session.get('user_info')['uid'],
                     node=node_obj).first()
         node_link_obj = NodeLink.objects.select_related('author').filter(
             category=node_obj).order_by('-create_time')
         page_obj = Paginator(current_page, node_link_obj.count())
         node_link_obj = node_link_obj[page_obj.start:page_obj.end]
         page_str = page_obj.page_str(
             reverse('node_link', args=(node_code, )) + '?')
         return render(request, 'topic/node_link.html', locals())
     except TopicCategory.DoesNotExist:
         raise Http404("node does not exist")
Beispiel #6
0
 def get(self, request, node_code):
     is_login = request.session.get('isLogin', None)
     user_info = request.session.get('user_info', None)
     current_page = request.GET.get('p', '1')
     current_page = int(current_page)
     try:
         node_obj = TopicCategory.objects.get(code=node_code,
                                              category_type=2)
         if is_login:
             node_obj.favorite = FavoriteNode.objects.values_list(
                 'favorite').filter(user_id=user_info['uid'],
                                    node=node_obj).first()
         topic_obj = Topic.objects.filter(
             category=node_obj).order_by('-add_time')
         page_obj = Paginator(current_page, topic_obj.count())
         topic_obj = topic_obj[page_obj.start:page_obj.end]
         page_str = page_obj.page_str(
             reverse('node', args=(node_code, )) + '?')
         return render(request, 'topic/node.html', locals())
     except TopicCategory.DoesNotExist:
         raise Http404("node does not exist")