Пример #1
0
 def get(self, path, cache, **kwargs):
     if cache is None:
         category = category_schema.dump(
             category_utils.get_parent_category_by_category_id(kwargs['category_id'])).data
         return caching_utils.cache_json_and_get(path=path, response=category), 200
     else:
         return cache, 200
Пример #2
0
 def get(self, path, cache, **kwargs):
     if cache is None:
         cart = cart_schema.dump(
             cart_utils.get_cart_by_consumer_id(kwargs['consumer_id'])).data
         return cache_json_and_get(path=path, response=cart), 200
     else:
         return cache, 200
Пример #3
0
 def get(self, path, cache, **kwargs):
     if cache is None:
         subcategories = category_schema_list.dump(
             category_utils.get_subcategories_by_category_slug(kwargs['category_slug'])).data
         return caching_utils.cache_json_and_get(path=path, response=subcategories), 200
     else:
         return cache, 200
Пример #4
0
 def get(self, path, cache, **kwargs):
     if cache is None:
         products = product_schema_list.dump(
             product_utils.get_popular_products_by_category_id(kwargs['category_id'], kwargs['direction'])).data
         return caching_utils.cache_json_and_get(path=path, response=products), 200
     else:
         return cache, 200
Пример #5
0
 def get(self, path, cache, **kwargs):
     if cache is None:
         orders = order_schema_list.dump(order_utils.get_all_orders()).data
         return caching_utils.cache_json_and_get(path=path,
                                                 response=orders), 200
     else:
         return cache, 200
Пример #6
0
 def get(self, path, cache, **kwargs):
     response = dict()
     page_number = pagination_utils.get_page_number()
     if cache is None or 'meta' not in kwargs:
         comments_page = comment_utils.get_comments_by_consumer_id(
             kwargs['consumer_id'], page_number)
         response['meta'] = caching_utils.cache_json_and_get(
             path='{}/meta'.format(path),
             response=pagination_utils.get_meta_from_page(
                 page_number, comments_page))
         response['body'] = caching_utils.cache_json_and_get(
             path=path,
             response=comment_schema_list.dump(comments_page.items).data)
     else:
         response['meta'] = kwargs['meta']
         response['body'] = cache
     return response, 200
Пример #7
0
 def get(self, path, cache):
     if cache is None:
         consumers = consumer_schema_list.dump(
             consumer_utils.get_all_consumers()).data
         return caching_utils.cache_json_and_get(path=path,
                                                 response=consumers), 200
     else:
         return cache, 200
Пример #8
0
 def get(self, path, cache):
     if cache is None:
         products = product_schema_list.dump(
             product_utils.get_popular_products()).data
         return caching_utils.cache_json_and_get(path=path,
                                                 response=products), 200
     else:
         return cache, 200
Пример #9
0
 def get(self, path, cache, **kwargs):
     if cache is None:
         product = product_schema.dump(
             product_utils.get_product_by_id(kwargs['product_id'])).data
         return caching_utils.cache_json_and_get(path=path,
                                                 response=product), 200
     else:
         return cache, 200
Пример #10
0
 def get(self, path, cache, **kwargs):
     if cache is None:
         order = order_schema.dump(
             order_utils.get_order_by_id(kwargs['order_id'])).data
         return caching_utils.cache_json_and_get(path=path,
                                                 response=order), 200
     else:
         return cache, 200
Пример #11
0
 def get(self, path, cache, **kwargs):
     if cache is None:
         products = product_schema_list.dump(
             cart_utils.get_products_from_cart(
                 cart_utils.get_cart_by_consumer_id(
                     kwargs['consumer_id']).items)).data
         return caching_utils.cache_json_and_get(path=path,
                                                 response=products), 200
     else:
         return cache, 200
Пример #12
0
 def get(self, path, cache):
     if cache is None:
         args = search_parser.parse_args()
         search_query = '&'.join(args['find'].split(' '))
         producer_id = args['producer_id']
         category_id = args['category_id']
         result = product_utils.search_products_by_param(
             search_query, producer_id, category_id)
         if result is None:
             return {}, 400
         return caching_utils.cache_json_and_get(
             path=path, response=product_schema_list.dump(result).data), 200
     else:
         return cache
Пример #13
0
 def get(self, path, cache, **kwargs):
     if cache is None:
         categories = category_schema_list.dump(category_utils.get_all_base_categories()).data
         return caching_utils.cache_json_and_get(path=path, response=categories), 200
     else:
         return cache, 200