diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-10-05 16:33:32 +0700 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-10-05 16:33:32 +0700 |
| commit | 1c18f6c7438537a60f181d089df06a0b4ba915f9 (patch) | |
| tree | aefc31f3422ff8cd80f0df8d598bfcca7af0525c /indoteknik_api/controllers/product_controller.py | |
| parent | 06a5c0c589a00c036684285766eeddbdd0c39fcb (diff) | |
Float duration flash sale and response 404 data not found
Diffstat (limited to 'indoteknik_api/controllers/product_controller.py')
| -rw-r--r-- | indoteknik_api/controllers/product_controller.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/indoteknik_api/controllers/product_controller.py b/indoteknik_api/controllers/product_controller.py index a127b790..0f29971c 100644 --- a/indoteknik_api/controllers/product_controller.py +++ b/indoteknik_api/controllers/product_controller.py @@ -86,7 +86,7 @@ class ProductController(controller.Controller): if active_flash_sale: flash_sale = { 'banner': base_url + 'api/image/product.pricelist/banner/' + str(active_flash_sale.id) if active_flash_sale.banner else '', - 'duration': (active_flash_sale.end_date - datetime.now()).total_seconds(), + 'duration': round((active_flash_sale.end_date - datetime.now()).total_seconds()), 'products': [] } product_pricelist_item = request.env['product.pricelist.item'].search([('pricelist_id', '=', active_flash_sale.id)]) @@ -104,6 +104,8 @@ class ProductController(controller.Controller): 'promotion': self.get_promotion_by_product(product), }) data.update({'flash_sale': flash_sale}) + else: + return self.response(code=404, description='Data not found') return self.response(data) def get_stock_by_product(self, product_template: object): |
