From d6449770707a4ab68a3a26433ab12676ecf23c6a Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 2 Jul 2013 21:04:49 +0200 Subject: [PATCH] [IMP] new page feature bzr revid: fp@tinyerp.com-20130702190449-i1mbuq1cmsz2vu7t --- addons/website/controllers/main.py | 27 +++++++++++++++++--- addons/website/views/views.xml | 40 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index aa42b8f3ea4..66d7e187541 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -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/', type='http', auth="db") - def page(self, path): + @http.route('//', type='http', auth="db") + def page(self, operation, path, new=False): #def get_html_head(): # head += ['' % 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: diff --git a/addons/website/views/views.xml b/addons/website/views/views.xml index befdd106c67..dd606264e8f 100644 --- a/addons/website/views/views.xml +++ b/addons/website/views/views.xml @@ -260,6 +260,46 @@ + + + New Page + qweb + + +
+
+
+

New Page

+

Write your text here...

+
+
+ +
+
+
+
+ + + + Page not found + qweb + + +
+
+
+

Page not found: !

+

Do you want to create one?

+ Create One +
+
+ +
+
+
+
+ + contactus qweb