diff --git a/document_page_portal/README.rst b/document_page_portal/README.rst new file mode 100644 index 00000000000..908f3165d0b --- /dev/null +++ b/document_page_portal/README.rst @@ -0,0 +1,103 @@ +==================== +Document Page Portal +==================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:83751d0dd805c839f85221e62ddf9569bc2555dda895792cc05bcc5cbc4ab377 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fknowledge-lightgray.png?logo=github + :target: https://github.com/OCA/knowledge/tree/15.0/document_page_portal + :alt: OCA/knowledge +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/knowledge-15-0/knowledge-15-0-document_page_portal + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows documents to be made available on the portal. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +No configuration required. + +Usage +===== + +* Add a user as a follower of the document or configure the document as public so that it is visible through the user portal. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* `Escodoo `_: + + * Marcel Savegnago + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* Escodoo + +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-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px + :target: https://github.com/marcelsavegnago + :alt: marcelsavegnago + +Current `maintainer `__: + +|maintainer-marcelsavegnago| + +This module is part of the `OCA/knowledge `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/document_page_portal/__init__.py b/document_page_portal/__init__.py new file mode 100644 index 00000000000..91c5580fed3 --- /dev/null +++ b/document_page_portal/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/document_page_portal/__manifest__.py b/document_page_portal/__manifest__.py new file mode 100644 index 00000000000..e4bc157cfb0 --- /dev/null +++ b/document_page_portal/__manifest__.py @@ -0,0 +1,28 @@ +# Copyright (C) 2020 - TODAY, Marcel Savegnago - Escodoo). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +{ + "name": "Document Page Portal", + "summary": """ + This module enables document page portal""", + "version": "15.0.1.0.0", + "category": "Knowledge Management", + "author": "Escodoo, Odoo Community Association (OCA)", + "maintainers": ["marcelsavegnago"], + "images": ["static/description/banner.png"], + "website": "https://github.com/OCA/knowledge", + "license": "AGPL-3", + "depends": ["base", "portal", "document_page", "web_tour"], + "data": [ + "views/document_page.xml", + "security/document_page_portal_security.xml", + "security/ir.model.access.csv", + "views/document_page_portal_templates.xml", + ], + "assets": { + "web.assets_tests": [ + "document_page_portal/static/src/js/document_page_portal_tour.js" + ], + }, +} diff --git a/document_page_portal/controllers/__init__.py b/document_page_portal/controllers/__init__.py new file mode 100644 index 00000000000..8c3feb6f562 --- /dev/null +++ b/document_page_portal/controllers/__init__.py @@ -0,0 +1 @@ +from . import portal diff --git a/document_page_portal/controllers/portal.py b/document_page_portal/controllers/portal.py new file mode 100644 index 00000000000..9f77aba6483 --- /dev/null +++ b/document_page_portal/controllers/portal.py @@ -0,0 +1,37 @@ +from odoo.tests.common import HttpCase + + +class TestPortalController(HttpCase): + def setUp(self): + super(TestPortalController, self).setUp() + self.document_page_model = self.env["document.page"] + self.portal_controller = self.env["ir.http"].get( + "portal.my.knowledge.document.pages" + ) + + def test_prepare_portal_layout_values(self): + self.document_page_model.create({"name": "Test Page 1", "type": "content"}) + response = self.portal_controller()._prepare_portal_layout_values() + self.assertIn("document_page_count", response) + self.assertEqual(response["document_page_count"], 1) + + def test_get_archive_groups(self): + self.document_page_model.create({"name": "Test Page 1", "type": "content"}) + domain = [("type", "=", "content")] + groups = self.portal_controller()._get_archive_groups("document.page", domain) + self.assertTrue(groups) + self.assertEqual(groups[0]["name"], "Test Page 1") + + def test_portal_my_knowledge_document_pages(self): + self.document_page_model.create({"name": "Test Page 1", "type": "content"}) + response = self.url_open("/my/knowledge/documents/") + self.assertEqual(response.status_code, 200) + self.assertIn(b"Test Page 1", response.data) + + def test_document_pages_followup(self): + document_page = self.document_page_model.create( + {"name": "Test Page 1", "type": "content"} + ) + response = self.url_open(f"/knowledge/document/{document_page.id}") + self.assertEqual(response.status_code, 200) + self.assertIn(b"Test Page 1", response.data) diff --git a/document_page_portal/i18n/document_page_portal.pot b/document_page_portal/i18n/document_page_portal.pot new file mode 100644 index 00000000000..14c9dc58927 --- /dev/null +++ b/document_page_portal/i18n/document_page_portal.pot @@ -0,0 +1,94 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_portal +# +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: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.document_pages_followup +msgid "No content" +msgstr "" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.document_pages_followup +msgid "Category:" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +#, python-format +msgid "Category" +msgstr "" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.document_pages_followup +msgid "Current Category of this document" +msgstr "" + +#. module: document_page_portal +#: model:ir.model,name:document_page_portal.model_document_page +msgid "Document Page" +msgstr "" + +#. module: document_page_portal +#: model:ir.model.fields,help:document_page_portal.field_document_page__is_public +msgid "" +"If true it allows any user of the portal to have access to this document." +msgstr "" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_home_Knowledge_document_page +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_home_menu_Knowledge +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +msgid "Knowledge Documents" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +#, python-format +msgid "Name" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#, python-format +msgid "Newest" +msgstr "" + +#. module: document_page_portal +#: model:ir.model.fields,field_description:document_page_portal.field_document_page__is_public +msgid "Public Page" +msgstr "" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +msgid "Ref" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#, python-format +msgid "Search (in Content)" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#, python-format +msgid "Search in All" +msgstr "" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +msgid "There are currently no Knowledge Document for your account." +msgstr "" diff --git a/document_page_portal/i18n/it.po b/document_page_portal/i18n/it.po new file mode 100644 index 00000000000..8ba47f7881c --- /dev/null +++ b/document_page_portal/i18n/it.po @@ -0,0 +1,98 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_portal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-23 10:10+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.document_pages_followup +msgid "No content" +msgstr "Nessun contenuto" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.document_pages_followup +msgid "Category:" +msgstr "Categoria:" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +#, python-format +msgid "Category" +msgstr "Categoria" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.document_pages_followup +msgid "Current Category of this document" +msgstr "Categoria attuale di questo documento" + +#. module: document_page_portal +#: model:ir.model,name:document_page_portal.model_document_page +msgid "Document Page" +msgstr "Pagina documento" + +#. module: document_page_portal +#: model:ir.model.fields,help:document_page_portal.field_document_page__is_public +msgid "" +"If true it allows any user of the portal to have access to this document." +msgstr "" +"Se vera consente ad ogni utente del portale di accedere a questo documento." + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_home_Knowledge_document_page +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_home_menu_Knowledge +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +msgid "Knowledge Documents" +msgstr "Documenti knowledge" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +#, python-format +msgid "Name" +msgstr "Nome" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#, python-format +msgid "Newest" +msgstr "Il più recente" + +#. module: document_page_portal +#: model:ir.model.fields,field_description:document_page_portal.field_document_page__is_public +msgid "Public Page" +msgstr "Pagina pubblica" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +msgid "Ref" +msgstr "Rif." + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#, python-format +msgid "Search (in Content)" +msgstr "Cerca (nel contenuto)" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#, python-format +msgid "Search in All" +msgstr "Cercare fra tutti" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +msgid "There are currently no Knowledge Document for your account." +msgstr "Al momento non ci sono documenti knowledge per il tuo account." diff --git a/document_page_portal/i18n/pt_BR.po b/document_page_portal/i18n/pt_BR.po new file mode 100644 index 00000000000..f88df8b7716 --- /dev/null +++ b/document_page_portal/i18n/pt_BR.po @@ -0,0 +1,121 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_portal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-11-27 14:08+0000\n" +"PO-Revision-Date: 2019-11-27 11:11-0300\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Poedit 2.2.4\n" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.document_pages_followup +msgid "No content" +msgstr "" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.document_pages_followup +msgid "Category:" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +#, python-format +msgid "Category" +msgstr "Categoria" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.document_pages_followup +msgid "Current Category of this document" +msgstr "" + +#. module: document_page_portal +#: model:ir.model,name:document_page_portal.model_document_page +msgid "Document Page" +msgstr "" + +#. module: document_page_portal +#: model:ir.model.fields,help:document_page_portal.field_document_page__is_public +msgid "" +"If true it allows any user of the portal to have access to this document." +msgstr "" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_home_Knowledge_document_page +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_home_menu_Knowledge +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +msgid "Knowledge Documents" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +#, python-format +msgid "Name" +msgstr "Nome" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#, python-format +msgid "Newest" +msgstr "Mais Recentes" + +#. module: document_page_portal +#: model:ir.model.fields,field_description:document_page_portal.field_document_page__is_public +msgid "Public Page" +msgstr "" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +msgid "Ref" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#, python-format +msgid "Search (in Content)" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:0 +#, python-format +msgid "Search in All" +msgstr "" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_knowledge_document_pages +msgid "There are currently no Knowledge Document for your account." +msgstr "" + +#~ msgid "" +#~ "
\n" +#~ " Category:" +#~ msgstr "" +#~ "
\n" +#~ " Categoria:" + +#~ msgid "" +#~ "
\n" +#~ " Date:" +#~ msgstr "" +#~ "
\n" +#~ " Data:" + +#~ msgid "All" +#~ msgstr "Todos" + +#~ msgid "Documents" +#~ msgstr "Documentos" + +#~ msgid "There are no documents in your account." +#~ msgstr "Não há documentos em sua conta." diff --git a/document_page_portal/models/__init__.py b/document_page_portal/models/__init__.py new file mode 100644 index 00000000000..427be24e72a --- /dev/null +++ b/document_page_portal/models/__init__.py @@ -0,0 +1 @@ +from . import document_page diff --git a/document_page_portal/models/document_page.py b/document_page_portal/models/document_page.py new file mode 100644 index 00000000000..72bf4082fc9 --- /dev/null +++ b/document_page_portal/models/document_page.py @@ -0,0 +1,15 @@ +# Copyright 2020 - TODAY, Marcel Savegnago - Escodoo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class DocumentPage(models.Model): + + _inherit = "document.page" + + is_public = fields.Boolean( + "Public Page", + help="If true it allows any user of the portal to have " + "access to this document.", + ) diff --git a/document_page_portal/readme/CONFIGURE.rst b/document_page_portal/readme/CONFIGURE.rst new file mode 100644 index 00000000000..e7dc235973a --- /dev/null +++ b/document_page_portal/readme/CONFIGURE.rst @@ -0,0 +1 @@ +No configuration required. diff --git a/document_page_portal/readme/CONTRIBUTORS.rst b/document_page_portal/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..ae453a60bdb --- /dev/null +++ b/document_page_portal/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Escodoo `_: + + * Marcel Savegnago diff --git a/document_page_portal/readme/CREDITS.rst b/document_page_portal/readme/CREDITS.rst new file mode 100644 index 00000000000..fcb24d04573 --- /dev/null +++ b/document_page_portal/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Escodoo diff --git a/document_page_portal/readme/DESCRIPTION.rst b/document_page_portal/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..d5ab614d4c2 --- /dev/null +++ b/document_page_portal/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows documents to be made available on the portal. diff --git a/document_page_portal/readme/USAGE.rst b/document_page_portal/readme/USAGE.rst new file mode 100644 index 00000000000..e15b4b2fb81 --- /dev/null +++ b/document_page_portal/readme/USAGE.rst @@ -0,0 +1 @@ +* Add a user as a follower of the document or configure the document as public so that it is visible through the user portal. diff --git a/document_page_portal/security/document_page_portal_security.xml b/document_page_portal/security/document_page_portal_security.xml new file mode 100644 index 00000000000..4ab86ef4389 --- /dev/null +++ b/document_page_portal/security/document_page_portal_security.xml @@ -0,0 +1,23 @@ + + + + Documents: knowledge user: see all + + [(1, '=', 1)] + + + + Documents: portal users: portal or following + + + [ + '|', '|', ('type', '!=', 'content'), ('is_public', '=', True), + ('message_partner_ids', 'child_of', [user.partner_id.commercial_partner_id.id]) + ] + + + + diff --git a/document_page_portal/security/ir.model.access.csv b/document_page_portal/security/ir.model.access.csv new file mode 100644 index 00000000000..660b8280169 --- /dev/null +++ b/document_page_portal/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +document_page_portal,document.page portal,document_page.model_document_page,base.group_portal,1,0,0,0 +document_page_portal_user,document.page portal user,document_page.model_document_page,base.group_user,1,0,0,0 diff --git a/document_page_portal/static/description/banner.png b/document_page_portal/static/description/banner.png new file mode 100644 index 00000000000..da4f6de2a24 Binary files /dev/null and b/document_page_portal/static/description/banner.png differ diff --git a/document_page_portal/static/description/icon.png b/document_page_portal/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/document_page_portal/static/description/icon.png differ diff --git a/document_page_portal/static/description/index.html b/document_page_portal/static/description/index.html new file mode 100644 index 00000000000..2e1c113dda3 --- /dev/null +++ b/document_page_portal/static/description/index.html @@ -0,0 +1,448 @@ + + + + + +Document Page Portal + + + +
+

