[IMP] website: publish improvements
- added protection again writing/reading directly on website_published: now done only if this is a valid column - added management of website_published_datetime, set everytime published is set to True; this is done to be able to track publish date on messages and blog posts notably. bzr revid: tde@openerp.com-20131011125429-4zvm8txz67ew8tho
This commit is contained in:
parent
3fb01132d2
commit
9700084074
|
@ -27,6 +27,7 @@ except ImportError:
|
|||
return specialless[:max_length]
|
||||
|
||||
import openerp
|
||||
from openerp.osv import fields
|
||||
from openerp.addons.website.models import website
|
||||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
|
@ -252,11 +253,16 @@ class Website(openerp.addons.web.controllers.main.Home):
|
|||
def publish(self, id, object):
|
||||
_id = int(id)
|
||||
_object = request.registry[object]
|
||||
|
||||
obj = _object.browse(request.cr, request.uid, _id)
|
||||
|
||||
values = {}
|
||||
if 'website_published' in _object._all_columns:
|
||||
values['website_published'] = not obj.website_published
|
||||
if 'website_published_datetime' in _object._all_columns and values.get('website_published'):
|
||||
values['website_published_datetime'] = fields.datetime.now()
|
||||
_object.write(request.cr, request.uid, [_id],
|
||||
{'website_published': not obj.website_published},
|
||||
context=request.context)
|
||||
values, context=request.context)
|
||||
|
||||
obj = _object.browse(request.cr, request.uid, _id)
|
||||
return obj.website_published and True or False
|
||||
|
||||
|
|
|
@ -384,6 +384,9 @@
|
|||
<a href="#" class="js_publish_btn css_unpublish">Unpublish</a>
|
||||
<a href="#" class="js_publish_btn css_publish">Publish</a>
|
||||
</li>
|
||||
<li t-if="publish_duplicate">
|
||||
<a t-att-href="publish_duplicate">Duplicate</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<t t-if="publish_edit">
|
||||
|
|
Loading…
Reference in New Issue