[IMP] new page feature
bzr revid: fp@tinyerp.com-20130702190449-i1mbuq1cmsz2vu7t
This commit is contained in:
parent
4361ab910c
commit
d644977070
|
@ -26,7 +26,6 @@ def template_values():
|
|||
return values
|
||||
|
||||
class Website(openerp.addons.web.controllers.main.Home):
|
||||
|
||||
@http.route('/', type='http', auth="db")
|
||||
def index(self, **kw):
|
||||
return self.page("website.homepage")
|
||||
|
@ -35,23 +34,43 @@ class Website(openerp.addons.web.controllers.main.Home):
|
|||
def admin(self, *args, **kw):
|
||||
return super(Website, self).index(*args, **kw)
|
||||
|
||||
@http.route('/page/<path:path>', type='http', auth="db")
|
||||
def page(self, path):
|
||||
@http.route('/<any(page,pagenew):operation>/<path:path>', type='http', auth="db")
|
||||
def page(self, operation, path, new=False):
|
||||
#def get_html_head():
|
||||
# head += ['<link rel="stylesheet" href="%s">' % i for i in manifest_list('css', db=request.db)]
|
||||
#modules = request.registry.get("ir.module.module").search_read(request.cr, openerp.SUPERUSER_ID, fields=['id', 'shortdesc', 'summary', 'icon_image'], limit=50)
|
||||
values = template_values()
|
||||
uid = values['uid']
|
||||
if operation=='pagenew':
|
||||
imd = request.registry['ir.model.data']
|
||||
view_model, view_id = imd.get_object_reference(request.cr, uid, 'website', 'default_page')
|
||||
newview_id = request.registry['ir.ui.view'].copy(request.cr, uid, view_id)
|
||||
if '.' in path:
|
||||
module, idname = path.split('.')
|
||||
else:
|
||||
module = False
|
||||
idname = path
|
||||
imd.create(request.cr, uid, {
|
||||
'name': idname,
|
||||
'module': module,
|
||||
'model': 'ir.ui.view',
|
||||
'res_id': newview_id,
|
||||
})
|
||||
|
||||
context = {
|
||||
'inherit_branding': values['editable'],
|
||||
}
|
||||
company = request.registry['res.company'].browse(request.cr, uid, 1, context=context)
|
||||
values.update({
|
||||
'res_company': company,
|
||||
'path': path
|
||||
})
|
||||
values['google_map_url'] = "http://maps.googleapis.com/maps/api/staticmap?center=%s&sensor=false&zoom=8&size=298x298" \
|
||||
% quote_plus('%s, %s %s, %s' % (company.street, company.city, company.zip, company.country_id and company.country_id.name_get()[0][1] or ''))
|
||||
html = request.registry.get("ir.ui.view").render(request.cr, uid, path, values, context)
|
||||
try:
|
||||
html = request.registry.get("ir.ui.view").render(request.cr, uid, path, values, context)
|
||||
except ValueError, e:
|
||||
html = request.registry.get("ir.ui.view").render(request.cr, uid, 'website.404', values, context)
|
||||
return html
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -260,6 +260,46 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="default_page" model="ir.ui.view">
|
||||
<field name="name">New Page</field>
|
||||
<field name="type">qweb</field>
|
||||
<field name="arch" type="xml">
|
||||
<t t-call="website.layout">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<h1>New Page</h1>
|
||||
<p>Write your text here...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</t>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="404" model="ir.ui.view">
|
||||
<field name="name">Page not found</field>
|
||||
<field name="type">qweb</field>
|
||||
<field name="arch" type="xml">
|
||||
<t t-call="website.layout">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<h1>Page not found: <span t-esc="path"/>!</h1>
|
||||
<p>Do you want to create one?</p>
|
||||
<a t-att-href="'/pagenew/'+path">Create One</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</t>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="contactus" model="ir.ui.view">
|
||||
<field name="name">contactus</field>
|
||||
<field name="type">qweb</field>
|
||||
|
|
Loading…
Reference in New Issue