Пример #1
0
 def list(self, request):
     page = request.GET.get('page')
     countries = Country.objects.all()
     if page is not None:
         countries = paginate(countries, page)
     serializer = CountryGeneralSerializer(countries, many=True)
     return Response(serializer.data, status=status.HTTP_200_OK)
 def list(self, request):
     page = request.GET.get('page')
     users = self.get_queryset()
     if page is not None:
         users = paginate(users, page)
     serializer = UserGeneralSerializer(users, many=True)
     return Response(serializer.data, status=status.HTTP_200_OK)
Пример #3
0
 def list(self, request):
   page = request.GET.get('page')
   orgs = Organization.objects.all()
   if page is not None:
     orgs = paginate(orgs, page)
   serializer = OrganizationGeneralSerializer(orgs, many=True)
   return Response(serializer.data, status=status.HTTP_200_OK)
 def list(self, request):
     page = request.GET.get('page')
     disasters = Disaster.objects.all()
     if page is not None:
         disasters = paginate(disasters, page)
     serializer = DisasterGeneralSerializer(disasters, many=True)
     return Response(serializer.data, status=status.HTTP_200_OK)
Пример #5
0
  def list(self, request):
    page = request.GET.get('page')
    comments = Comment.objects.all()

    # Oldest first
    comments = comments.order_by('date_created')
    if page is not None:
      comments = paginate(comments, page)
    serializer = CommentGeneralSerializer(comments, many=True)
    return Response(serializer.data, status=status.HTTP_200_OK)
    def list(self, request):
        page = request.GET.get('page')
        country_id = request.GET.get('country')
        news = News.objects.all()

        # Filter news by country
        if country_id is not None:
            news = news.filter(country_id=country_id)

        # Newest first
        news = news.order_by('-date_created')
        if page is not None:
            news = paginate(news, page)
        serializer = NewsGeneralSerializer(news, many=True)
        return Response(serializer.data, status=status.HTTP_200_OK)
    def list(self, request):
        page = request.GET.get('page')
        funds = Fund.objects.all()
        organization_id = request.GET.get('organization')
        disaster_id = request.GET.get('disaster')
        if organization_id is not None:
            # Filter for all funds by an organization
            funds = funds.fitler(organization_id=organization_id)
        elif disaster_id is not None:
            # Filter for all funds related to a disaster
            funds = funds.fitler(disaster_id=disaster_id)

        funds = funds.order_by('-date_created')
        if page is not None:
            funds = paginate(funds, page)
        serializer = FundGeneralSerializer(funds, many=True)
        return Response(serializer.data, status=status.HTTP_200_OK)
Пример #8
0
  def list(self, request):
    page = request.GET.get('page')
    country_id = request.GET.get('country')
    personal = request.GET.get('personal')
    posts = Post.objects.all()

    if country_id is not None:
      # Filter posts by country
      posts = posts.filter(country_id=country_id)
    elif personal is not None:
      # Filter for posts made by the current user
      posts = posts.filter(user_id=request.user.id)

    # Newest first
    posts = posts.order_by('-date_created')
    if page is not None:
      posts = paginate(posts, page)
    serializer = PostGeneralSerializer(posts, many=True)
    return Response(serializer.data, status=status.HTTP_200_OK)