From aefbbe76d0cb228d6928180991f59829d3ef2139 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 7 Mar 2023 15:06:30 +0700 Subject: Add website page content --- indoteknik_api/controllers/api_v1/__init__.py | 1 + indoteknik_api/controllers/api_v1/page_content.py | 23 +++++++++++ indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/website_page_content.py | 10 +++++ indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/website_page_content.xml | 48 +++++++++++++++++++++++ 7 files changed, 85 insertions(+) create mode 100644 indoteknik_api/controllers/api_v1/page_content.py create mode 100644 indoteknik_custom/models/website_page_content.py create mode 100644 indoteknik_custom/views/website_page_content.xml diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py index df89fcaf..682cb369 100644 --- a/indoteknik_api/controllers/api_v1/__init__.py +++ b/indoteknik_api/controllers/api_v1/__init__.py @@ -8,6 +8,7 @@ from . import download from . import flash_sale from . import invoice from . import manufacture +from . import page_content from . import partner from . import product_variant from . import product diff --git a/indoteknik_api/controllers/api_v1/page_content.py b/indoteknik_api/controllers/api_v1/page_content.py new file mode 100644 index 00000000..64f57d3e --- /dev/null +++ b/indoteknik_api/controllers/api_v1/page_content.py @@ -0,0 +1,23 @@ +from .. import controller +from odoo import http +from odoo.http import request + +class PageContent(controller.Controller): + PREFIX = '/api/v1/' + + @http.route(PREFIX + 'page-content', auth='public', methods=['GET', 'OPTIONS']) + def get_page_content(self, **kw): + if not self.authenticate(): + return self.response(code=401, description='Unauthorized') + + data = None + url_path = kw.get('url_path') + page_content = request.env['website.page.content'].search([('url_path', '=', url_path)], limit=1) + if page_content: + data = { + 'id': page_content.id, + 'url_path': page_content.url_path, + 'content': page_content.content, + } + + return self.response(data=data) diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 449fd09c..701f33c0 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -59,6 +59,7 @@ 'views/customer_review.xml', 'views/website_content_channel.xml', 'views/website_content.xml', + 'views/website_page_content.xml', 'views/custom_mail_marketing.xml', 'views/website_ads.xml', 'views/leads_monitoring.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index bba017e7..5a4a0cfd 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -38,6 +38,7 @@ from . import users from . import website_brand_homepage from . import website_categories_homepage from . import website_content +from . import website_page_content from . import website_user_cart from . import website_user_wishlist from . import x_banner_banner diff --git a/indoteknik_custom/models/website_page_content.py b/indoteknik_custom/models/website_page_content.py new file mode 100644 index 00000000..a09de543 --- /dev/null +++ b/indoteknik_custom/models/website_page_content.py @@ -0,0 +1,10 @@ +from odoo import models, fields + + +class WebsitePageContent(models.Model): + _name = 'website.page.content' + _rec_name = 'url_path' + _sql_constraints = [('url_path_unique', 'unique(url_path)', 'URL Path already exists!')] + + url_path = fields.Char(string='Url Path') + content = fields.Html(string='Content') \ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 3f762c13..e704f5a1 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -24,6 +24,7 @@ access_sales_outstanding,access.sales.outstanding,model_sales_outstanding,,1,1,1 access_customer_review,access.customer.review,model_customer_review,,1,1,1,1 access_website_content_channel,access.website.content.channel,model_website_content_channel,,1,1,1,1 access_website_content,access.website.content,model_website_content,,1,1,1,1 +access_website_page_content,access.website.page.content,model_website_page_content,,1,1,1,1 access_invoice_reklas,access.invoice.reklas,model_invoice_reklas,,1,1,1,1 access_custom_mail_marketing,access.custom.mail.marketing,model_custom_mail_marketing,,1,1,1,1 access_website_ads,access.website.ads,model_website_ads,,1,1,1,1 diff --git a/indoteknik_custom/views/website_page_content.xml b/indoteknik_custom/views/website_page_content.xml new file mode 100644 index 00000000..295cffde --- /dev/null +++ b/indoteknik_custom/views/website_page_content.xml @@ -0,0 +1,48 @@ + + + + website.page.content.tree + website.page.content + + + + + + + + + website.page.content.form + website.page.content + +
+ + + + + + + + + + + + +
+
+
+ + + Website Page Content + ir.actions.act_window + website.page.content + tree,form + + + +
\ No newline at end of file -- cgit v1.2.3