예제 #1
0
 def get(self, request, slug):
     products = Product.objects.filter(future=True,
                                       show_on_home_page=True,
                                       cities__slug=slug,
                                       public=True)
     serializer = ProductListSerializer(products, many=True)
     return Response(serializer.data)
예제 #2
0
    def get(self, request, slug='karaganda'):
        response_data = {}

        info = HomePageInfo.objects.get(city__slug=slug)
        info_serializer = HomeInfoSerializer(info, many=False)
        response_data['homePageInfo'] = info_serializer.data

        slides = Slider.objects.all()
        slides_serializer = SliderSerializer(slides, many=True)
        response_data['slides'] = slides_serializer.data

        categories = Category.objects.filter(show_on_home_page=True,
                                             public=True,
                                             cities__slug=slug)
        categories_serializer = CategoryListSerializer(categories, many=True)
        response_data['categories'] = categories_serializer.data

        products = Product.objects.filter(show_on_home_page=True,
                                          old_price__gt=1,
                                          cities__slug=slug,
                                          public=True)
        products_serializer = ProductListSerializer(products, many=True)
        response_data['products'] = products_serializer.data

        testimonials = Testimonial.objects.filter(public=True,
                                                  show_on_home_page=True)[:10]
        testimonials_serializer = TestimonialsSerializer(testimonials,
                                                         many=True)
        response_data['testimonials'] = testimonials_serializer.data

        return Response(response_data)
예제 #3
0
    def get(self, request, city, pk):
        # city = city.split(',')
        # print(city)
        response_data = {}
        toys = Product.objects.filter(suggest=True,
                                      public=True,
                                      cities__id=city)
        toys_serializer = ProductListSerializer(toys, many=True)
        response_data['toys'] = toys_serializer.data

        product = Product.objects.get(id=pk)
        products = Product.objects.exclude(id=pk).filter(
            category_id=product.category_id, public=True, cities__id=city)[:12]
        products_serializer = ProductListSerializer(products, many=True)
        response_data['products'] = products_serializer.data
        return Response(response_data)
예제 #4
0
    def get(self, request, slug, city_id):
        response_data = {}
        sort = Sort.objects.get(slug=slug)
        sort_serializer = SortDetailSerializer(sort, many=False)
        response_data['sort'] = sort_serializer.data

        products = Product.objects.filter(sort__id=sort.id,
                                          cities__id=city_id,
                                          public=True)
        products_serializer = ProductListSerializer(products, many=True)
        response_data['products'] = products_serializer.data

        return Response(response_data)
예제 #5
0
    def get(self, request, slug, city_id):
        response_data = {}
        category = Category.objects.get(slug=slug)
        category_serializer = CategoryDetailSerializer(category, many=False)
        response_data['category'] = category_serializer.data

        products = Product.objects.filter(category_id=category.id,
                                          cities__id=city_id,
                                          public=True)
        products_serializer = ProductListSerializer(products, many=True)
        response_data['products'] = products_serializer.data

        return Response(response_data)
예제 #6
0
    def get(self, request, slug, city_id):
        response_data = {}
        reason = Reason.objects.get(slug=slug)
        reason_serializer = ReasonsDetailSerializer(reason, many=False)
        response_data['reason'] = reason_serializer.data

        products = Product.objects.filter(reasons__id=reason.id,
                                          cities__id=city_id,
                                          public=True)
        products_serializer = ProductListSerializer(products, many=True)
        response_data['products'] = products_serializer.data

        return Response(response_data)