diff --git a/document_page_portal/README.rst b/document_page_portal/README.rst new file mode 100644 index 00000000..d707498d --- /dev/null +++ b/document_page_portal/README.rst @@ -0,0 +1,105 @@ +==================== +Document Page Portal +==================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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/12.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-12-0/knowledge-12-0-document_page_portal + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/118/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows documents to be made available on the portal. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**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 smashing 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 00000000..91c5580f --- /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 00000000..80ba91de --- /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': '12.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' + ], + 'data': [ + 'views/assets.xml', + 'views/document_page.xml', + 'security/document_page_portal_security.xml', + 'security/ir.model.access.csv', + 'views/document_page_portal_templates.xml', + ], +} diff --git a/document_page_portal/controllers/__init__.py b/document_page_portal/controllers/__init__.py new file mode 100644 index 00000000..8c3feb6f --- /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 00000000..30d8c8e2 --- /dev/null +++ b/document_page_portal/controllers/portal.py @@ -0,0 +1,118 @@ +# Copyright (C) 2020 - TODAY, Marcel Savegnago - Escodoo). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import http +from odoo.exceptions import AccessError, MissingError +from odoo.http import request +from odoo.tools.translate import _ +from odoo.addons.portal.controllers.portal import pager as portal_pager, CustomerPortal +from odoo.osv.expression import OR + + +class CustomerPortal(CustomerPortal): + + def _prepare_portal_layout_values(self): + values = super(CustomerPortal, self)._prepare_portal_layout_values() + values['document_page_count'] = request.env[ + 'document.page'].search_count([('type', '=', 'content')]) + return values + + def _document_page_get_page_view_values(self, document_page, + access_token, **kwargs): + values = { + 'page_name': 'document_page', + 'document_page': document_page, + } + return self._get_page_view_values( + document_page, access_token, values, + 'my_document_pages_history', False, **kwargs) + + @http.route( + ['/my/knowledge/documents/', '/my/knowledge/documents/page/'], + type='http', auth="user", website=True) + def portal_my_knowledge_document_pages(self, page=1, date_begin=None, + date_end=None, sortby=None, + search=None, search_in='content', **kw): + values = self._prepare_portal_layout_values() + domain = [('type', '=', 'content')] + + searchbar_sortings = { + 'date': {'label': _('Newest'), 'order': 'create_date desc'}, + 'name': {'label': _('Name'), 'order': 'name'}, + 'parent': {'label': _('Category'), 'order': 'parent_id'}, + } + searchbar_inputs = { + 'content': {'input': 'content', 'label': _( + 'Search (in Content)')}, + 'all': {'input': 'all', 'label': _('Search in All')}, + } + + # default sort by value + if not sortby: + sortby = 'date' + order = searchbar_sortings[sortby]['order'] + + # archive groups - Default Group By 'create_date' + archive_groups = self._get_archive_groups('document.page', domain) + if date_begin and date_end: + domain += [ + ('create_date', '>', date_begin), + ('create_date', '<=', date_end), + ] + + # search + if search and search_in: + search_domain = [] + if search_in in ('content', 'all'): + search_domain = OR([search_domain, [ + '|', ('name', 'ilike', search), ('content', 'ilike', search)]]) + domain += search_domain + + # pager + document_pages_count = request.env['document.page'].search_count(domain) + pager = portal_pager( + url="/my/knowledge/documents", + url_args={'date_begin': date_begin, 'date_end': date_end, 'sortby': sortby}, + total=document_pages_count, + page=page, + step=self._items_per_page + ) + + document_pages = request.env['document.page'].search( + domain, order=order, limit=self._items_per_page, offset=pager['offset']) + request.session['my_document_pages_history'] = document_pages.ids[:100] + + values.update({ + 'date': date_begin, + 'document_pages': document_pages, + 'page_name': 'document_page', + 'default_url': '/my/knowledge/s', + 'pager': pager, + 'archive_groups': archive_groups, + 'searchbar_sortings': searchbar_sortings, + 'searchbar_inputs': searchbar_inputs, + 'sortby': sortby, + 'search_in': search_in, + 'search': search, + }) + return request.render( + "document_page_portal.portal_my_knowledge_document_pages", values) + + @http.route([ + "/knowledge/document/", + "/knowledge/document//", + '/my/knowledge/document/' + ], type='http', auth="public", website=True) + def document_pages_followup(self, document_page_id=None, + access_token=None, **kw): + try: + document_page_sudo = self._document_check_access( + 'document.page', document_page_id, access_token) + except (AccessError, MissingError): + return request.redirect('/my') + + values = self._document_page_get_page_view_values( + document_page_sudo, access_token, **kw) + return request.render( + "document_page_portal.document_pages_followup", values) 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 00000000..db207f42 --- /dev/null +++ b/document_page_portal/i18n/document_page_portal.pot @@ -0,0 +1,81 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_portal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-02-15 05:49+0000\n" +"PO-Revision-Date: 2020-02-15 05:49+0000\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:36 +#: 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_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 "Documents" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:35 +#: 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:34 +#, python-format +msgid "Newest" +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:39 +#, python-format +msgid "Search (in Content)" +msgstr "" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:40 +#, 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 Document for your account." +msgstr "" + diff --git a/document_page_portal/i18n/pt_BR.po b/document_page_portal/i18n/pt_BR.po new file mode 100644 index 00000000..a81ca1be --- /dev/null +++ b/document_page_portal/i18n/pt_BR.po @@ -0,0 +1,72 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_portal +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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" +"Language-Team: \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" +"Last-Translator: \n" +"Language: pt_BR\n" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_document_page_page +msgid "" +"
\n" +" Category:" +msgstr "" +"
\n" +" Categoria:" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_document_page_page +msgid "" +"
\n" +" Date:" +msgstr "" +"
\n" +" Data:" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:55 +#, python-format +msgid "All" +msgstr "Todos" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_documents +msgid "Category" +msgstr "Categoria" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_layout +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_documents +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_home +msgid "Documents" +msgstr "Documentos" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:53 +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_documents +#, python-format +msgid "Name" +msgstr "Nome" + +#. module: document_page_portal +#: code:addons/document_page_portal/controllers/portal.py:52 +#, python-format +msgid "Newest" +msgstr "Mais Recentes" + +#. module: document_page_portal +#: model_terms:ir.ui.view,arch_db:document_page_portal.portal_my_documents +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 00000000..427be24e --- /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 00000000..fef21ad4 --- /dev/null +++ b/document_page_portal/models/document_page.py @@ -0,0 +1,14 @@ +# 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 00000000..e7dc2359 --- /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 00000000..ae453a60 --- /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 00000000..fcb24d04 --- /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 00000000..d5ab614d --- /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 00000000..e15b4b2f --- /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 00000000..98ce80f5 --- /dev/null +++ b/document_page_portal/security/document_page_portal_security.xml @@ -0,0 +1,22 @@ + + + + + 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 00000000..2fcb0056 --- /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 \ No newline at end of file diff --git a/document_page_portal/static/description/banner.png b/document_page_portal/static/description/banner.png new file mode 100644 index 00000000..da4f6de2 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 00000000..3a0328b5 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 00000000..cdb7813e --- /dev/null +++ b/document_page_portal/static/description/index.html @@ -0,0 +1,450 @@ + + + + + + +Document Page Portal + + + +
+

