diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-07 15:06:30 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-07 15:06:30 +0700 |
| commit | aefbbe76d0cb228d6928180991f59829d3ef2139 (patch) | |
| tree | 973ec1693a81ff3075111f3b35af5d4b8dc68290 | |
| parent | c0152c8cc6fcd72e74b0b4bca1d39dbdd2000788 (diff) | |
Add website page content
| -rw-r--r-- | indoteknik_api/controllers/api_v1/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/page_content.py | 23 | ||||
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/website_page_content.py | 10 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/website_page_content.xml | 48 |
7 files changed, 85 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <record id="website_page_content_tree" model="ir.ui.view"> + <field name="name">website.page.content.tree</field> + <field name="model">website.page.content</field> + <field name="arch" type="xml"> + <tree> + <field name="url_path"/> + </tree> + </field> + </record> + + <record id="website_page_content_form" model="ir.ui.view"> + <field name="name">website.page.content.form</field> + <field name="model">website.page.content</field> + <field name="arch" type="xml"> + <form> + <sheet> + <group> + <group> + <field name="url_path" placeholder="/example/url"/> + </group> + </group> + <notebook> + <page string="Content" name="content"> + <field name="content"/> + </page> + </notebook> + </sheet> + </form> + </field> + </record> + + <record id="website_page_content_action" model="ir.actions.act_window"> + <field name="name">Website Page Content</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">website.page.content</field> + <field name="view_mode">tree,form</field> + </record> + + <menuitem + id="menu_website_page_content" + name="Website Page Content" + parent="website.menu_website_global_configuration" + sequence="3" + action="website_page_content_action" + /> +</odoo>
\ No newline at end of file |
