コード例 #1
0
 def test_get_seat_from_query(self):
     """ Verify right seat is returned. """
     course, seat = self.create_course_and_seat(course_id=self.course_id)
     self.mock_dynamic_catalog_course_runs_api(query=self.query,
                                               course_run=course)
     response = get_seats_from_query(self.site, self.query, self.seat_type)
     self.assertEqual(seat, response[0])
コード例 #2
0
 def test_get_seat_from_query_no_product(self):
     """ Verify an empty list is returned for no matched seats. """
     course, __ = self.create_course_and_seat(seat_type='professional',
                                              course_id=self.course_id)
     self.mock_dynamic_catalog_course_runs_api(query=self.query,
                                               course_run=course)
     response = get_seats_from_query(self.site, self.query, self.seat_type)
     self.assertEqual(response, [])
コード例 #3
0
ファイル: models.py プロジェクト: 10clouds/ecommerce
 def all_products(self):
     request = get_current_request()
     if self.catalog_query and self.course_seat_types:
         products = get_seats_from_query(request.site, self.catalog_query, self.course_seat_types)
         return products + list(super(Range, self).all_products())  # pylint: disable=bad-super-call
     if self.catalog:
         catalog_products = [record.product for record in self.catalog.stock_records.all()]
         return catalog_products + list(super(Range, self).all_products())  # pylint: disable=bad-super-call
     return super(Range, self).all_products()  # pylint: disable=bad-super-call
コード例 #4
0
 def all_products(self):
     request = get_current_request()
     if self.catalog_query and self.course_seat_types:
         products = get_seats_from_query(request.site, self.catalog_query,
                                         self.course_seat_types)
         return products + list(super(Range, self).all_products())  # pylint: disable=bad-super-call
     if self.catalog:
         catalog_products = [
             record.product for record in self.catalog.stock_records.all()
         ]
         return catalog_products + list(super(Range, self).all_products())  # pylint: disable=bad-super-call
     return super(Range, self).all_products()  # pylint: disable=bad-super-call
コード例 #5
0
ファイル: serializers.py プロジェクト: ED-HEC/ecommerce
 def get_seats(self, obj):
     offer = self.retrieve_offer(obj)
     _range = offer.condition.range
     request = self.context['request']
     if _range.catalog:
         stockrecords = _range.catalog.stock_records.all()
         seats = Product.objects.filter(id__in=[sr.product.id for sr in stockrecords])
     else:
         seats = get_seats_from_query(
             request.site,
             _range.catalog_query,
             _range.course_seat_types
         )
     serializer = ProductSerializer(seats, many=True, context={'request': request})
     return serializer.data