Document Page Portal

+ + +

Alpha License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runbot

+

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

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

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 smashing 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 00000000..264df980 --- /dev/null +++ b/document_page_portal/static/src/js/document_page_portal_tour.js @@ -0,0 +1,37 @@ +odoo.define('document_page_portal.tour', function (require) { + 'use strict'; + + var tour = require("web_tour.tour"); + + tour.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', + }, + ]); + + tour.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: '.search-submit', + }, + ]); +}); diff --git a/document_page_portal/tests/__init__.py b/document_page_portal/tests/__init__.py new file mode 100644 index 00000000..7e42ded9 --- /dev/null +++ b/document_page_portal/tests/__init__.py @@ -0,0 +1 @@ +from . import test_document_page_portal 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 00000000..ae65ad76 --- /dev/null +++ b/document_page_portal/tests/test_document_page_portal.py @@ -0,0 +1,33 @@ +# 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 TestUi(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.phantom_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" + ) + + self.phantom_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/assets.xml b/document_page_portal/views/assets.xml new file mode 100644 index 00000000..9b3edfbb --- /dev/null +++ b/document_page_portal/views/assets.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/document_page_portal/views/document_page.xml b/document_page_portal/views/document_page.xml new file mode 100644 index 00000000..27c3e352 --- /dev/null +++ b/document_page_portal/views/document_page.xml @@ -0,0 +1,19 @@ + + + + + + + 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 00000000..995b7bfb --- /dev/null +++ b/document_page_portal/views/document_page_portal_templates.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + +