[IMP] website_rating_project: website published mixin usage
'project.project' should not use 'website.published.mixin', since we don't want to publish a project on the website. All we want is to display the rating of a project, nothing more. So, a flag on project is enought to allow the publication.
This commit is contained in:
@@ -13,7 +13,7 @@ class WebsiteRatingProject(http.Controller):
|
||||
|
||||
@http.route(['/project/rating/'], type='http', auth="public", website=True)
|
||||
def index(self, **kw):
|
||||
projects = request.env['project.project'].sudo().search([('rating_status', '!=', 'no'), ('website_published', '=', True)])
|
||||
projects = request.env['project.project'].sudo().search([('rating_status', '!=', 'no'), ('portal_show_rating', '=', True)])
|
||||
values = {'projects': projects}
|
||||
return request.render('website_rating_project.index', values)
|
||||
|
||||
@@ -23,7 +23,7 @@ class WebsiteRatingProject(http.Controller):
|
||||
project = request.env['project.project'].sudo().browse(project_id)
|
||||
# to avoid giving any access rights on projects to the public user, let's use sudo
|
||||
# and check if the user should be able to view the project (project managers only if it's unpublished or has no rating)
|
||||
if not ((project.rating_status!='no') and project.website_published) and not user.sudo(user).has_group('project.group_project_manager'):
|
||||
if not ((project.rating_status!='no') and project.portal_show_rating) and not user.sudo(user).has_group('project.group_project_manager'):
|
||||
raise NotFound()
|
||||
values = {
|
||||
'project': project,
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
|
||||
_name = "project.project"
|
||||
_inherit = ['project.project', 'website.published.mixin']
|
||||
_inherit = ['project.project']
|
||||
|
||||
portal_show_rating = fields.Boolean('Rating visible in Website', copy=False, oldname='website_published')
|
||||
|
||||
@api.multi
|
||||
def action_view_all_rating(self):
|
||||
""" Override this method without calling parent to redirect to rating website project page """
|
||||
self.ensure_one()
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'name': "Redirect to the Website Projcet Rating Page",
|
||||
'target': 'self',
|
||||
'url': "/project/rating/%s" % (self.id,)
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def _compute_website_url(self):
|
||||
super(Project, self)._compute_website_url()
|
||||
for project in self:
|
||||
project.website_url = "/project/rating/%s" % project.id
|
||||
if self.portal_show_rating:
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'name': "Redirect to the Website Projcet Rating Page",
|
||||
'target': 'self',
|
||||
'url': "/project/rating/%s" % (self.id,)
|
||||
}
|
||||
return super(Project, self).action_view_all_rating()
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="project_project_view_form" model="ir.ui.view">
|
||||
<field name="name">project.project.inherit.form</field>
|
||||
<field name="model">project.project</field>
|
||||
<field name="inherit_id" ref="project.edit_project"/>
|
||||
<field name="inherit_id" ref="rating_project.view_project_project_rating_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//div[@name="button_box"]/*[1]' position='before'>
|
||||
<button class="oe_stat_button" name="website_publish_button"
|
||||
type="object" icon="fa-globe" attrs="{'invisible': [('rating_status', '=', 'no')]}">
|
||||
<field name="website_published" widget="website_button"/>
|
||||
</button>
|
||||
<xpath expr="//field[@name='rating_status_period']" position="after">
|
||||
<field name="portal_show_rating" attrs="{'invisible': [('rating_status','==','no')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -115,13 +115,6 @@
|
||||
<div class="container oe_website_rating_project">
|
||||
<h1 t-esc="project.name" class="text-center"/>
|
||||
<div class="row mb32">
|
||||
<div id="website_published_button" class="" groups="project.group_project_manager">
|
||||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="project"/>
|
||||
<t t-set="publish_edit" t-value="True"/>
|
||||
<t t-set="action" t-value="'project.open_view_project_all'"/>
|
||||
</t>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<t t-set="type" t-value="'Tasks'"/>
|
||||
<t t-set="data" t-value="task_data"/>
|
||||
|
||||
Reference in New Issue
Block a user