[IMP] project: use project sharings in portal route
Before this commit, when the portal user can access to project sharing
and click on the shared link of the project. He is redirected to the
`/project_sharing/<int:project_id>` route. Since only the portal user
can access and no public users, we could directly redirect to the portal
route and display project sharing views.
This commit removes the `/project_sharing/<int:project_id>` route.
The main route will always be the `/my/project/<int:project_id>` and
we check if the user can access project before rendering.
If the user can access to the project via the shared link:
1. If he is a public user then we render the classic portal view.
2. If he is a portal user then
- we check if he is an access to project sharing, if yes then we
render project sharing views otherwise we display the classic
portal views.
task-2379518
closes #73341
This commit is contained in:
@@ -3,18 +3,18 @@
|
||||
|
||||
from collections import OrderedDict
|
||||
from operator import itemgetter
|
||||
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import conf, http, _
|
||||
from odoo.exceptions import AccessError, MissingError
|
||||
from odoo.http import request
|
||||
from odoo.addons.web.controllers.main import HomeStaticTemplateHelpers
|
||||
from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager
|
||||
from odoo.tools import consteq, groupby as groupbyelem
|
||||
from odoo.tools import groupby as groupbyelem
|
||||
|
||||
from odoo.osv.expression import OR
|
||||
|
||||
from odoo.addons.web.controllers.main import HomeStaticTemplateHelpers
|
||||
|
||||
|
||||
class ProjectCustomerPortal(CustomerPortal):
|
||||
|
||||
@@ -86,22 +86,12 @@ class ProjectCustomerPortal(CustomerPortal):
|
||||
project_sudo = self._document_check_access('project.project', project_id, access_token)
|
||||
except (AccessError, MissingError):
|
||||
return request.redirect('/my')
|
||||
if project_sudo.privacy_visibility == 'portal' and not request.env.user._is_public():
|
||||
if project_sudo.with_user(request.env.user)._check_project_sharing_access():
|
||||
return request.render("project.project_sharing_portal", {'project_id': project_id})
|
||||
values = self._project_get_page_view_values(project_sudo, access_token, **kw)
|
||||
return request.render("project.portal_my_project", values)
|
||||
|
||||
@http.route("/project_sharing/<int:project_id>", type='http', auth="user", methods=['GET'])
|
||||
def get_project_sharing(self, project_id, model='project.project', access_token=None):
|
||||
if not model or model != 'project.project' or not access_token:
|
||||
return request.not_found()
|
||||
project = request.env[model].sudo().browse(project_id)
|
||||
project_validation = project and project.exists() and consteq(project.access_token, access_token) and project.privacy_visibility == 'portal'
|
||||
if not project_validation:
|
||||
return request.not_found()
|
||||
return request.render('project.project_sharing', {'project_id': project.id})
|
||||
|
||||
@http.route("/embed/project/<int:project_id>", type="http", auth="user", methods=['GET'])
|
||||
@http.route("/my/project/<int:project_id>/project_sharing", type="http", auth="user", methods=['GET'])
|
||||
def render_project_backend_view(self, project_id):
|
||||
project = request.env['project.project'].sudo().browse(project_id)
|
||||
if not project.exists() or not project.with_user(request.env.user)._check_project_sharing_access():
|
||||
@@ -123,7 +113,7 @@ class ProjectCustomerPortal(CustomerPortal):
|
||||
cache_hashes=cache_hashes,
|
||||
action_name='project.project_sharing_project_task_action',
|
||||
project_id=project.id,
|
||||
can_edit=project.user_can_edit,
|
||||
can_edit=project._check_project_sharing_access('edit'),
|
||||
user_companies={
|
||||
'current_company': project_company.id,
|
||||
'allowed_companies': {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</template>
|
||||
|
||||
<template id="project_sharing" name="Project Sharing View">
|
||||
<iframe width="100%" height="100%" frameborder="0" t-attf-src="/embed/project/{{ project_id }}"/>
|
||||
<iframe width="100%" height="100%" frameborder="0" t-attf-src="/my/project/{{ project_id }}/project_sharing"/>
|
||||
</template>
|
||||
|
||||
<template id="project_sharing_embed" name="Project Sharing View Embed">
|
||||
|
||||
Reference in New Issue
Block a user