-
-
Notifications
You must be signed in to change notification settings - Fork 701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
15.0 mig website legal page #875
Closed
Closed
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
cd1afaf
[ADD] website_legal_page addon
36aa95f
OCA Transbot updated translations from Transifex
oca-transbot 5bdaa1a
[UPD] prefix versions with 8.0
sbidoul 719473a
[MIG] Make modules uninstallable
pedrobaeza 3ec496d
[8.0][IMP][website_legal_page] Reusable templates for legal terms
yajo d144d70
Seems like I can only set page to True, so I won't set it.
yajo 25f48f2
Upgrade website_legal_page to 9.0
lasley bc3814b
Add missing translations for website_legal_page
lasley e7dce66
[IMP] website_legal_page: Credits to authors
pedrobaeza da2f103
OCA Transbot updated translations from Transifex
oca-transbot b482f2d
[FIX] remove en.po that was erroneously created by transbot
sbidoul 6a3424a
[MIG] Make modules uninstallable
pedrobaeza 1d065a9
[MIG] Rename manifest files
pedrobaeza d56375d
[MIG] website_legal_page: Migrated to 10.0
11344c1
[IMP] website_legal: Move to explicit route
lasley 4940a1a
[MIG][website_legal_page] Migration script and polish
yajo 46d5e07
[FIX][website_legal_page] Fix links in reusable template
yajo a9893d9
[ADD][website_multi_theme] Allow different themes by website (#354)
yajo ca7d59c
[FIX] website_legal_page: add missing space before caret (#391)
zeroheure 5672086
[MIG] website_legal_page : Migration to 11.0
nadiaafa 96b3280
[WARN] failure expected on test due to odoo framework bug
088c311
[FIX] website_legal_page: Remove expected failure
yajo 6f6346e
[FIX] website_legal_page: Flake8
pedrobaeza e64468d
Translated using Weblate (German)
e48ea32
Translated using Weblate (Spanish)
chienandalu 82bab07
Translated using Weblate (Spanish)
cristinamartinrod 84e6dfa
porting website_legal_page to 12.0
eLBati d3ad394
website_legal_page: use correct template names (keys)
irina235 63fe879
website_legal_page 12.0.1.1.0
OCA-git-bot c2ea46c
Translated using Weblate (Portuguese (Brazil))
25279bb
[13.0][MIG] website_legal_page
emagdalenaC2i f69c98d
[IMP] website_legal_page: Finish Migration to 13.0
Tardo 5b71108
[IMP] website_legal_page: black, isort, prettier
ska-ibees 8755b75
[MIG] website_legal_page: Migration to 14.0
ska-ibees 84d1c0c
[UPD] Update website_legal_page.pot
oca-travis 28e5b04
Added translation using Weblate (Spanish (Argentina))
ibuioli 7e4844c
Translated using Weblate (Spanish (Argentina))
ibuioli e11f72f
Translated using Weblate (Catalan)
54052d9
Translated using Weblate (Italian)
dariodomenici 27ae32c
[IMP] website_legal_page: black, isort, prettier
schout-it b0ba1cd
[MIG] website_legal_page: Migration to 15.0
schout-it File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../website_legal_page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
================== | ||
Website Legal Page | ||
================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwebsite-lightgray.png?logo=github | ||
:target: https://github.com/OCA/website/tree/14.0/website_legal_page | ||
:alt: OCA/website | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/website-14-0/website-14-0-website_legal_page | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/186/14.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module was written to provide common legal page needed in any website. | ||
This legal page must be edited using the website builder. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Website editor can change easily any text of these pages using website builder. | ||
|
||
If you install this module after 'website_sale', it will be merge the content | ||
of 'website_sale.terms' into a new page. | ||
|
||
This module hard-redirect '/shop/terms' to '/legal'. | ||
|
||
|
||
Disclaimer | ||
~~~~~~~~~~ | ||
|
||
These legal pages are templates. | ||
|
||
**You must edit the templates and adapt them to your particular case** | ||
|
||
The provided agreements are for **informational purposes only** and do not | ||
constitute legal advice. | ||
|
||
Authors, contributors and maintainer are not law firms and are not providing legal advice. | ||
All information (including agreements, forms and documents) available in this | ||
addon are **provided without any warranty**, express or implied, including as to | ||
their legal effect and completeness. The information **should be used as a | ||
guide** and modified to meet your own individual needs and the laws of your | ||
state. Your use of any information or forms is at your own risk. | ||
|
||
Authors, contributors, maintainer and any of its employees, contractors, or | ||
attorneys who participated in development of this addon **expressly disclaim any | ||
warranty**: they are not creating or entering into any Attorney-Client | ||
relationship by providing information to you. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/website/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/website/issues/new?body=module:%20website_legal_page%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Tecnativa | ||
* LasLabs | ||
* Nicolas JEUDY | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Antonio Espinosa <[email protected]> | ||
* Igor Pastor <[email protected]> | ||
* Dave Lasley <[email protected]> | ||
* Nicola Malcontenti <[email protected]> | ||
* Nicolas JEUDY <https://github.com/njeudy> | ||
* Lorenzo Battistini <https://github.com/eLBati> | ||
* Eduardo Magdalena <[email protected]> (C2i Change 2 improve http://www.c2i.es) | ||
|
||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Rafael Blasco | ||
* Jairo Llopis | ||
* Alexandre Diaz | ||
|
||
Other credits | ||
~~~~~~~~~~~~~ | ||
|
||
Templates | ||
~~~~~~~~~ | ||
|
||
Templates are based on legal templates publicy provided by `termsfeed.com <https://termsfeed.com>`_: | ||
|
||
* `Privacy policy <https://media.termsfeed.com/pdf/privacy-policy-template.pdf>`_ | ||
* `Terms of use <https://media.termsfeed.com/pdf/terms-of-use-template.pdf>`_ | ||
|
||
Icon | ||
~~~~ | ||
|
||
Icon based on ``johnny-automatic-scales-of-justice.svg`` from | ||
`Openclipart <https://openclipart.org/detail/26849/scales-of-justice>`_ | ||
|
||
Thanks to `johnny_automatic <https://openclipart.org/user-detail/johnny_automatic>`_ | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/website <https://github.com/OCA/website/tree/14.0/website_legal_page>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import controllers | ||
from .hooks import post_init_hook, _merge_views |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2015 Antonio Espinosa <[email protected]> | ||
# Copyright 2017 Jairo Llopis <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Website Legal Page", | ||
"category": "Website", | ||
"version": "15.0.1.0.0", | ||
"depends": ["website"], | ||
"data": [ | ||
"views/reusable_templates.xml", | ||
"views/website_legal_main_page.xml", | ||
], | ||
"assets": { | ||
"web.assets_frontend": [ | ||
"/website_legal_page/static/src/css/website_legal_page.scss" | ||
] | ||
}, | ||
"author": "Tecnativa, " | ||
"LasLabs, " | ||
"Nicolas JEUDY, " | ||
"Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/website", | ||
"license": "AGPL-3", | ||
"post_init_hook": "post_init_hook", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2020 Alexandre Díaz - Tecnativa | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import http | ||
from odoo.http import request | ||
|
||
|
||
class WebsiteLegalPage(http.Controller): | ||
@http.route(["/shop/terms"], type="http", auth="public", website=True) | ||
def terms(self, **kw): | ||
""" | ||
Ensure the website_legal_page template usage, even if the page was edited. | ||
This is done in this way because 'http.route' wins to | ||
'website.rewrite' 301 redirections. | ||
""" | ||
return request.redirect("/legal") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# Copyright 2020 Tecnativa - Alexandre Díaz | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from copy import deepcopy | ||
from xml.sax.saxutils import escape | ||
|
||
from lxml import etree as ElementTree | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
|
||
def _merge_views(env, xmlids): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any chance we can have some unit tests for this method? |
||
old_view_ids = env["ir.ui.view"].search( | ||
[("key", "in", xmlids), ("active", "=", True)] | ||
) | ||
# Get only the edited version of the views (if has it) | ||
old_view_ids_edited = old_view_ids.filtered("website_id") | ||
old_view_ids_edited_keys = old_view_ids_edited.mapped("key") | ||
views_to_discard = env["ir.ui.view"] | ||
for old_view in old_view_ids: | ||
if not old_view.website_id and old_view.key in old_view_ids_edited_keys: | ||
views_to_discard |= old_view | ||
old_view_ids -= views_to_discard | ||
new_website_page = env.ref("website_legal_page.legal_page_page") | ||
new_view_id = env.ref("website_legal_page.legal_page") | ||
# 'Dolly' separator element | ||
separator = ElementTree.fromstring( | ||
"<div class='s_hr text-left pt32 pb32' data-name='Separator'>" | ||
+ "<hr class='s_hr_1px s_hr_solid border-600 w-100 mx-auto'/></div>" | ||
) | ||
# Replace new content with the old one per website | ||
website_ids = old_view_ids.mapped("website_id") | ||
for website_id in website_ids: | ||
new_xml = ElementTree.fromstring(new_view_id.arch) | ||
table_content_list = new_xml.xpath("//div[@id='section_list']/ul")[0] | ||
sections_content = new_xml.xpath("//div[@id='section_content']")[0] | ||
has_views_edited = any( | ||
old_view_ids_edited.filtered(lambda x: x.website_id == website_id) | ||
) | ||
# Remove 'IS A SAMPLE' alert | ||
if has_views_edited: | ||
alert = new_xml.xpath( | ||
"//section[@data-name='Title']//div[@data-name='Alert']" | ||
)[0] | ||
alert.find("..").remove(alert) | ||
# Remove unused content | ||
for child in table_content_list.getchildren(): | ||
table_content_list.remove(child) | ||
for child in sections_content.getchildren(): | ||
sections_content.remove(child) | ||
views_done = env["ir.ui.view"] | ||
for old_view_id in old_view_ids: | ||
if old_view_id.website_id != website_id: | ||
continue | ||
anchor_name = old_view_id.key.split(".")[1] | ||
# Insert item in table content list | ||
list_item = ElementTree.fromstring( | ||
"<li><p><a href='#{}'>{}</a></p></li>".format( | ||
anchor_name, escape(old_view_id.name) | ||
) | ||
) | ||
table_content_list.append(list_item) | ||
# Insert section content | ||
old_xml = ElementTree.fromstring(old_view_id.arch) | ||
old_content = old_xml.xpath("//div[@id='wrap']")[0] | ||
sections_content.append(deepcopy(separator)) | ||
sections_content.append( | ||
ElementTree.fromstring( | ||
"<a class='legal_anchor' id='%s'/>" % anchor_name | ||
) | ||
) | ||
for children in old_content.getchildren(): | ||
sections_content.append(children) | ||
views_done |= old_view_id | ||
old_view_ids -= views_done | ||
# Create a new page with the changes | ||
view_id = env["ir.ui.view"].create( | ||
{ | ||
"arch": ElementTree.tostring(new_xml, encoding="unicode"), | ||
"website_id": website_id.id, | ||
"key": new_view_id.key, | ||
"name": new_view_id.name, | ||
"type": "qweb", | ||
} | ||
) | ||
env["website.page"].create( | ||
{ | ||
"name": new_website_page.name, | ||
"url": new_website_page.url, | ||
"view_id": view_id.id, | ||
"is_published": True, | ||
"website_id": website_id.id, | ||
"website_indexed": True, | ||
"website_published": True, | ||
} | ||
) | ||
|
||
|
||
def post_init_hook(cr, registry): | ||
with api.Environment.manage(): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
is_website_sale_installed = ( | ||
env["ir.module.module"].search_count( | ||
[("name", "=", "website_sale"), ("state", "=", "installed")] | ||
) | ||
> 0 | ||
) | ||
if is_website_sale_installed: | ||
_merge_views(env, ["website_sale.terms"]) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 15.0 this is
![image](https://user-images.githubusercontent.com/10028499/157883619-8ee11f75-0df0-47c2-b4e1-0e06d41ac034.png)
/terms
not/shop/terms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be pending.