diff --git a/controllers/main.py b/controllers/main.py index 691a63e..ef60b5d 100644 --- a/controllers/main.py +++ b/controllers/main.py @@ -131,15 +131,27 @@ class AppNotificationController(http.Controller): @http.route('/api/loyalty/app_config', type='jsonrpc', auth='public', methods=['POST'], csrf=False) def fetch_app_config(self, **kw): """ - Public endpoint to fetch app configuration (About Us URL, Contact Us URL). + Public endpoint to fetch app configuration (About Us URL, Contact Us URL, Branding & Theme). """ config = request.env['mapan.app.config'].sudo().search([], limit=1) if not config: - config = request.env['mapan.app.config'].sudo().create({'name': 'App Configuration'}) + config = request.env['mapan.app.config'].sudo().create({ + 'name': 'App Configuration', + 'primary_color': '#C62828', + 'secondary_color': '#FF8F00' + }) + + brand_logo = config.brand_logo + if brand_logo and isinstance(brand_logo, bytes): + brand_logo = brand_logo.decode('utf-8') + return { 'status': 'success', 'about_us_url': config.about_us_url or '', 'contact_us_url': config.contact_us_url or '', + 'brand_logo': brand_logo or '', + 'primary_color': config.primary_color or '#C62828', + 'secondary_color': config.secondary_color or '#FF8F00', } @http.route('/api/loyalty/order_history', type='jsonrpc', auth='user', methods=['POST'], csrf=False) diff --git a/models/app_cms_config.py b/models/app_cms_config.py index 347d5da..c41aae9 100644 --- a/models/app_cms_config.py +++ b/models/app_cms_config.py @@ -18,10 +18,41 @@ class AppCmsConfig(models.Model): help='URL to open when user taps "Contact Us" in the app account menu.' ) + brand_logo = fields.Image( + string='Brand Logo', + help='Logo to be displayed in the app header/dashboard.' + ) + primary_color = fields.Char( + string='Primary Color (Hex)', + default='#C62828', + help='Hex color code for primary theme color, e.g. #C62828' + ) + secondary_color = fields.Char( + string='Secondary Color (Hex)', + default='#FF8F00', + help='Hex color code for secondary theme color, e.g. #FF8F00' + ) + @api.model def get_config(self): """Always return the single config record, creating it if it does not exist.""" config = self.search([], limit=1) if not config: - config = self.create({'name': 'App Configuration'}) - return config + config = self.create({ + 'name': 'App Configuration', + 'primary_color': '#C62828', + 'secondary_color': '#FF8F00' + }) + @api.model + def action_open_config(self): + """Action to open the singleton configuration record.""" + config = self.get_config() + return { + 'name': 'App Settings', + 'type': 'ir.actions.act_window', + 'res_model': 'mapan.app.config', + 'view_mode': 'form', + 'res_id': config.id, + 'target': 'current', + } + diff --git a/views/app_cms_config_views.xml b/views/app_cms_config_views.xml index 84d6243..d80a8d5 100644 --- a/views/app_cms_config_views.xml +++ b/views/app_cms_config_views.xml @@ -10,27 +10,37 @@

Mobile App Settings

- - - + + + + + + + + + + - - + + App Settings - mapan.app.config - form - inline - - [] + + code + + action = model.action_open_config() +