Document Page Portal

+ + +

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runboat

+

This module allows documents to be made available on the portal.

+

Table of contents

+ +
+

Configuration

+

No configuration required.

+
+
+

Usage

+
    +
  • Add a user as a follower of the document or configure the document as public so that it is visible through the user portal.
  • +
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Escodoo
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The development of this module has been financially supported by:

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

marcelsavegnago

+

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

+

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

+
+
+
+ + diff --git a/document_page_portal/static/src/js/document_page_portal_tour.js b/document_page_portal/static/src/js/document_page_portal_tour.js new file mode 100644 index 00000000000..4ce56994467 --- /dev/null +++ b/document_page_portal/static/src/js/document_page_portal_tour.js @@ -0,0 +1,46 @@ +odoo.define("document_page_portal.tour", function (require) { + "use strict"; + + var webTour = require("web_tour.tour"); + + webTour.register( + "document_page_portal_tour", + { + test: true, + url: "/my", + }, + [ + { + content: "Check document_page_portal is loaded", + trigger: + 'a[href*="/my/knowledge/documents"]:contains("Knowledge Documents"):first', + }, + { + content: "Check public document_page is loaded", + trigger: + 'a[href*="/knowledge/document/"]:contains("Test Public Page 1"):first', + }, + ] + ); + + webTour.register( + "document_page_portal_search_tour", + { + test: true, + url: "/my/knowledge/documents", + }, + [ + { + content: "Search", + trigger: "input[name='search']", + run: "text Test", + }, + { + content: "Click Search.", + extra_trigger: "#wrap:not(:has(input[name=search]:propValue('')))", + trigger: + "form.o_portal_search_panel .input-group-append .btn[type='submit']", + }, + ] + ); +}); diff --git a/document_page_portal/tests/__init__.py b/document_page_portal/tests/__init__.py new file mode 100644 index 00000000000..d868a7a19fa --- /dev/null +++ b/document_page_portal/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_document_page_portal +from . import test_document_controller diff --git a/document_page_portal/tests/test_document_controller.py b/document_page_portal/tests/test_document_controller.py new file mode 100644 index 00000000000..c86b83025fd --- /dev/null +++ b/document_page_portal/tests/test_document_controller.py @@ -0,0 +1,62 @@ +from unittest.mock import patch + +from odoo.tests import common +from odoo.tests.common import tagged + +from odoo.addons.document_page_portal.controllers.portal import CustomerPortal + + +@tagged("post_install", "-at_install") +class TestCustomerPortal(common.HttpCase): + def setUp(self): + super(TestCustomerPortal, self).setUp() + self.customer_portal = CustomerPortal() + self.document_page = self.env["document.page"].create( + { + "name": "Test Document Page", + "content": "Test Content", + "type": "content", + } + ) + + def _mock_request(self): + mock_request = type("MockRequest", (), {})() + mock_request.env = self.env + mock_request.session = {} + return mock_request + + @patch("odoo.http.request") + def test_get_archive_groups(self, mock_request): + mock_request.env = self.env + groups = self.customer_portal._get_archive_groups("document.page") + self.assertTrue(groups) + + @patch("odoo.http.request") + def test_document_page_get_page_view_values(self, mock_request): + mock_request.env = self.env + mock_request.session = {} + values = self.customer_portal._document_page_get_page_view_values( + self.document_page, "test_token" + ) + self.assertEqual(values["page_name"], "document_page") + self.assertEqual(values["document_page"], self.document_page) + + def test_portal_my_knowledge_document_pages(self): + self.authenticate("admin", "admin") + response = self.url_open("/my/knowledge/documents/") + self.assertEqual(response.status_code, 200) + + # Test with search parameters + response = self.url_open( + "/my/knowledge/documents/?search=Test&search_in=content" + ) + self.assertEqual(response.status_code, 200) + + def test_document_pages_followup(self): + self.authenticate("admin", "admin") + response = self.url_open(f"/knowledge/document/{self.document_page.id}") + self.assertEqual(response.status_code, 200) + + # Test with invalid document_page_id + response = self.url_open("/knowledge/document/9999") + self.assertEqual(response.status_code, 303) # Should redirect to /my diff --git a/document_page_portal/tests/test_document_page_portal.py b/document_page_portal/tests/test_document_page_portal.py new file mode 100644 index 00000000000..cb2e19d5a86 --- /dev/null +++ b/document_page_portal/tests/test_document_page_portal.py @@ -0,0 +1,36 @@ +# Copyright 2020 - TODAY, Marcel Savegnago - Escodoo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl + +import odoo.tests + + +@odoo.tests.tagged("post_install", "-at_install") +class TestPortalDocumentPage(odoo.tests.HttpCase): + def test_01_document_page_portal_tour(self): + # Create a public document + self.env["document.page"].create( + { + "name": "Test Public Page 1", + "content": "Test content", + "is_public": True, + } + ) + + self.browser_js( + "/", + "odoo.__DEBUG__.services['web_tour.tour']" + ".run('document_page_portal_tour')", + "odoo.__DEBUG__.services['web_tour.tour']" + ".tours.document_page_portal_tour.ready", + login="portal", + ) + + def test_02_document_page_portal_tour(self): + self.browser_js( + "/", + "odoo.__DEBUG__.services['web_tour.tour']" + ".run('document_page_portal_search_tour')", + "odoo.__DEBUG__.services['web_tour.tour']" + ".tours.document_page_portal_search_tour.ready", + login="portal", + ) diff --git a/document_page_portal/views/document_page.xml b/document_page_portal/views/document_page.xml new file mode 100644 index 00000000000..5ec1c49e99d --- /dev/null +++ b/document_page_portal/views/document_page.xml @@ -0,0 +1,18 @@ + + + + + + document.page.form (in document_page_portal) + document.page + + + + + + + + + + diff --git a/document_page_portal/views/document_page_portal_templates.xml b/document_page_portal/views/document_page_portal_templates.xml new file mode 100644 index 00000000000..ae01ca8e7a4 --- /dev/null +++ b/document_page_portal/views/document_page_portal_templates.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000000..9cd1629223b --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +# generated from manifests external_dependencies diff --git a/setup/document_page_portal/odoo/addons/document_page_portal b/setup/document_page_portal/odoo/addons/document_page_portal new file mode 120000 index 00000000000..f596dff3591 --- /dev/null +++ b/setup/document_page_portal/odoo/addons/document_page_portal @@ -0,0 +1 @@ +../../../../document_page_portal \ No newline at end of file diff --git a/setup/document_page_portal/setup.py b/setup/document_page_portal/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/document_page_portal/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000000..66bc2cbae3f --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo_test_helper