[IMP] document_page_portal: black, isort, prettier

This commit is contained in:
Mikheil Barnaveli 2024-05-29 12:00:04 +04:00
parent cd038b3dca
commit 146792eabf
5 changed files with 134 additions and 27 deletions

View File

@ -110,7 +110,7 @@ class CustomerPortal(CustomerPortal):
"date": date_begin, "date": date_begin,
"document_pages": document_pages, "document_pages": document_pages,
"page_name": "document_page", "page_name": "document_page",
"default_url": "/my/knowledge/s", "default_url": "/my/knowledge/documents",
"pager": pager, "pager": pager,
"archive_groups": archive_groups, "archive_groups": archive_groups,
"searchbar_sortings": searchbar_sortings, "searchbar_sortings": searchbar_sortings,
@ -127,7 +127,7 @@ class CustomerPortal(CustomerPortal):
@http.route( @http.route(
[ [
"/knowledge/document/<int:document_page_id>", "/knowledge/document/<int:document_page_id>",
"/knowledge/document/<int:document_page_id>/<token>", "/knowledge/document/<int:document_page_id>/<access_token>",
"/my/knowledge/document/<int:document_page_id>", "/my/knowledge/document/<int:document_page_id>",
], ],
type="http", type="http",

View File

@ -5,7 +5,6 @@ from odoo import fields, models
class DocumentPage(models.Model): class DocumentPage(models.Model):
_inherit = "document.page" _inherit = "document.page"
is_public = fields.Boolean( is_public = fields.Boolean(

View File

@ -1,23 +1,135 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1"> <odoo noupdate="1">
<record model="ir.rule" id="knowledge_user_document_page_rule"> <template
<field name="name">Documents: knowledge user: see all</field> id="portal_my_home_menu_Knowledge"
<field name="model_id" ref="document_page.model_document_page" /> name="Portal layout : Knowledge document_pages menu entries"
<field name="domain_force">[(1, '=', 1)]</field> inherit_id="portal.portal_breadcrumbs"
<field name="groups" eval="[(4,ref('knowledge.group_document_user'))]" /> priority="50"
</record> >
<record model="ir.rule" id="knowledge_portal_document_page_rule"> <xpath expr="//ol[hasclass('o_portal_submenu')]" position="inside">
<field name="name">Documents: portal users: portal or following</field> <li
<field name="model_id" ref="document_page.model_document_page" /> t-if="page_name == 'document_page' or document_page"
<field name="domain_force"> t-attf-class="breadcrumb-item #{'active ' if not document_page else ''}"
[ >
'|', '|', ('type', '!=', 'content'), ('is_public', '=', True), <a
('message_partner_ids', 'child_of', [user.partner_id.commercial_partner_id.id]) t-if="document_page"
] t-attf-href="/my/knowledge/documents?{{ keep_query() }}"
</field> >Knowledge Documents</a>
<field <t t-else="">Knowledge Documents</t>
name="groups" </li>
eval="[(4, ref('base.group_portal')),(4, ref('base.group_user'))]" <li t-if="document_page" class="breadcrumb-item active">
#<span t-field="document_page.id" />
</li>
</xpath>
</template>
<template
id="portal_my_home_Knowledge_document_page"
name="Portal My Home : Knowledge Documents"
inherit_id="portal.portal_my_home"
priority="50"
>
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
<t t-if="document_page_count" t-call="portal.portal_docs_entry">
<t t-set="title">Knowledge Documents</t>
<t t-set="url" t-value="'/my/knowledge/documents'" />
<t t-set="count" t-value="document_page_count" />
</t>
</xpath>
</template>
<template id="portal_my_knowledge_document_pages" name="Knowledge Document">
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True" />
<t t-call="portal.portal_searchbar">
<t t-set="title">Knowledge Documents</t>
</t>
<div t-if="not document_pages" class="alert alert-info">
There are currently no Knowledge Document for your account.
</div>
<t t-if="document_pages" t-call="portal.portal_table">
<thead>
<tr>
<th class="text-right">Ref</th>
<th class="w-100">Name</th>
<th />
<th class="text-center">Category</th>
</tr>
</thead>
<t t-foreach="document_pages" t-as="document_page">
<tr>
<td class="text-right"><a
t-attf-href="/knowledge/document/#{document_page.id}"
>
<small>#</small><t t-esc="document_page.id" /></a></td>
<td>
<a t-attf-href="/knowledge/document/#{document_page.id}">
<span t-field="document_page.name" /></a>
</td>
<td />
<td class="text-center">
<span
class="badge badge-pill badge-info"
t-field="document_page.parent_id.name"
/> />
</record> </td>
</tr>
</t>
</t>
</t>
</template>
<template id="document_pages_followup" name="Knowledge Documents Followup">
<t t-call="portal.portal_layout">
<t t-set="wrapwrap_classes" t-value="'o_portal_bg_dark'" />
<t t-set="o_portal_fullwidth_alert" groups="knowledge.group_document_user">
<t t-call="portal.portal_back_in_edit_mode">
<t
t-set="backend_url"
t-value="'/web#return_label=Website&amp;model=document.page&amp;id=%s&amp;view_type=form' % (document_page.id)"
/>
</t>
</t>
<t t-call="portal.portal_record_layout">
<t t-set="card_header">
<div class="row no-gutters">
<div class="col-md">
<h5 class="mb-1 mb-md-0">
<span t-field="document_page.name" />
<small class="text-muted"> (#<span
t-field="document_page.id"
/>)</small>
</h5>
</div>
<div class="col-md text-md-right">
<small class="text-right">Category:</small>
<span
t-field="document_page.parent_id.name"
class="badge badge-pill badge-info"
title="Current Category of this document"
/>
</div>
</div>
</t>
<t t-set="card_body">
<div class="row mb-4">
<h1 class="col-lg-12">
<span t-field="document_page.name" />
</h1>
<div
t-if="document_page.content"
class="col-lg-12"
t-raw="document_page.content"
/>
<div t-else="" class="col-lg-10">
<em class="text-muted"><small>No content</small></em>
</div>
</div>
</t>
</t>
</t>
</template>
</odoo> </odoo>

View File

@ -15,7 +15,6 @@ class TestPortalDocumentPage(odoo.tests.HttpCase):
"is_public": True, "is_public": True,
} }
) )
self.start_tour("/", "document_page_portal_tour", login="portal") self.start_tour("/", "document_page_portal_tour", login="portal")
def test_02_document_page_portal_tour(self): def test_02_document_page_portal_tour(self):

View File

@ -2,7 +2,6 @@
<!-- Copyright 2020 - TODAY, Marcel Savegnago - Escodoo <!-- Copyright 2020 - TODAY, Marcel Savegnago - Escodoo
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo> <odoo>
<record model="ir.ui.view" id="document_page_form_view"> <record model="ir.ui.view" id="document_page_form_view">
<field name="name">document.page.form (in document_page_portal)</field> <field name="name">document.page.form (in document_page_portal)</field>
<field name="model">document.page</field> <field name="model">document.page</field>
@ -13,6 +12,4 @@
</field> </field>
</field> </field>
</record> </record>
</odoo> </odoo>