From 4c89edf2f892702363d31af03ee35e8669728ce8 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 30 Dec 2022 10:00:29 +0100 Subject: [PATCH 01/12] [ADD] survey_legal: New module 13.0 TT40980 --- survey_legal/README.rst | 95 ++++ survey_legal/__init__.py | 2 + survey_legal/__manifest__.py | 19 + survey_legal/controllers/__init__.py | 1 + survey_legal/controllers/main.py | 28 ++ survey_legal/i18n/survey_legal.pot | 47 ++ survey_legal/models/__init__.py | 2 + survey_legal/models/survey.py | 13 + survey_legal/models/survey_user_input.py | 12 + survey_legal/readme/CONFIGURE.rst | 7 + survey_legal/readme/CONTRIBUTORS.rst | 3 + survey_legal/readme/DESCRIPTION.rst | 2 + survey_legal/static/description/icon.png | Bin 0 -> 9142 bytes survey_legal/static/description/index.html | 436 ++++++++++++++++++ survey_legal/views/survey_templates.xml | 41 ++ .../views/survey_user_input_views.xml | 17 + survey_legal/views/survey_views.xml | 12 + 17 files changed, 737 insertions(+) create mode 100644 survey_legal/README.rst create mode 100644 survey_legal/__init__.py create mode 100644 survey_legal/__manifest__.py create mode 100644 survey_legal/controllers/__init__.py create mode 100644 survey_legal/controllers/main.py create mode 100644 survey_legal/i18n/survey_legal.pot create mode 100644 survey_legal/models/__init__.py create mode 100644 survey_legal/models/survey.py create mode 100644 survey_legal/models/survey_user_input.py create mode 100644 survey_legal/readme/CONFIGURE.rst create mode 100644 survey_legal/readme/CONTRIBUTORS.rst create mode 100644 survey_legal/readme/DESCRIPTION.rst create mode 100644 survey_legal/static/description/icon.png create mode 100644 survey_legal/static/description/index.html create mode 100644 survey_legal/views/survey_templates.xml create mode 100644 survey_legal/views/survey_user_input_views.xml create mode 100644 survey_legal/views/survey_views.xml diff --git a/survey_legal/README.rst b/survey_legal/README.rst new file mode 100644 index 00000000..a5d3a2ba --- /dev/null +++ b/survey_legal/README.rst @@ -0,0 +1,95 @@ +================== +Survey legal terms +================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fsurvey-lightgray.png?logo=github + :target: https://github.com/OCA/survey/tree/13.0/survey_legal + :alt: OCA/survey +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/survey-13-0/survey-13-0-survey_legal + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/200/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to include a legal terms acceptance checkbox in your surveys. You +have the ability to customize this feature for each individual survey. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To require legal terms acceptance in a survey, follow these steps: + +#. Go to to *Surveys* and select the survey you want to edit. +#. Go to the *Options* tab and check the *Requier legal terms acceptance* checkbox. + +The users of the survey will be required to accept the legal terms before they can +submit their answers to the questions. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_ + + * David Vidal + +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. + +.. |maintainer-chienandalu| image:: https://github.com/chienandalu.png?size=40px + :target: https://github.com/chienandalu + :alt: chienandalu + +Current `maintainer `__: + +|maintainer-chienandalu| + +This module is part of the `OCA/survey `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/survey_legal/__init__.py b/survey_legal/__init__.py new file mode 100644 index 00000000..91c5580f --- /dev/null +++ b/survey_legal/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/survey_legal/__manifest__.py b/survey_legal/__manifest__.py new file mode 100644 index 00000000..2c25589c --- /dev/null +++ b/survey_legal/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2022 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Survey legal terms", + "summary": "Require legal terms before survey submit", + "version": "13.0.1.0.0", + "development_status": "Beta", + "category": "Marketing/Survey", + "website": "https://github.com/OCA/survey", + "author": "Tecnativa, Odoo Community Association (OCA)", + "maintainers": ["chienandalu"], + "license": "AGPL-3", + "depends": ["survey", "website_legal_page"], + "data": [ + "views/survey_views.xml", + "views/survey_templates.xml", + "views/survey_user_input_views.xml", + ], +} diff --git a/survey_legal/controllers/__init__.py b/survey_legal/controllers/__init__.py new file mode 100644 index 00000000..12a7e529 --- /dev/null +++ b/survey_legal/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/survey_legal/controllers/main.py b/survey_legal/controllers/main.py new file mode 100644 index 00000000..cc289bf4 --- /dev/null +++ b/survey_legal/controllers/main.py @@ -0,0 +1,28 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.http import request, route + +from odoo.addons.survey.controllers.main import Survey + + +class SurveyMetada(Survey): + @route() + def survey_submit(self, survey_token, answer_token, **post): + """The acceptance of the legal terms has the user's footprint warranty""" + res = super().survey_submit(survey_token, answer_token, **post) + access_data = self._get_access_data( + survey_token, answer_token, ensure_token=True + ) + if access_data["validity_code"] != "answer_done": + return res + answer_sudo = access_data["answer_sudo"] + if not answer_sudo.survey_id.legal_terms: + return res + environ = request.httprequest.headers.environ + answer_sudo.user_metadata = ( + f"IP: {environ.get('REMOTE_ADDR')}\n" + f"USER_AGENT: {environ.get('HTTP_USER_AGENT')}\n" + f"ACCEPT_LANGUAGE: {environ.get('HTTP_ACCEPT_LANGUAGE')}\n" + f"REFERER: {environ.get('HTTP_REFERER')}\n" + ) + return res diff --git a/survey_legal/i18n/survey_legal.pot b/survey_legal/i18n/survey_legal.pot new file mode 100644 index 00000000..50dd647e --- /dev/null +++ b/survey_legal/i18n/survey_legal.pot @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_legal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: survey_legal +#: model:ir.model.fields,help:survey_legal.field_survey_user_input__user_metadata +msgid "" +"Metadata gathered during survey validation when legal terms are enabled" +msgstr "" + +#. module: survey_legal +#: model:ir.model.fields,field_description:survey_legal.field_survey_survey__legal_terms +msgid "Require legal terms acceptance" +msgstr "" + +#. module: survey_legal +#: model:ir.model,name:survey_legal.model_survey_survey +msgid "Survey" +msgstr "" + +#. module: survey_legal +#: model:ir.model,name:survey_legal.model_survey_user_input +msgid "Survey User Input" +msgstr "" + +#. module: survey_legal +#: model:ir.model.fields,help:survey_legal.field_survey_survey__legal_terms +msgid "" +"The users will be prompted to require the acceptance of the legal terms to " +"be able to submit their answers" +msgstr "" + +#. module: survey_legal +#: model:ir.model.fields,field_description:survey_legal.field_survey_user_input__user_metadata +msgid "User Metadata" +msgstr "" diff --git a/survey_legal/models/__init__.py b/survey_legal/models/__init__.py new file mode 100644 index 00000000..843a39d6 --- /dev/null +++ b/survey_legal/models/__init__.py @@ -0,0 +1,2 @@ +from . import survey +from . import survey_user_input diff --git a/survey_legal/models/survey.py b/survey_legal/models/survey.py new file mode 100644 index 00000000..9db64c0a --- /dev/null +++ b/survey_legal/models/survey.py @@ -0,0 +1,13 @@ +# Copyright 2022 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class SurveySurvey(models.Model): + _inherit = "survey.survey" + + legal_terms = fields.Boolean( + string="Require legal terms acceptance", + help="The users will be prompted to require the acceptance of the legal terms " + "to be able to submit their answers", + ) diff --git a/survey_legal/models/survey_user_input.py b/survey_legal/models/survey_user_input.py new file mode 100644 index 00000000..1037278d --- /dev/null +++ b/survey_legal/models/survey_user_input.py @@ -0,0 +1,12 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class SurveyUserInput(models.Model): + _inherit = "survey.user_input" + + user_metadata = fields.Text( + help="Metadata gathered during survey validation when legal terms are enabled", + readonly=True, + ) diff --git a/survey_legal/readme/CONFIGURE.rst b/survey_legal/readme/CONFIGURE.rst new file mode 100644 index 00000000..2bfb4a9e --- /dev/null +++ b/survey_legal/readme/CONFIGURE.rst @@ -0,0 +1,7 @@ +To require legal terms acceptance in a survey, follow these steps: + +#. Go to to *Surveys* and select the survey you want to edit. +#. Go to the *Options* tab and check the *Requier legal terms acceptance* checkbox. + +The users of the survey will be required to accept the legal terms before they can +submit their answers to the questions. diff --git a/survey_legal/readme/CONTRIBUTORS.rst b/survey_legal/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..fedc8467 --- /dev/null +++ b/survey_legal/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `_ + + * David Vidal diff --git a/survey_legal/readme/DESCRIPTION.rst b/survey_legal/readme/DESCRIPTION.rst new file mode 100644 index 00000000..0099a76f --- /dev/null +++ b/survey_legal/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows you to include a legal terms acceptance checkbox in your surveys. You +have the ability to customize this feature for each individual survey. diff --git a/survey_legal/static/description/icon.png b/survey_legal/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3f200e502252bc7617b5f27380e230d841aae7d9 GIT binary patch literal 9142 zcmV;nBT3weP)PyA07*naRCr$PT?dpDMf(4GW_M?X4Qv1;EJ#{5kTdEj2%@MUD4>s|C}uDmoQjH= z5Iu~D9(QIzJf z>IWzz%HBX6pnwQ1;elmUPr1ge0w11~@z5YWBP zT0T7RYy)kzUM%lKd#$#MCI@HR>jD9y0l*CaG2jvsz$GMt00~la0>!uaqV9T42m}K0 z#|vIOSzfW%TTyjHGxOO7&Z!PMC7_1(hMCrE!U*62m(Uj6kX+_*-IydC%Uk$pN!bsN zRr`x|^rW3BR%cFa0D#1~to?ARy{zAlgmKLPpf&~A2m#ycf)sGOvt|kVvL}9C_A3>6`+DWD?e&_VQ0S$P;!RzA{j= z1ETlJSs9GKgKU&*44}H#UP%s-x68_e5dovs^EEYqwF7|28K9xP04l(+0>ucSbsx#4G9bj@oF?w3{FzB5)zuC*s0cNmlLp#~(?OE2 z$S}PAetnzK^{u^ib%KiQ!=sX%61-D7w}FA|XCM{BI5lw2)my*f9)E^7jiE}aof#T= ze4(Me$_Q=bax|LY!uErgGkZzAwvN>Sv|7HQy$+}(5@4J(x*Fm%dbc$aU|W%+6%#>Z z7~TduW&G9#qgWBVQ|)zf!dh{&MK8$?l~h+d=+uB(nW09J)cVj~VcUUWHM;m%7iV;R zW6au|pgNUgm9or2%Vuj8r1JmEGg>PzC&q_IzC?!MwP~E9QtS0L#A)nSftFN~^#KjX z4Omo_)jW`f_F9kAh=9=!meFcugG%||&ZkiU#_rY5NK_jO)9~nA9-HXT(q1QxVqxq4 z%No3-AW~4!fu!6^V(ZI=-qh$^Y30pw%{NsL)l))U$^zZYU+;<&&f zzg$sy29BJV4W35Xs`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4QaoTAC#Jw;~I)X#lSI^&U1K1zaCf`!+HV|}0HJrOW8;;>8S zS_UAas-lN^Xn`<3+d(f-YXD}IuiFjKqjys103l`-Xpjh{p0I50H@`~awMiIf5*4tF zKrt$B$B}Dfpy-tWH7$hIt0Kr3!P2vLa>&4qbfB%ME|r%wXZ5#?zW@LOWJyFpR9?r( z^I>WMKvn?YoJ|zA`n0N+#|zXlu{%nD?!6Lq%)+8NoC21iO5!zsBZK@5VzoTU z9hVqJi4-dvvrG`z5T`LdkxO!&6Co*hLMAJ-u)ar&$IyOH0-PQ&3QDkQlUOZp%6K}) zv1*f8El)OnS-dzUSXcqz1cMkE%c5KTXR%t|v>y=y7!PLd z(JK*>g9kM$XS`ju2hAqo^`;CN##BI7Z4ySH7|l?MKSlg?O&PB|#xH^e!~L=vGMnK} z0Em^*M1%T)+3f;xand2kmN(p-m0Ws zd!PD*V9J!HMluJ=w{5w02C zbU}>IJ*`tlqtL<0DmRz8=JBkXa-(6yr$FEs1$}+-6ew{JaYI?+>|n zV*4!Qh~!aYnjZIh-O=qj_@Gg&;!=m&wn-RO9gEwl#=RY@)cmRrUFROX8dKveEHj?YN zwhITYbsHbV2DAH>{UX_Xbj_-nuoU@PZLiWKiHdfWHA{(}HhIE2@vxI&-E@w} z>mFED6-e{@170-+@*&9bHW0=E3Ac){HIdR}qLHcj9*qHc;w&Oq&hkJ6O=Cac2uO4~ek9hzPx|8t#0TW2+1M3*8*Z=?k07*qoM6N<$f_X9? ArT_o{ literal 0 HcmV?d00001 diff --git a/survey_legal/static/description/index.html b/survey_legal/static/description/index.html new file mode 100644 index 00000000..7697ac74 --- /dev/null +++ b/survey_legal/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Survey legal terms + + + + + + diff --git a/survey_legal/views/survey_templates.xml b/survey_legal/views/survey_templates.xml new file mode 100644 index 00000000..8dc063e5 --- /dev/null +++ b/survey_legal/views/survey_templates.xml @@ -0,0 +1,41 @@ + + + + + diff --git a/survey_legal/views/survey_user_input_views.xml b/survey_legal/views/survey_user_input_views.xml new file mode 100644 index 00000000..caa8d43a --- /dev/null +++ b/survey_legal/views/survey_user_input_views.xml @@ -0,0 +1,17 @@ + + + + survey.user_input + + + + + + + + + + diff --git a/survey_legal/views/survey_views.xml b/survey_legal/views/survey_views.xml new file mode 100644 index 00000000..26a147a7 --- /dev/null +++ b/survey_legal/views/survey_views.xml @@ -0,0 +1,12 @@ + + + + survey.survey + + + + + + + + From 3d12c2217b6a20db0455afee8c83c4c92b7ec35f Mon Sep 17 00:00:00 2001 From: David Date: Tue, 22 Aug 2023 09:42:33 +0200 Subject: [PATCH 02/12] [MIG] survey_legal: Migration to 15.0 Aside from migration adaptations: - Drop website_require_legal dependency - Validation is now performed in js insead of the view so we need to do so. - Additional control for the legal terms link and text TT44775 --- survey_legal/README.rst | 11 +++--- survey_legal/__manifest__.py | 5 +-- survey_legal/controllers/main.py | 2 +- survey_legal/i18n/survey_legal.pot | 19 +++++++++- survey_legal/models/survey.py | 4 +++ survey_legal/readme/CONFIGURE.rst | 1 + survey_legal/static/description/index.html | 7 ++-- survey_legal/static/src/js/survey_form.esm.js | 31 ++++++++++++++++ survey_legal/views/survey_templates.xml | 35 ++++++++++++++----- survey_legal/views/survey_views.xml | 8 +++++ 10 files changed, 102 insertions(+), 21 deletions(-) create mode 100644 survey_legal/static/src/js/survey_form.esm.js diff --git a/survey_legal/README.rst b/survey_legal/README.rst index a5d3a2ba..5fe22647 100644 --- a/survey_legal/README.rst +++ b/survey_legal/README.rst @@ -14,13 +14,13 @@ Survey legal terms :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsurvey-lightgray.png?logo=github - :target: https://github.com/OCA/survey/tree/13.0/survey_legal + :target: https://github.com/OCA/survey/tree/15.0/survey_legal :alt: OCA/survey .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/survey-13-0/survey-13-0-survey_legal + :target: https://translation.odoo-community.org/projects/survey-15-0/survey-15-0-survey_legal :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/200/13.0 + :target: https://runbot.odoo-community.org/runbot/200/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -40,6 +40,7 @@ To require legal terms acceptance in a survey, follow these steps: #. Go to to *Surveys* and select the survey you want to edit. #. Go to the *Options* tab and check the *Requier legal terms acceptance* checkbox. +#. Configure your desired legal terms link and text. The users of the survey will be required to accept the legal terms before they can submit their answers to the questions. @@ -50,7 +51,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -90,6 +91,6 @@ Current `maintainer `__: |maintainer-chienandalu| -This module is part of the `OCA/survey `_ project on GitHub. +This module is part of the `OCA/survey `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/survey_legal/__manifest__.py b/survey_legal/__manifest__.py index 2c25589c..6b4d67eb 100644 --- a/survey_legal/__manifest__.py +++ b/survey_legal/__manifest__.py @@ -3,17 +3,18 @@ { "name": "Survey legal terms", "summary": "Require legal terms before survey submit", - "version": "13.0.1.0.0", + "version": "15.0.1.0.0", "development_status": "Beta", "category": "Marketing/Survey", "website": "https://github.com/OCA/survey", "author": "Tecnativa, Odoo Community Association (OCA)", "maintainers": ["chienandalu"], "license": "AGPL-3", - "depends": ["survey", "website_legal_page"], + "depends": ["survey"], "data": [ "views/survey_views.xml", "views/survey_templates.xml", "views/survey_user_input_views.xml", ], + "assets": {"survey.survey_assets": ["survey_legal/static/src/js/*"]}, } diff --git a/survey_legal/controllers/main.py b/survey_legal/controllers/main.py index cc289bf4..593aae96 100644 --- a/survey_legal/controllers/main.py +++ b/survey_legal/controllers/main.py @@ -13,7 +13,7 @@ def survey_submit(self, survey_token, answer_token, **post): access_data = self._get_access_data( survey_token, answer_token, ensure_token=True ) - if access_data["validity_code"] != "answer_done": + if access_data["validity_code"] is not True: return res answer_sudo = access_data["answer_sudo"] if not answer_sudo.survey_id.legal_terms: diff --git a/survey_legal/i18n/survey_legal.pot b/survey_legal/i18n/survey_legal.pot index 50dd647e..6e68851a 100644 --- a/survey_legal/i18n/survey_legal.pot +++ b/survey_legal/i18n/survey_legal.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -13,6 +13,16 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: survey_legal +#: model:ir.model.fields,field_description:survey_legal.field_survey_survey__legal_terms_link +msgid "Legal Terms Link" +msgstr "" + +#. module: survey_legal +#: model:ir.model.fields,field_description:survey_legal.field_survey_survey__legal_terms_text +msgid "Legal Terms Text" +msgstr "" + #. module: survey_legal #: model:ir.model.fields,help:survey_legal.field_survey_user_input__user_metadata msgid "" @@ -45,3 +55,10 @@ msgstr "" #: model:ir.model.fields,field_description:survey_legal.field_survey_user_input__user_metadata msgid "User Metadata" msgstr "" + +#. module: survey_legal +#. openerp-web +#: code:addons/survey_legal/static/src/js/survey_form.esm.js:0 +#, python-format +msgid "You must accept the legal terms" +msgstr "" diff --git a/survey_legal/models/survey.py b/survey_legal/models/survey.py index 9db64c0a..69dc2f62 100644 --- a/survey_legal/models/survey.py +++ b/survey_legal/models/survey.py @@ -11,3 +11,7 @@ class SurveySurvey(models.Model): help="The users will be prompted to require the acceptance of the legal terms " "to be able to submit their answers", ) + legal_terms_link = fields.Char(default="/terms") + legal_terms_text = fields.Text( + default="I accept the legal terms, the privacy policy and conditions." + ) diff --git a/survey_legal/readme/CONFIGURE.rst b/survey_legal/readme/CONFIGURE.rst index 2bfb4a9e..fe920bf0 100644 --- a/survey_legal/readme/CONFIGURE.rst +++ b/survey_legal/readme/CONFIGURE.rst @@ -2,6 +2,7 @@ To require legal terms acceptance in a survey, follow these steps: #. Go to to *Surveys* and select the survey you want to edit. #. Go to the *Options* tab and check the *Requier legal terms acceptance* checkbox. +#. Configure your desired legal terms link and text. The users of the survey will be required to accept the legal terms before they can submit their answers to the questions. diff --git a/survey_legal/static/description/index.html b/survey_legal/static/description/index.html index 7697ac74..6e0df3f3 100644 --- a/survey_legal/static/description/index.html +++ b/survey_legal/static/description/index.html @@ -367,7 +367,7 @@

