[MERGE]Merge lp:~openerp-dev/openobject-addons/trunk-website-al.
bzr revid: bth@tinyerp.com-20130827125728-08li08bkjyia7vok
This commit is contained in:
@@ -13,6 +13,7 @@ OpenERP Website CMS
|
||||
'installable': True,
|
||||
'data': [
|
||||
'views/views.xml',
|
||||
'views/themes.xml',
|
||||
'views/res_config.xml',
|
||||
'website_data.xml',
|
||||
],
|
||||
|
||||
@@ -66,6 +66,26 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||
})
|
||||
return werkzeug.utils.redirect("/page/%s" % path)
|
||||
|
||||
@http.route('/website/theme_change', type='http', auth="admin")
|
||||
def theme_change(self, theme_id=False, **kwargs):
|
||||
imd = request.registry['ir.model.data']
|
||||
view = request.registry['ir.ui.view']
|
||||
|
||||
view_model, view_option_id = imd.get_object_reference(request.cr, request.uid, 'website', 'theme')
|
||||
views = view.search(request.cr, request.uid, [('inherit_id','=',view_option_id)])
|
||||
view.write(request.cr, request.uid, views, {'inherit_id': False})
|
||||
|
||||
if theme_id:
|
||||
module, xml_id = theme_id.split('.')
|
||||
view_model, view_id = imd.get_object_reference(request.cr, request.uid, module, xml_id)
|
||||
view.write(request.cr, request.uid, [view_id], {'inherit_id':view_option_id})
|
||||
|
||||
website = request.registry.get("website")
|
||||
values = website.get_rendering_context({
|
||||
'theme_changed': True
|
||||
})
|
||||
return website.render('website.themes', values)
|
||||
|
||||
@http.route('/page/<path:path>', type='http', auth="admin")
|
||||
def page(self, path, **kwargs):
|
||||
website = request.registry.get("website")
|
||||
@@ -83,25 +103,25 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||
view_obj = request.registry.get("ir.ui.view")
|
||||
view = view_obj.browse(request.cr, request.uid, int(view_id), context=request.context)
|
||||
if view.inherit_id:
|
||||
print '*', view.inherit_id
|
||||
value = False
|
||||
else:
|
||||
value = view.inherit_option_id and view.inherit_option_id.id or False
|
||||
print '*', view.inherit_id, 'no', value, view
|
||||
view_obj.write(request.cr, request.uid, [view_id], {
|
||||
'inherit_id': value
|
||||
}, context=request.context)
|
||||
print 'Wrote', value, 'on', view_id
|
||||
return True
|
||||
|
||||
@http.route('/website/customize_template_get', type='json', auth='admin') # FIXME: auth
|
||||
def customize_template_get(self, xml_id):
|
||||
imd = request.registry['ir.model.data']
|
||||
view_model, view_theme_id = imd.get_object_reference(request.cr, request.uid, 'website', 'theme')
|
||||
|
||||
view = request.registry.get("ir.ui.view")
|
||||
views = view._views_get(request.cr, request.uid, xml_id, request.context)
|
||||
done = {}
|
||||
result = []
|
||||
for v in views:
|
||||
if v.inherit_option_id:
|
||||
if v.inherit_option_id and v.inherit_option_id.id<>view_theme_id:
|
||||
if v.inherit_option_id.id not in done:
|
||||
result.append({
|
||||
'name': v.inherit_option_id.name,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@charset "utf-8";
|
||||
.oe_hidden {
|
||||
display: none !important;
|
||||
}
|
||||
@@ -220,7 +221,7 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#mobile-preview.modal {
|
||||
.oe_mobile_preview.modal {
|
||||
height: 660px;
|
||||
background-color: black;
|
||||
border: 2px solid;
|
||||
@@ -233,22 +234,22 @@
|
||||
right: 0;
|
||||
max-width: 330px;
|
||||
}
|
||||
#mobile-preview.modal .modal-header {
|
||||
.oe_mobile_preview.modal .modal-header {
|
||||
background-color: black;
|
||||
border-bottom: 0;
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
#mobile-preview.modal .modal-header .oe_mobile_preview_title {
|
||||
.oe_mobile_preview.modal .modal-header .oe_mobile_preview_title {
|
||||
color: #1a1a1a;
|
||||
}
|
||||
#mobile-preview.modal .modal-body {
|
||||
.oe_mobile_preview.modal .modal-body {
|
||||
background-color: black;
|
||||
max-height: 600px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
#mobile-preview.modal .modal-footer {
|
||||
.oe_mobile_preview.modal .modal-footer {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
@@ -267,3 +268,24 @@
|
||||
color: #e00101;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.oe_seo_configuration input {
|
||||
width: inherit;
|
||||
}
|
||||
.oe_seo_configuration textarea {
|
||||
width: inherit;
|
||||
}
|
||||
.oe_seo_configuration ul {
|
||||
list-style: none;
|
||||
}
|
||||
.oe_seo_configuration .oe_remove {
|
||||
color: #e00101;
|
||||
}
|
||||
|
||||
.oe_seo_keywords_list {
|
||||
width: 39em;
|
||||
}
|
||||
.oe_seo_keywords_list li {
|
||||
float: left;
|
||||
width: 12em;
|
||||
}
|
||||
|
||||
@@ -194,8 +194,8 @@
|
||||
|
||||
$mobile_preview_background: #000000
|
||||
$mobile_preview_border: #1A1A1A
|
||||
$mobile_preview_close: #E00101
|
||||
#mobile-preview.modal
|
||||
$icon_close: #E00101
|
||||
.oe_mobile_preview.modal
|
||||
height: 660px
|
||||
background-color: $mobile_preview_background
|
||||
border: 2px solid
|
||||
@@ -233,5 +233,21 @@ $mobile_preview_close: #E00101
|
||||
color: lightgrey
|
||||
opacity: 1
|
||||
.close:hover
|
||||
color: $mobile_preview_close
|
||||
color: $icon_close
|
||||
opacity: 1
|
||||
|
||||
.oe_seo_configuration
|
||||
input
|
||||
width: inherit
|
||||
textarea
|
||||
width: inherit
|
||||
ul
|
||||
list-style: none
|
||||
.oe_remove
|
||||
color: $icon_close
|
||||
|
||||
.oe_seo_keywords_list
|
||||
width: 39em
|
||||
li
|
||||
float: left
|
||||
width: 12em
|
||||
@@ -46,6 +46,7 @@
|
||||
'click button[data-action=cancel]': 'cancel',
|
||||
'click button[data-action=snippet]': 'snippet',
|
||||
'click a[data-action=show-mobile-preview]': 'mobilePreview',
|
||||
'click a[data-action=promote-current-page]': 'promotePage',
|
||||
},
|
||||
container: 'body',
|
||||
customize_setup: function() {
|
||||
@@ -64,6 +65,8 @@
|
||||
item.id, item.active ? '' : '-empty', item.name));
|
||||
}
|
||||
});
|
||||
// Adding Static Menus
|
||||
menu.append('<li class="divider"></li><li><a href="/page/website.themes">Change Theme</a></li>');
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -75,12 +78,6 @@
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
$('#mobile-preview').on('hidden', function () {
|
||||
$('body').removeClass('oe_stop_scrolling');
|
||||
});
|
||||
$('.oe_mobile_preview_header button').click(function (){
|
||||
$("#mobile-preview").addClass('hide');
|
||||
});
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
@@ -200,11 +197,98 @@
|
||||
this.snippets.toggle();
|
||||
},
|
||||
mobilePreview: function () {
|
||||
(new website.MobilePreview()).appendTo($('body'));
|
||||
},
|
||||
promotePage: function () {
|
||||
(new website.seo.Configurator()).appendTo($('body'));
|
||||
},
|
||||
});
|
||||
|
||||
/* ----- MOBILE PREVIEW ---- */
|
||||
website.MobilePreview = openerp.Widget.extend({
|
||||
template: 'website.mobile_preview',
|
||||
events: {
|
||||
'hidden': 'close'
|
||||
},
|
||||
start: function () {
|
||||
$('body').addClass('oe_stop_scrolling');
|
||||
$('body').addClass('oe_stop_scrolling');
|
||||
$("#mobile-preview").removeClass('hide');
|
||||
document.getElementById("mobile-viewport").src = window.location.href + "?mobile-preview=true";
|
||||
this.$el.modal();
|
||||
},
|
||||
close: function () {
|
||||
$('body').removeClass('oe_stop_scrolling');
|
||||
this.destroy();
|
||||
},
|
||||
});
|
||||
|
||||
/* ----- SEO TOOLS ---- */
|
||||
website.seo = {};
|
||||
website.seo.Keyword = openerp.Widget.extend({
|
||||
template: 'website.seo_keyword',
|
||||
events: {
|
||||
'click a[data-action=remove-keyword]': 'destroy',
|
||||
},
|
||||
init: function (parent, options) {
|
||||
this._super(parent);
|
||||
this.keyword = options.keyword;
|
||||
},
|
||||
});
|
||||
website.seo.Configurator = openerp.Widget.extend({
|
||||
template: 'website.seo_configuration',
|
||||
events: {
|
||||
'keypress input[name=seo_page_keywords]': 'confirmKeyword',
|
||||
'click button[data-action=add]': 'addKeyword',
|
||||
'click a[data-action=update]': 'update',
|
||||
'hidden': 'close'
|
||||
},
|
||||
start: function () {
|
||||
$('body').addClass('oe_stop_scrolling');
|
||||
|
||||
this.$el.find('input[name=seo_page_url]').val(window.location.href);
|
||||
this.$el.find('input[name=seo_page_title]').val($('title').text());
|
||||
|
||||
this.$el.modal();
|
||||
},
|
||||
keywords: function () {
|
||||
var result = [];
|
||||
this.$el.find('.js_seo_keyword').each(function () {
|
||||
result.push($(this).text());
|
||||
})
|
||||
return _.uniq(result);
|
||||
},
|
||||
isExistingKeyword: function (word) {
|
||||
return _.contains(this.keywords(), word);
|
||||
},
|
||||
isKeywordListFull: function () {
|
||||
return this.keywords().length >= 10;
|
||||
},
|
||||
confirmKeyword: function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
this.addKeyword();
|
||||
this.$el.find('input[name=seo_page_keywords]').val("");
|
||||
}
|
||||
},
|
||||
addKeyword: function () {
|
||||
var word = this.$el.find('input[name=seo_page_keywords]').val().trim();
|
||||
if (word && !this.isKeywordListFull() && !this.isExistingKeyword(word)) {
|
||||
new website.seo.Keyword(this, {
|
||||
keyword: word
|
||||
}).appendTo(this.$el.find('.js_seo_keywords_list'));
|
||||
var $body = this.$el.find('.modal-body');
|
||||
$body.animate({
|
||||
scrollTop: $body[0].scrollHeight
|
||||
}, 500);
|
||||
}
|
||||
},
|
||||
update: function () {
|
||||
console.log(this.keywords());
|
||||
// TODO: Persist changes
|
||||
},
|
||||
close: function () {
|
||||
$('body').removeClass('oe_stop_scrolling');
|
||||
this.destroy();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -321,14 +405,14 @@
|
||||
}
|
||||
},
|
||||
vomify: function($el){
|
||||
var hue=0;
|
||||
var hue=0;
|
||||
var beat = false;
|
||||
var a = setInterval(function(){
|
||||
var a = setInterval(function(){
|
||||
$el.css({'-webkit-filter':'hue-rotate('+hue+'deg)'}); hue += 5;
|
||||
}, 10);
|
||||
setTimeout(function(){
|
||||
clearInterval(a);
|
||||
setInterval(function(){
|
||||
setInterval(function(){
|
||||
var filter = 'hue-rotate('+hue+'deg)'+ (beat ? ' invert()' : '');
|
||||
$('html').css({'-webkit-filter': filter}); hue += 5;
|
||||
if(hue % 35 === 0){
|
||||
@@ -372,7 +456,7 @@
|
||||
// setup widget and drag and drop
|
||||
start_snippets: function(){
|
||||
var self = this;
|
||||
|
||||
|
||||
this.$('.oe_snippet').draggable({
|
||||
helper: 'clone',
|
||||
zIndex: '1000',
|
||||
@@ -497,7 +581,7 @@
|
||||
|
||||
activate_overlay_zones: function(selector){
|
||||
var $targets = $(selector);
|
||||
|
||||
|
||||
function is_visible($el){
|
||||
return $el.css('display') != 'none'
|
||||
&& $el.css('opacity') != '0'
|
||||
@@ -512,7 +596,7 @@
|
||||
var parents = $(this).parents().filter(function(){ return !is_visible($(this)); });
|
||||
return parents.length === 0;
|
||||
});
|
||||
|
||||
|
||||
var zone_template = "<div class='oe_drop_zone oe_overlay'></div>";
|
||||
$('.oe_drop_zone').remove();
|
||||
|
||||
@@ -536,7 +620,7 @@
|
||||
var self = this;
|
||||
this.activate_overlay_zones('#wrap .container');
|
||||
var $snippets = $('.oe_drop_zone');
|
||||
|
||||
|
||||
for(var i = 0, len = $snippets.length; i < len; i++){
|
||||
var $snippet = $snippets.eq(i);
|
||||
var $manipulator = $(openerp.qweb.render('website.snippet_manipulator'));
|
||||
@@ -558,10 +642,10 @@
|
||||
var y = event.pageY;
|
||||
|
||||
var pt = $snippet.css('padding-top');
|
||||
var pb = $snippet.css('padding-bottom');
|
||||
var pb = $snippet.css('padding-bottom');
|
||||
pt = Number(pt.slice(0,pt.length - 2)) || 0; //FIXME something cleaner to remove 'px'
|
||||
pb = Number(pb.slice(0,pb.length - 2)) || 0;
|
||||
|
||||
|
||||
$manipulator.addClass('oe_hover');
|
||||
event.preventDefault();
|
||||
|
||||
@@ -573,7 +657,7 @@
|
||||
$snippet.css('padding-top',pt-dy+'px');
|
||||
self.cover_target($manipulator,$snippet);
|
||||
}else if($handle.hasClass('s') || $handle.hasClass('sw') || $handle.hasClass('se')){
|
||||
|
||||
|
||||
$snippet.css('padding-bottom',pb+dy+'px');
|
||||
self.cover_target($manipulator,$snippet);
|
||||
}
|
||||
@@ -585,7 +669,7 @@
|
||||
self.activate_snippet_manipulators();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
deactivate_snippet_manipulators: function(){
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<button data-action="edit" class="btn btn-primary">Edit</button>
|
||||
</form>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><a data-action="show-mobile-preview" href="#mobile-preview" data-toggle="modal" role="button"><span title="Mobile preview" class="icon-mobile-phone"/></a></li>
|
||||
<li><a data-action="show-mobile-preview" href="#"><span title="Mobile preview" class="icon-mobile-phone"/></a></li>
|
||||
<li class="divider-vertical"></li>
|
||||
<li><a href="#">Promote<!-- <sup><span class="badge">1</span></sup> --></a></li>
|
||||
<li><a data-action="promote-current-page" href="#"><span title="Promote page on the web">Promote</span></a></li>
|
||||
<li><a href="#">Translate</a></li>
|
||||
<li class="dropdown">
|
||||
<a id="customize-menu-button" class="dropdown-toggle" data-toggle="dropdown" href="#">Customize <span class="caret"></span></a>
|
||||
@@ -35,8 +35,10 @@
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</t>
|
||||
|
||||
<div id="mobile-preview" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="mobile-preview-title" aria-hidden="true">
|
||||
<t t-name="website.mobile_preview">
|
||||
<div id="mobile-preview" class="modal hide fade oe_mobile_preview" tabindex="-1" role="dialog" aria-labelledby="mobile-preview-title" aria-hidden="true">
|
||||
<div class="modal-header oe_mobile_preview_header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="mobile-preview-title" class="oe_mobile_preview_title">Mobile preview</h3>
|
||||
@@ -47,7 +49,54 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website.seo_configuration">
|
||||
<div class="modal hide fade oe_seo_configuration" tabindex="-1" role="dialog" aria-labelledby="seo-configuration-title" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button title="Close" type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="seo-configuration-title">Promote your page on the web</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="seo_page_url">URL</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="seo_page_url" maxlength="70" size="70" readonly="readonly"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="seo_page_title">Title</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="seo_page_title" maxlength="70" size="70"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="seo_page_description">Description</label>
|
||||
<div class="controls">
|
||||
<textarea name="seo_page_description" rows="3" cols="70" size="160"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group oe_seo_keywords_area">
|
||||
<label class="control-label" for="seo_page_keywords">Keywords</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="text" name="seo_page_keywords" maxlength="20" size="24" placeholder="New keyword"/>
|
||||
<button data-action="add" class="btn" type="button">Add</button>
|
||||
</div>
|
||||
<ul class="oe_seo_keywords_list js_seo_keywords_list">
|
||||
<!-- filled in JS -->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a data-action="update" href="#" class="btn btn-primary">Update page</a>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website.seo_keyword">
|
||||
<li><a href="#" class="oe_remove" data-action="remove-keyword"><i class="icon-trash"/></a> <span class="label js_seo_keyword"><t t-raw="widget.keyword"/></span></li>
|
||||
</t>
|
||||
|
||||
<t t-name="website.carousel">
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!--
|
||||
Theme Selector
|
||||
-->
|
||||
|
||||
<template id="website.themes" name="Themes">
|
||||
<t t-call="website.layout">
|
||||
<div class="container" t-if="editable">
|
||||
|
||||
<div class="alert alert-block alert-success mt32" t-if="theme_changed">
|
||||
<button type="button" class="close" data-dismiss="alert">&times;</button>
|
||||
<p>
|
||||
<h4>Theme Changed!</h4>
|
||||
Have a look at <a href="/">your homepage</a> or try another theme bellow.
|
||||
</p>
|
||||
</div>
|
||||
<h1 class="text-center mt32">Change Your Theme</h1>
|
||||
|
||||
<div class="row mt32" id="themes-list">
|
||||
|
||||
<div class="span4">
|
||||
<div class="well text-center">
|
||||
<div class="image">
|
||||
<img class="img-responsive" src="http://bootswatch.com/flatly/thumbnail.png" alt="Flatly"/>
|
||||
</div>
|
||||
<div class="options">
|
||||
<h3>Flatly</h3>
|
||||
<p>Flat and modern</p>
|
||||
<a class="btn btn-info" href="/website/theme_change?theme_id=website.theme_flatly">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span4">
|
||||
<div class="well text-center">
|
||||
<div class="image">
|
||||
<img src="http://bootswatch.com/amelia/thumbnail.png" class="img-responsive" alt="Amelia"/>
|
||||
</div>
|
||||
<div class="options">
|
||||
<h3>Default</h3>
|
||||
<p>Sweet and cheery</p>
|
||||
<a class="btn btn-info" href="/website/theme_change">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span4">
|
||||
<div class="well text-center">
|
||||
<div class="image">
|
||||
<img src="http://bootswatch.com/cerulean/thumbnail.png" class="img-responsive" alt="Cerulean"/>
|
||||
</div>
|
||||
<div class="options">
|
||||
<h3>Cerulean</h3>
|
||||
<p>A calm, blue sky</p>
|
||||
<a class="btn btn-info" href="/website/theme_change">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span4">
|
||||
<div class="well text-center">
|
||||
<div class="image">
|
||||
<img class="img-responsive" src="http://bootswatch.com/cosmo/thumbnail.png" alt="Cosmo"/>
|
||||
</div>
|
||||
<div class="options">
|
||||
<h3>Cosmo</h3>
|
||||
<p>An ode to Metro</p>
|
||||
<a class="btn btn-info" href="/website/theme_change">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span4">
|
||||
<div class="well text-center">
|
||||
<div class="image">
|
||||
<img class="img-responsive" src="http://bootswatch.com/cyborg/thumbnail.png" alt="Cyborg"/>
|
||||
</div>
|
||||
<div class="options">
|
||||
<h3>Cyborg</h3>
|
||||
<p>Jet black and electric blue</p>
|
||||
<a class="btn btn-info" href="/website/theme_change">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span4">
|
||||
<div class="well text-center">
|
||||
<div class="image">
|
||||
<img class="img-responsive" src="http://bootswatch.com/journal/thumbnail.png" alt="Journal"/>
|
||||
</div>
|
||||
<div class="options">
|
||||
<h3>Journal</h3>
|
||||
<p>Crisp like a new sheet of paper</p>
|
||||
<a class="btn btn-info" href="/website/theme_change">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span4">
|
||||
<div class="well text-center">
|
||||
<div class="image">
|
||||
<img class="img-responsive" src="http://bootswatch.com/readable/thumbnail.png" alt="Readable"/>
|
||||
</div>
|
||||
<div class="options">
|
||||
<h3>Readable</h3>
|
||||
<p>Optimized for legibility</p>
|
||||
<a class="btn btn-info" href="/website/theme_change">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span4">
|
||||
<div class="well text-center">
|
||||
<div class="image">
|
||||
<img class="img-responsive" src="http://bootswatch.com/simplex/thumbnail.png" alt="Simplex"/>
|
||||
</div>
|
||||
<div class="options">
|
||||
<h3>Simplex</h3>
|
||||
<p>Mini and minimalist</p>
|
||||
<a class="btn btn-info" href="/website/theme_change">Apply</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<!--
|
||||
All Default Themes
|
||||
-->
|
||||
|
||||
<template id="website.theme_flatly" name="Flat Theme" inherit_option_id="website.theme">
|
||||
<xpath expr="//link[@id='bootstrap_css']" position="replace">
|
||||
<link rel='stylesheet' href='/website/static/lib/bootstrap/css/bootstrap-flatly.css' t-ignore="true"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -11,12 +11,6 @@
|
||||
<link id="website_css" rel='stylesheet' href='/website/static/src/css/website.css' t-ignore="true"/>
|
||||
</template>
|
||||
|
||||
<template id="website.theme_flatly" name="Flat Theme" inherit_option_id="website.theme">
|
||||
<xpath expr="//link[@id='bootstrap_css']" position="replace">
|
||||
<link rel='stylesheet' href='/website/static/lib/bootstrap/css/bootstrap-flatly.css' t-ignore="true"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="layout">
|
||||
<!DOCTYPE html>
|
||||
<html t-att-data-view-xmlid="__stack__[0]" t-att-data-editable="'1' if editable else '0'">
|
||||
|
||||
@@ -90,7 +90,7 @@ class website(osv.osv):
|
||||
except ValueError:
|
||||
logger.error("Website Rendering Error.\n\n%s" % traceback.format_exc())
|
||||
return self.render('website.404', values)
|
||||
|
||||
|
||||
# render template and catch error
|
||||
try:
|
||||
return view.render(request.cr, request.uid, template, values, context=context)
|
||||
|
||||
@@ -9,7 +9,7 @@ OpenERP Blog
|
||||
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['website', 'sale'],
|
||||
'depends': ['website', 'sale', 'website_crm_partner_assign'],
|
||||
'data': [
|
||||
'views/website_contract.xml',
|
||||
],
|
||||
|
||||
@@ -20,6 +20,7 @@ class website_contract(http.Controller):
|
||||
|
||||
# public partner profile
|
||||
partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, domain + [('website_published', '=', True)])
|
||||
worldmap_partner_ids = ",".join([str(p) for p in partner_ids])
|
||||
|
||||
if request.uid != website.get_public_user().id:
|
||||
contract_ids = account_obj.search(request.cr, openerp.SUPERUSER_ID, [(1, "=", 1)])
|
||||
@@ -36,6 +37,7 @@ class website_contract(http.Controller):
|
||||
|
||||
values = website.get_rendering_context({
|
||||
'partner_ids': partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids),
|
||||
'worldmap_partner_ids': worldmap_partner_ids,
|
||||
'pager': pager,
|
||||
'search': post.get("search"),
|
||||
})
|
||||
@@ -46,6 +48,9 @@ class website_contract(http.Controller):
|
||||
website = request.registry['website']
|
||||
partner_obj = request.registry['res.partner']
|
||||
partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, [('website_published', '=', True), ('id', '=', ref_id)])
|
||||
if request.uid != website.get_public_user().id:
|
||||
partner_ids += partner_obj.search(request.cr, request.uid, [('id', '=', ref_id)])
|
||||
|
||||
values = website.get_rendering_context({
|
||||
'partner_id': partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids[0], context={'show_address': True}),
|
||||
})
|
||||
|
||||
@@ -70,6 +70,8 @@
|
||||
<a t-attf-href="/event/#{ search_path }&country=#{ country_id[0] }"><t t-esc="country_id[1]"/><small>(<t t-esc="country_id_count"/>)</small></a>
|
||||
</li>
|
||||
</t-->
|
||||
<iframe t-attf-src="/worldmap/?width=320&height=240&partner_ids=#{ worldmap_partner_ids }&partner_url=/references/"
|
||||
style="width:320px; height:260px; border:0; padding:0; margin:0;"></iframe>
|
||||
</ul>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
import controllers
|
||||
import website_crm
|
||||
@@ -11,9 +11,7 @@ OpenERP Contact Form
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['website', 'crm'],
|
||||
'data': [
|
||||
'views/website_crm.xml'
|
||||
'views/website_crm.xml',
|
||||
],
|
||||
'js': ['static/src/js/ecommerce.js'],
|
||||
'css': ['static/src/css/ecommerce.css'],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import openerp
|
||||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
import simplejson
|
||||
import werkzeug.wrappers
|
||||
|
||||
from urllib import quote_plus
|
||||
|
||||
@@ -19,4 +22,37 @@ class contactus(http.Controller):
|
||||
})
|
||||
return website.render("website_crm.thanks", values)
|
||||
|
||||
@http.route(['/crm/worldmap/'], type='http', auth="admin")
|
||||
def worldmap(self, *arg, **post):
|
||||
website = request.registry['website']
|
||||
values = website.get_rendering_context()
|
||||
values['partner_ids'] = post.get('partner_ids', "")
|
||||
return website.render("website_crm.worldmap", values)
|
||||
|
||||
@http.route(['/crm/worldmap/partners.json'], type='http', auth="admin")
|
||||
def worldmap_data(self, *arg, **post):
|
||||
website = request.registry['website']
|
||||
partner_obj = request.registry['res.partner']
|
||||
|
||||
domain = [("id", "in", [int(p) for p in post.get('partner_ids', "").split(",") if p])]
|
||||
partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, domain + [('website_published', '=', True)])
|
||||
if request.uid != website.get_public_user().id:
|
||||
partner_ids += partner_obj.search(request.cr, request.uid, domain)
|
||||
|
||||
data = {
|
||||
"counter": len(partner_ids),
|
||||
"partners": []
|
||||
}
|
||||
for partner in partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids, context={'show_address': True}):
|
||||
data["partners"].append({
|
||||
'id': partner.id,
|
||||
'name': partner.name,
|
||||
'address': '\n'.join(partner.name_get()[0][1].split('\n')[1:]),
|
||||
'type': "Silver Partners"
|
||||
})
|
||||
|
||||
mime = 'application/json'
|
||||
body = "var data = " + "}, \n{".join(simplejson.dumps(data).split("}, {"))
|
||||
return werkzeug.wrappers.Response(body, headers=[('Content-Type', mime), ('Content-Length', len(body))])
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
class res_partner(osv.osv):
|
||||
_inherit = 'res.partner'
|
||||
_columns = {
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import controllers
|
||||
import website_crm_partner_assign
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
'name': 'Website Worldmap',
|
||||
'category': 'Website',
|
||||
'summary': '',
|
||||
'version': '1.0',
|
||||
'description': """
|
||||
OpenERP Website Worldmap
|
||||
========================
|
||||
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['website', 'website_crm', 'crm_partner_assign'],
|
||||
'data': [
|
||||
'views/worldmap.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import main
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -0,0 +1,83 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import openerp
|
||||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
import simplejson
|
||||
import werkzeug.wrappers
|
||||
from datetime import datetime
|
||||
|
||||
from urllib import quote_plus
|
||||
|
||||
class contactus(http.Controller):
|
||||
|
||||
@http.route(['/crm/contactus'], type='http', auth="admin")
|
||||
def contactus(self, *arg, **post):
|
||||
website = request.registry['website']
|
||||
post['user_id'] = False
|
||||
request.registry['crm.lead'].create(request.cr, request.uid, post)
|
||||
values = website.get_rendering_context()
|
||||
company = values['res_company']
|
||||
values.update({
|
||||
'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 ''))
|
||||
})
|
||||
return website.render("website_crm.thanks", values)
|
||||
|
||||
@http.route(['/worldmap/'], type='http', auth="admin")
|
||||
def worldmap(self, *arg, **post):
|
||||
website = request.registry['website']
|
||||
values = website.get_rendering_context()
|
||||
values['partner_ids'] = post.get('partner_ids', "")
|
||||
values['width'] = post.get('width', 900)
|
||||
values['height'] = post.get('height', 460)
|
||||
values['partner_url'] = post.get('partner_url')
|
||||
return website.render("website_crm_partner_assign.worldmap", values)
|
||||
|
||||
@http.route(['/worldmap/partners.json'], type='http', auth="admin")
|
||||
def worldmap_data(self, *arg, **post):
|
||||
website = request.registry['website']
|
||||
partner_obj = request.registry['res.partner']
|
||||
|
||||
domain = [("id", "in", [int(p) for p in post.get('partner_ids', "").split(",") if p])]
|
||||
partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, domain + [('website_published', '=', True)])
|
||||
if request.uid != website.get_public_user().id:
|
||||
partner_ids += partner_obj.search(request.cr, request.uid, domain)
|
||||
partner_ids = list(set(partner_ids))
|
||||
|
||||
data = {
|
||||
"counter": len(partner_ids),
|
||||
"partners": []
|
||||
}
|
||||
for partner in partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids, context={'show_address': True}):
|
||||
data["partners"].append({
|
||||
'id': partner.id,
|
||||
'name': partner.name,
|
||||
'address': '\n'.join(partner.name_get()[0][1].split('\n')[1:]),
|
||||
'type': partner.grade_id.name,
|
||||
'latitude': partner.partner_latitude,
|
||||
'longitude': partner.partner_longitude,
|
||||
})
|
||||
|
||||
mime = 'application/json'
|
||||
body = "var data = " + "}, \n{".join(simplejson.dumps(data).split("}, {"))
|
||||
return werkzeug.wrappers.Response(body, headers=[('Content-Type', mime), ('Content-Length', len(body))])
|
||||
|
||||
@http.route(['/worldmap/set_partner_position/'], type='http', auth="admin")
|
||||
def worldmap_set_partner_position(self, *arg, **post):
|
||||
website = request.registry['website']
|
||||
partner_obj = request.registry['res.partner']
|
||||
|
||||
partner_id = post.get('partner_id') and int(post['partner_id'])
|
||||
latitude = post.get('latitude') and float(post['latitude'])
|
||||
longitude = post.get('longitude') and float(post['longitude'])
|
||||
|
||||
if request.uid != website.get_public_user().id and partner_id and (latitude or longitude):
|
||||
values = {
|
||||
'partner_latitude': latitude,
|
||||
'partner_longitude': longitude,
|
||||
'date_localization': datetime.now().strftime('%Y-%m-%d'),
|
||||
}
|
||||
partner_obj.write(request.cr, request.uid, [partner_id], values)
|
||||
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
(function(){var d=null;function e(a){return function(b){this[a]=b}}function i(a){return function(){return this[a]}}var j;
|
||||
function k(a,b,c){this.extend(k,google.maps.OverlayView);this.b=a;this.a=[];this.f=[];this.ca=[53,56,66,78,90];this.j=[];this.A=!1;c=c||{};this.g=c.gridSize||60;this.l=c.minimumClusterSize||2;this.J=c.maxZoom||d;this.j=c.styles||[];this.X=c.imagePath||this.Q;this.W=c.imageExtension||this.P;this.O=!0;if(c.zoomOnClick!=void 0)this.O=c.zoomOnClick;this.r=!1;if(c.averageCenter!=void 0)this.r=c.averageCenter;l(this);this.setMap(a);this.K=this.b.getZoom();var f=this;google.maps.event.addListener(this.b,
|
||||
"zoom_changed",function(){var a=f.b.mapTypes[f.b.getMapTypeId()].maxZoom,b=f.b.getZoom();if(!(b<0||b>a)&&f.K!=b)f.K=f.b.getZoom(),f.m()});google.maps.event.addListener(this.b,"idle",function(){f.i()});b&&b.length&&this.C(b,!1)}j=k.prototype;j.Q="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/images/m";j.P="png";j.extend=function(a,b){return function(a){for(var b in a.prototype)this.prototype[b]=a.prototype[b];return this}.apply(a,[b])};
|
||||
j.onAdd=function(){if(!this.A)this.A=!0,n(this)};j.draw=function(){};function l(a){if(!a.j.length)for(var b=0,c;c=a.ca[b];b++)a.j.push({url:a.X+(b+1)+"."+a.W,height:c,width:c})}j.S=function(){for(var a=this.o(),b=new google.maps.LatLngBounds,c=0,f;f=a[c];c++)b.extend(f.getPosition());this.b.fitBounds(b)};j.z=i("j");j.o=i("a");j.V=function(){return this.a.length};j.ba=e("J");j.I=function(){return this.J||this.b.mapTypes[this.b.getMapTypeId()].maxZoom};
|
||||
j.G=function(a,b){for(var c=0,f=a.length,g=f;g!==0;)g=parseInt(g/10,10),c++;c=Math.min(c,b);return{text:f,index:c}};j.$=e("G");j.H=i("G");j.C=function(a,b){for(var c=0,f;f=a[c];c++)q(this,f);b||this.i()};function q(a,b){b.s=!1;b.draggable&&google.maps.event.addListener(b,"dragend",function(){b.s=!1;a.L()});a.a.push(b)}j.q=function(a,b){q(this,a);b||this.i()};
|
||||
function s(a,b){var c=-1;if(a.a.indexOf)c=a.a.indexOf(b);else for(var f=0,g;g=a.a[f];f++)if(g==b){c=f;break}if(c==-1)return!1;a.a.splice(c,1);return!0}j.Y=function(a,b){var c=s(this,a);return!b&&c?(this.m(),this.i(),!0):!1};j.Z=function(a,b){for(var c=!1,f=0,g;g=a[f];f++)g=s(this,g),c=c||g;if(!b&&c)return this.m(),this.i(),!0};j.U=function(){return this.f.length};j.getMap=i("b");j.setMap=e("b");j.w=i("g");j.aa=e("g");
|
||||
j.v=function(a){var b=this.getProjection(),c=new google.maps.LatLng(a.getNorthEast().lat(),a.getNorthEast().lng()),f=new google.maps.LatLng(a.getSouthWest().lat(),a.getSouthWest().lng());c=b.fromLatLngToDivPixel(c);c.x+=this.g;c.y-=this.g;f=b.fromLatLngToDivPixel(f);f.x-=this.g;f.y+=this.g;c=b.fromDivPixelToLatLng(c);b=b.fromDivPixelToLatLng(f);a.extend(c);a.extend(b);return a};j.R=function(){this.m(!0);this.a=[]};
|
||||
j.m=function(a){for(var b=0,c;c=this.f[b];b++)c.remove();for(b=0;c=this.a[b];b++)c.s=!1,a&&c.setMap(d);this.f=[]};j.L=function(){var a=this.f.slice();this.f.length=0;this.m();this.i();window.setTimeout(function(){for(var b=0,c;c=a[b];b++)c.remove()},0)};j.i=function(){n(this)};
|
||||
function n(a){if(a.A)for(var b=a.v(new google.maps.LatLngBounds(a.b.getBounds().getSouthWest(),a.b.getBounds().getNorthEast())),c=0,f;f=a.a[c];c++)if(!f.s&&b.contains(f.getPosition())){for(var g=a,r=4E4,o=d,v=0,m=void 0;m=g.f[v];v++){var h=m.getCenter();if(h){var p=f.getPosition();if(!h||!p)h=0;else{var w=(p.lat()-h.lat())*Math.PI/180,x=(p.lng()-h.lng())*Math.PI/180;h=Math.sin(w/2)*Math.sin(w/2)+Math.cos(h.lat()*Math.PI/180)*Math.cos(p.lat()*Math.PI/180)*Math.sin(x/2)*Math.sin(x/2);h=6371*2*Math.atan2(Math.sqrt(h),
|
||||
Math.sqrt(1-h))}h<r&&(r=h,o=m)}}o&&o.F.contains(f.getPosition())?o.q(f):(m=new t(g),m.q(f),g.f.push(m))}}function t(a){this.k=a;this.b=a.getMap();this.g=a.w();this.l=a.l;this.r=a.r;this.d=d;this.a=[];this.F=d;this.n=new u(this,a.z(),a.w())}j=t.prototype;
|
||||
j.q=function(a){var b;a:if(this.a.indexOf)b=this.a.indexOf(a)!=-1;else{b=0;for(var c;c=this.a[b];b++)if(c==a){b=!0;break a}b=!1}if(b)return!1;if(this.d){if(this.r)c=this.a.length+1,b=(this.d.lat()*(c-1)+a.getPosition().lat())/c,c=(this.d.lng()*(c-1)+a.getPosition().lng())/c,this.d=new google.maps.LatLng(b,c),y(this)}else this.d=a.getPosition(),y(this);a.s=!0;this.a.push(a);b=this.a.length;b<this.l&&a.getMap()!=this.b&&a.setMap(this.b);if(b==this.l)for(c=0;c<b;c++)this.a[c].setMap(d);b>=this.l&&a.setMap(d);
|
||||
if(this.b.getZoom()>this.k.I())for(a=0;b=this.a[a];a++)b.setMap(this.b);else if(this.a.length<this.l)z(this.n);else{b=this.k.H()(this.a,this.k.z().length);this.n.setCenter(this.d);a=this.n;a.B=b;a.ga=b.text;a.ea=b.index;if(a.c)a.c.innerHTML=b.text;b=Math.max(0,a.B.index-1);b=Math.min(a.j.length-1,b);b=a.j[b];a.da=b.url;a.h=b.height;a.p=b.width;a.M=b.textColor;a.e=b.anchor;a.N=b.textSize;a.D=b.backgroundPosition;this.n.show()}return!0};
|
||||
j.getBounds=function(){for(var a=new google.maps.LatLngBounds(this.d,this.d),b=this.o(),c=0,f;f=b[c];c++)a.extend(f.getPosition());return a};j.remove=function(){this.n.remove();this.a.length=0;delete this.a};j.T=function(){return this.a.length};j.o=i("a");j.getCenter=i("d");function y(a){a.F=a.k.v(new google.maps.LatLngBounds(a.d,a.d))}j.getMap=i("b");
|
||||
function u(a,b,c){a.k.extend(u,google.maps.OverlayView);this.j=b;this.fa=c||0;this.u=a;this.d=d;this.b=a.getMap();this.B=this.c=d;this.t=!1;this.setMap(this.b)}j=u.prototype;
|
||||
j.onAdd=function(){this.c=document.createElement("DIV");if(this.t)this.c.style.cssText=A(this,B(this,this.d)),this.c.innerHTML=this.B.text;this.getPanes().overlayMouseTarget.appendChild(this.c);var a=this;google.maps.event.addDomListener(this.c,"click",function(){var b=a.u.k;google.maps.event.trigger(b,"clusterclick",a.u);b.O&&a.b.fitBounds(a.u.getBounds())})};function B(a,b){var c=a.getProjection().fromLatLngToDivPixel(b);c.x-=parseInt(a.p/2,10);c.y-=parseInt(a.h/2,10);return c}
|
||||
j.draw=function(){if(this.t){var a=B(this,this.d);this.c.style.top=a.y+"px";this.c.style.left=a.x+"px"}};function z(a){if(a.c)a.c.style.display="none";a.t=!1}j.show=function(){if(this.c)this.c.style.cssText=A(this,B(this,this.d)),this.c.style.display="";this.t=!0};j.remove=function(){this.setMap(d)};j.onRemove=function(){if(this.c&&this.c.parentNode)z(this),this.c.parentNode.removeChild(this.c),this.c=d};j.setCenter=e("d");
|
||||
function A(a,b){var c=[];c.push("background-image:url("+a.da+");");c.push("background-position:"+(a.D?a.D:"0 0")+";");typeof a.e==="object"?(typeof a.e[0]==="number"&&a.e[0]>0&&a.e[0]<a.h?c.push("height:"+(a.h-a.e[0])+"px; padding-top:"+a.e[0]+"px;"):c.push("height:"+a.h+"px; line-height:"+a.h+"px;"),typeof a.e[1]==="number"&&a.e[1]>0&&a.e[1]<a.p?c.push("width:"+(a.p-a.e[1])+"px; padding-left:"+a.e[1]+"px;"):c.push("width:"+a.p+"px; text-align:center;")):c.push("height:"+a.h+"px; line-height:"+a.h+
|
||||
"px; width:"+a.p+"px; text-align:center;");c.push("cursor:pointer; top:"+b.y+"px; left:"+b.x+"px; color:"+(a.M?a.M:"black")+"; position:absolute; font-size:"+(a.N?a.N:11)+"px; font-family:Arial,sans-serif; font-weight:bold");return c.join("")}window.MarkerClusterer=k;k.prototype.addMarker=k.prototype.q;k.prototype.addMarkers=k.prototype.C;k.prototype.clearMarkers=k.prototype.R;k.prototype.fitMapToMarkers=k.prototype.S;k.prototype.getCalculator=k.prototype.H;k.prototype.getGridSize=k.prototype.w;
|
||||
k.prototype.getExtendedBounds=k.prototype.v;k.prototype.getMap=k.prototype.getMap;k.prototype.getMarkers=k.prototype.o;k.prototype.getMaxZoom=k.prototype.I;k.prototype.getStyles=k.prototype.z;k.prototype.getTotalClusters=k.prototype.U;k.prototype.getTotalMarkers=k.prototype.V;k.prototype.redraw=k.prototype.i;k.prototype.removeMarker=k.prototype.Y;k.prototype.removeMarkers=k.prototype.Z;k.prototype.resetViewport=k.prototype.m;k.prototype.repaint=k.prototype.L;k.prototype.setCalculator=k.prototype.$;
|
||||
k.prototype.setGridSize=k.prototype.aa;k.prototype.setMaxZoom=k.prototype.ba;k.prototype.onAdd=k.prototype.onAdd;k.prototype.draw=k.prototype.draw;t.prototype.getCenter=t.prototype.getCenter;t.prototype.getSize=t.prototype.T;t.prototype.getMarkers=t.prototype.o;u.prototype.onAdd=u.prototype.onAdd;u.prototype.draw=u.prototype.draw;u.prototype.onRemove=u.prototype.onRemove;
|
||||
})();
|
||||
@@ -0,0 +1,84 @@
|
||||
function initialize(pt) {
|
||||
var center = new google.maps.LatLng(10.91, 5.38);
|
||||
var Geocoder = new google.maps.Geocoder();
|
||||
|
||||
var map = new google.maps.Map(document.getElementById('map'), {
|
||||
zoom: 1,
|
||||
center: center,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
});
|
||||
|
||||
var infoWindow = new google.maps.InfoWindow();
|
||||
|
||||
google.maps.event.addListener(map, 'click', function() {
|
||||
infoWindow.close();
|
||||
});
|
||||
|
||||
var partners = new google.maps.MarkerImage("/website_crm/static/src/img/partners.png",new google.maps.Size(25, 25));
|
||||
|
||||
var markers = [];
|
||||
|
||||
var onMarkerClick = function() {
|
||||
var marker = this;
|
||||
var p = marker.partner;
|
||||
infoWindow.setContent(
|
||||
'<div class="marker">'+
|
||||
(partner_url.length ? '<a target="_top" href="'+partner_url+p.id+'"><b>'+p.name +'</b></a>' : '<b>'+p.name+'</b>' )+ '<br/>'+
|
||||
(p.type ? ' <b>' + p.type + '</b>' : '')+
|
||||
' <pre>' + p.address + '</pre>'+
|
||||
'</div>'
|
||||
);
|
||||
infoWindow.open(map, marker);
|
||||
};
|
||||
|
||||
var set_marker = function(partner) {
|
||||
if (!partner.latitude && !partner.longitude) {
|
||||
|
||||
Geocoder.geocode( { 'address': partner.address}, function(results, status) {
|
||||
if (status == google.maps.GeocoderStatus.OK) {
|
||||
var location = results[0].geometry.location;
|
||||
|
||||
$.post("/worldmap/set_partner_position/", {
|
||||
'partner_id': partner.id,
|
||||
'latitude': location.ob,
|
||||
'longitude': location.pb
|
||||
});
|
||||
partner.latitude = location.ob;
|
||||
partner.longitude = location.pb;
|
||||
|
||||
map.setCenter(results[0].geometry.location);
|
||||
var marker = new google.maps.Marker({
|
||||
partner: partner,
|
||||
map: map,
|
||||
icon: partners,
|
||||
position: location
|
||||
});
|
||||
google.maps.event.addListener(marker, 'click', onMarkerClick);
|
||||
markers.push(marker);
|
||||
} else {
|
||||
console.debug('Geocode was not successful for the following reason: ' + status);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
var latLng = new google.maps.LatLng(partner.latitude, partner.longitude);
|
||||
var marker = new google.maps.Marker({
|
||||
partner: partner,
|
||||
icon: partners,
|
||||
position: latLng
|
||||
});
|
||||
google.maps.event.addListener(marker, 'click', onMarkerClick);
|
||||
markers.push(marker);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if (data)
|
||||
for (var i = 0; i < data.counter; i++) {
|
||||
set_marker(data.partners[i]);
|
||||
}
|
||||
var markerCluster = new MarkerClusterer(map, markers);
|
||||
}
|
||||
google.maps.event.addDomListener(window, 'load', initialize);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="worldmap">
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title>World wide map</title>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: Helvetica, Arial, sans-serif !important;
|
||||
}
|
||||
.marker {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
.marker b {
|
||||
font-weight: 500;
|
||||
}
|
||||
.marker pre {
|
||||
font-size: 10px !important;
|
||||
}
|
||||
</style>
|
||||
<script>var partner_url = '<t t-raw="partner_url or ''"/>';</script>
|
||||
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
|
||||
<script type="text/javascript" t-attf-src="/worldmap/partners.json?partner_ids=#{ partner_ids }"></script>
|
||||
<script type="text/javascript" src="/website_crm_partner_assign/static/src/js/markerclusterer_compiled.js"></script>
|
||||
<script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
|
||||
<script type="text/javascript" src="/website_crm_partner_assign/static/src/js/worldmap.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" t-attf-style="width: #{ width }px; height: #{ height }px"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
class res_partner(osv.osv):
|
||||
_inherit = 'res.partner'
|
||||
_columns = {
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
}
|
||||
@@ -27,6 +27,9 @@ class mail_message(osv.osv):
|
||||
_columns = {
|
||||
'website_published': fields.boolean('Publish', help="Publish on the website as a blog"),
|
||||
}
|
||||
_defaults = {
|
||||
'website_published': lambda *args: True
|
||||
}
|
||||
|
||||
|
||||
class mail_group(osv.Model):
|
||||
|
||||
@@ -36,6 +36,9 @@ class product_template(osv.osv):
|
||||
'suggested_product_id': fields.many2one('product.product', 'Suggested For Product'),
|
||||
'suggested_product_ids': fields.one2many('product.product', 'suggested_product_id', 'Suggested Products'),
|
||||
}
|
||||
_defaults = {
|
||||
'website_published': lambda *args: True
|
||||
}
|
||||
|
||||
def recommended_products(self, cr, uid, ids, context=None):
|
||||
id = ids[0]
|
||||
|
||||
Reference in New Issue
Block a user