2013-06-24 13:36:54 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import openerp
|
|
|
|
from openerp.addons.web import http
|
2013-06-25 14:23:13 +00:00
|
|
|
from openerp.addons.web.controllers.main import manifest_list
|
2013-07-02 16:03:05 +00:00
|
|
|
from urllib import quote_plus
|
2013-06-24 13:36:54 +00:00
|
|
|
from openerp.addons.web.http import request
|
|
|
|
|
2013-07-02 11:04:39 +00:00
|
|
|
def template_values():
|
|
|
|
script = "\n".join(['<script type="text/javascript" src="%s"></script>' % i for i in manifest_list('js', db=request.db)])
|
2013-07-02 16:46:37 +00:00
|
|
|
try:
|
|
|
|
request.session.check_security()
|
|
|
|
loggued = True
|
|
|
|
uid = request.session._uid
|
|
|
|
except http.SessionExpiredException:
|
|
|
|
loggued = True
|
|
|
|
uid = openerp.SUPERUSER_ID
|
2013-07-02 11:04:39 +00:00
|
|
|
values = {
|
2013-07-02 16:46:37 +00:00
|
|
|
'loggued': loggued,
|
|
|
|
'editable': loggued,
|
2013-07-02 11:04:39 +00:00
|
|
|
'request': request,
|
|
|
|
'registry': request.registry,
|
|
|
|
'cr': request.cr,
|
2013-07-02 16:46:37 +00:00
|
|
|
'uid': uid,
|
2013-07-02 11:04:39 +00:00
|
|
|
'script' : script,
|
|
|
|
}
|
|
|
|
return values
|
|
|
|
|
2013-06-24 13:36:54 +00:00
|
|
|
class Website(openerp.addons.web.controllers.main.Home):
|
|
|
|
|
|
|
|
@http.route('/', type='http', auth="db")
|
|
|
|
def index(self, **kw):
|
2013-07-01 00:20:54 +00:00
|
|
|
return self.page("website.homepage")
|
2013-06-24 13:36:54 +00:00
|
|
|
|
|
|
|
@http.route('/admin', type='http', auth="none")
|
|
|
|
def admin(self, *args, **kw):
|
|
|
|
return super(Website, self).index(*args, **kw)
|
|
|
|
|
2013-06-27 09:14:09 +00:00
|
|
|
@http.route('/page/<path:path>', type='http', auth="db")
|
2013-06-27 14:27:51 +00:00
|
|
|
def page(self, path):
|
2013-07-01 00:20:54 +00:00
|
|
|
#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)
|
2013-07-02 16:46:37 +00:00
|
|
|
values = template_values()
|
|
|
|
uid = values['uid']
|
2013-07-01 00:20:54 +00:00
|
|
|
context = {
|
2013-07-02 16:46:37 +00:00
|
|
|
'inherit_branding': values['editable'],
|
2013-07-01 00:20:54 +00:00
|
|
|
}
|
2013-07-02 16:03:05 +00:00
|
|
|
company = request.registry['res.company'].browse(request.cr, uid, 1, context=context)
|
2013-07-02 11:04:39 +00:00
|
|
|
values.update({
|
2013-07-02 16:03:05 +00:00
|
|
|
'res_company': company,
|
2013-07-02 11:04:39 +00:00
|
|
|
})
|
2013-07-02 16:03:05 +00:00
|
|
|
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 ''))
|
2013-07-01 00:20:54 +00:00
|
|
|
html = request.registry.get("ir.ui.view").render(request.cr, uid, path, values, context)
|
2013-06-27 09:14:09 +00:00
|
|
|
return html
|
|
|
|
|
2013-06-24 13:36:54 +00:00
|
|
|
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|