Survey legal terms

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/survey Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/survey Translate me on Weblate Try me on Runbot

This module allows you to include a legal terms acceptance checkbox in your surveys. You have the ability to customize this feature for each individual survey.

Table of contents

@@ -389,6 +389,7 @@

Configuration

  1. Go to to Surveys and select the survey you want to edit.
  2. Go to the Options tab and check the Requier legal terms acceptance checkbox.
  3. +
  4. Configure your desired legal terms link and text.

The users of the survey will be required to accept the legal terms before they can submit their answers to the questions.

@@ -398,7 +399,7 @@

Bug Tracker

Bugs are tracked on GitHub 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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -427,7 +428,7 @@

Maintainers

promote its widespread use.

Current maintainer:

chienandalu

-

This module is part of the OCA/survey project on GitHub.

+

This module is part of the OCA/survey project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/survey_legal/static/src/js/survey_form.esm.js b/survey_legal/static/src/js/survey_form.esm.js new file mode 100644 index 00000000..6369ca73 --- /dev/null +++ b/survey_legal/static/src/js/survey_form.esm.js @@ -0,0 +1,31 @@ +/** @odoo-module **/ +/* Copyright 2022 Tecnativa - David Vidal + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ +import SurveyFormWidget from "survey.form"; +import {_t} from "web.core"; + +SurveyFormWidget.include({ + /** + * Validate legal terms acceptance if present + * + * @override + * @param {JQuery} [$form] the survey form + * @returns {Boolean} + */ + _validateForm: function ($form) { + const [$legalTermsInput] = $form.find("#accepted_legal_terms"); + const res = this._super(...arguments); + // The original method returns false when there are errors. We can break here + if (!res || !$legalTermsInput) { + return res; + } + if (!$legalTermsInput.checked) { + this._showErrors({ + accepted_legal_terms_wrapper: _t("You must accept the legal terms"), + }); + return false; + } + return res; + }, +}); diff --git a/survey_legal/views/survey_templates.xml b/survey_legal/views/survey_templates.xml index 8dc063e5..fe7bf0df 100644 --- a/survey_legal/views/survey_templates.xml +++ b/survey_legal/views/survey_templates.xml @@ -1,39 +1,56 @@ -