Skip to content
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
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
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
Jun 10, 2015
36aa95f
OCA Transbot updated translations from Transifex
oca-transbot Oct 5, 2015
5bdaa1a
[UPD] prefix versions with 8.0
sbidoul Oct 9, 2015
719473a
[MIG] Make modules uninstallable
pedrobaeza Oct 14, 2015
3ec496d
[8.0][IMP][website_legal_page] Reusable templates for legal terms
yajo Mar 14, 2016
d144d70
Seems like I can only set page to True, so I won't set it.
yajo Mar 15, 2016
25f48f2
Upgrade website_legal_page to 9.0
lasley Apr 20, 2016
bc3814b
Add missing translations for website_legal_page
lasley Apr 23, 2016
e7dce66
[IMP] website_legal_page: Credits to authors
pedrobaeza May 26, 2016
da2f103
OCA Transbot updated translations from Transifex
oca-transbot Mar 20, 2016
b482f2d
[FIX] remove en.po that was erroneously created by transbot
sbidoul Aug 15, 2016
6a3424a
[MIG] Make modules uninstallable
pedrobaeza Oct 6, 2016
1d065a9
[MIG] Rename manifest files
pedrobaeza Oct 6, 2016
d56375d
[MIG] website_legal_page: Migrated to 10.0
Jan 3, 2017
11344c1
[IMP] website_legal: Move to explicit route
lasley Jun 9, 2017
4940a1a
[MIG][website_legal_page] Migration script and polish
yajo Jun 30, 2017
46d5e07
[FIX][website_legal_page] Fix links in reusable template
yajo Jul 4, 2017
a9893d9
[ADD][website_multi_theme] Allow different themes by website (#354)
yajo Aug 28, 2017
ca7d59c
[FIX] website_legal_page: add missing space before caret (#391)
zeroheure Oct 17, 2017
5672086
[MIG] website_legal_page : Migration to 11.0
nadiaafa Dec 21, 2017
96b3280
[WARN] failure expected on test due to odoo framework bug
Jan 24, 2018
088c311
[FIX] website_legal_page: Remove expected failure
yajo Feb 9, 2018
6f6346e
[FIX] website_legal_page: Flake8
pedrobaeza Feb 9, 2018
e64468d
Translated using Weblate (German)
Aug 29, 2018
e48ea32
Translated using Weblate (Spanish)
chienandalu Sep 27, 2018
82bab07
Translated using Weblate (Spanish)
cristinamartinrod Sep 27, 2018
84e6dfa
porting website_legal_page to 12.0
eLBati Oct 1, 2018
d3ad394
website_legal_page: use correct template names (keys)
irina235 Jul 31, 2019
63fe879
website_legal_page 12.0.1.1.0
OCA-git-bot Jul 31, 2019
c2ea46c
Translated using Weblate (Portuguese (Brazil))
Sep 3, 2019
25279bb
[13.0][MIG] website_legal_page
emagdalenaC2i Oct 16, 2019
f69c98d
[IMP] website_legal_page: Finish Migration to 13.0
Tardo Feb 24, 2020
5b71108
[IMP] website_legal_page: black, isort, prettier
ska-ibees Nov 5, 2020
8755b75
[MIG] website_legal_page: Migration to 14.0
ska-ibees Nov 5, 2020
84d1c0c
[UPD] Update website_legal_page.pot
oca-travis Mar 18, 2021
28e5b04
Added translation using Weblate (Spanish (Argentina))
ibuioli Mar 31, 2021
7e4844c
Translated using Weblate (Spanish (Argentina))
ibuioli Mar 31, 2021
e11f72f
Translated using Weblate (Catalan)
May 11, 2021
54052d9
Translated using Weblate (Italian)
dariodomenici Jan 27, 2022
27ae32c
[IMP] website_legal_page: black, isort, prettier
schout-it Feb 1, 2022
b0ba1cd
[MIG] website_legal_page: Migration to 15.0
schout-it Feb 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup/website_legal_page/odoo/addons/website_legal_page
6 changes: 6 additions & 0 deletions setup/website_legal_page/setup.py
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,
)
140 changes: 140 additions & 0 deletions website_legal_page/README.rst
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.
4 changes: 4 additions & 0 deletions website_legal_page/__init__.py
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
26 changes: 26 additions & 0 deletions website_legal_page/__manifest__.py
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",
}
1 change: 1 addition & 0 deletions website_legal_page/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
16 changes: 16 additions & 0 deletions website_legal_page/controllers/main.py
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)
Copy link
Member

@tarteo tarteo Mar 11, 2022

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 /terms not /shop/terms
image

Copy link
Member

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.

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")
108 changes: 108 additions & 0 deletions website_legal_page/hooks.py
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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we can have some unit tests for this method?
If you don't have the time, don't worry about it..

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"])
Loading