summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-08-03 08:56:02 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-08-03 08:56:02 +0000
commitbcc35009da39e9ee8b5e181006d3690316b83c59 (patch)
treeb2de61846ad50de44cacc9130c8168d5f3180320 /indoteknik_api/controllers/api_v1
parent769ce2949ad4a3f03e0a05c6298d7299bc5b0d67 (diff)
parent46529f2657d18b6c74bd95c013f528de0f687a56 (diff)
Merged in production (pull request #81)
Production
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/banner.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/indoteknik_api/controllers/api_v1/banner.py b/indoteknik_api/controllers/api_v1/banner.py
index 79aa5fa5..d1ebf573 100644
--- a/indoteknik_api/controllers/api_v1/banner.py
+++ b/indoteknik_api/controllers/api_v1/banner.py
@@ -20,26 +20,36 @@ class Banner(controller.Controller):
if type:
query += [('x_banner_category.x_studio_field_KKVl4', '=', type)]
- week_number = self.get_week_number_of_current_month()
if type == 'index-a-1':
- order = 'sequence ASC'
- query += [('for_week', 'in', [week_number, False])]
+ order = 'group_by_week ASC, sequence ASC'
if manufacture_id:
query += [('x_relasi_manufacture', '=', int(manufacture_id))]
banners = request.env['x_banner.banner'].search(query, limit=limit, offset=offset, order=order)
- data = []
+ week_number = self.get_week_number_of_current_month()
+
+ end_datas = []
+ datas = []
for banner in banners:
- data.append({
+ data = {
'name': banner.x_name,
'url': banner.x_url_banner,
'background_color': banner.background_color,
+ 'sequence': banner.sequence,
+ 'group_by_week': banner.group_by_week,
'image': request.env['ir.attachment'].api_image('x_banner.banner', 'x_banner_image', banner.id),
- })
+ }
+
+ if banner.group_by_week and int(banner.group_by_week) < week_number and type == 'index-a-1':
+ end_datas.append(data)
+ continue
+
+ datas.append(data)
- return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')])
+ datas += end_datas
+ return self.response(datas, headers=[('Cache-Control', 'max-age=3600, public')])
def get_week_number_of_current_month(self):
today = datetime.now().day