[IMP] mass_mailing: move code from website_mail to mass_mailing and use web_editor

This commit is contained in:
Christophe Matthieu
2015-07-10 17:00:12 +02:00
parent 9665882fba
commit 05daa152dc
68 changed files with 349 additions and 770 deletions
+13 -2
View File
@@ -17,7 +17,6 @@ professional emails and reuse templates in a few clicks.
'mail',
'marketing',
'web_kanban_gauge',
'website_mail',
'website_links',
'utm',
],
@@ -31,10 +30,22 @@ professional emails and reuse templates in a few clicks.
'views/res_config.xml',
'views/email_template.xml',
'views/website_mass_mailing.xml',
'views/snippets.xml',
'security/ir.model.access.csv',
'views/mass_mailing.xml',
'views/unsubscribe.xml',
'views/snippets.xml',
'views/editor_field_html.xml',
'views/snippets_themes.xml',
'views/snippets_themes_options.xml',
'views/theme_list.xml',
'views/theme/neopolitan_snippets.xml',
'views/theme/skyline_snippets.xml',
'views/theme/narrative_snippets.xml',
'views/theme/sunday_snippets.xml',
'views/theme/go_snippets.xml',
'views/theme/airmail_snippets.xml',
'views/theme/zenflat_snippets.xml',
'views/theme/cleave_snippets.xml',
],
'qweb': [],
'demo': [
+1 -1
View File
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
import main
import website
import web_editor
+5 -5
View File
@@ -19,7 +19,7 @@ class MassMailController(http.Controller):
return response
@http.route(['/mail/mailing/<int:mailing_id>/unsubscribe'], type='http', auth='none', website=True)
@http.route(['/mail/mailing/<int:mailing_id>/unsubscribe'], type='http', website=True, auth='none')
def mailing(self, mailing_id, email=None, res_id=None, **post):
mailing = request.env['mail.mass_mailing'].sudo().browse(mailing_id)
if mailing.exists():
@@ -30,14 +30,14 @@ class MassMailController(http.Controller):
mailing.update_opt_out(mailing_id, email, [res_id], True)
return request.website.render('mass_mailing.page_unsubscribed')
@http.route(['/mail/mailing/unsubscribe'], type='json', auth='none', website=True)
@http.route(['/mail/mailing/unsubscribe'], type='json', auth='none')
def unsubscribe(self, mailing_id, opt_in_ids, opt_out_ids, email):
mailing = request.env['mail.mass_mailing'].sudo().browse(mailing_id)
if mailing.exists():
mailing.update_opt_out(mailing_id, email, opt_in_ids, False)
mailing.update_opt_out(mailing_id, email, opt_out_ids, True)
@http.route('/website_mass_mailing/is_subscriber', type='json', auth="public", website=True)
@http.route('/website_mass_mailing/is_subscriber', type='json', website=True, auth="public")
def is_subscriber(self, list_id, **post):
cr, uid, context = request.cr, request.uid, request.context
Contacts = request.registry['mail.mass_mailing.contact']
@@ -56,7 +56,7 @@ class MassMailController(http.Controller):
return {'is_subscriber': is_subscriber, 'email': email}
@http.route('/website_mass_mailing/subscribe', type='json', auth="public", website=True)
@http.route('/website_mass_mailing/subscribe', type='json', auth="public")
def subscribe(self, list_id, email, **post):
cr, uid, context = request.cr, request.uid, request.context
Contacts = request.registry['mail.mass_mailing.contact']
@@ -77,7 +77,7 @@ class MassMailController(http.Controller):
request.registry['website.links.click'].add_click(cr, uid, code, request.httprequest.remote_addr, request.session['geoip'].get('country_code'), stat_id=stat_id, context=context)
return werkzeug.utils.redirect(request.registry['website.links'].get_url_from_code(cr, uid, code, context=context), 301)
@http.route(['/website_mass_mailing/get_content'], type='json', auth="public", website=True)
@http.route(['/website_mass_mailing/get_content'], type='json', auth="public")
def get_mass_mailing_content(self, newsletter_id, **post):
data = self.is_subscriber(newsletter_id, **post)
mass_mailing_list = request.registry['mail.mass_mailing.list'].browse(request.cr, SUPERUSER_ID, int(newsletter_id), request.context)
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from openerp import http
from openerp.http import request
from openerp.addons.web_editor.controllers.main import Web_Editor
class Web_Editor(Web_Editor):
@http.route(["/website_mass_mailing/field/popup_content"], type='http', auth="user")
def mass_mailing_FieldTextHtmlPopupTemplate(self, model=None, res_id=None, field=None, callback=None, **kwargs):
kwargs['snippets'] = '/website/snippets'
kwargs['template'] = 'mass_mailing.FieldTextHtmlPopupContent'
return self.FieldTextHtml(model, res_id, field, callback, **kwargs)
@http.route('/mass_mailing/field/email_template', type='http', auth="user")
def mass_mailing_FieldTextHtmlEmailTemplate(self, model=None, res_id=None, field=None, callback=None, **kwargs):
kwargs['snippets'] = '/mass_mailing/snippets'
kwargs['template'] = 'mass_mailing.FieldTextHtmlInline'
return self.FieldTextHtmlInline(model, res_id, field, callback, **kwargs)
@http.route(['/mass_mailing/snippets'], type='json', auth="user", website=True)
def mass_mailing_snippets(self):
return request.registry["ir.ui.view"].render(request.cr, request.uid, 'mass_mailing.email_designer_snippets', None, context=request.context)
@@ -1,14 +0,0 @@
# -*- coding: utf-8 -*-
from openerp import http
from openerp.addons.website.controllers.main import Website
class Website(Website):
@http.route(["/website_mass_mailing/field/popup_content"], type='http', auth="public", website=True)
def FieldTextHtmlPopupTemplate(self, model=None, res_id=None, field=None, callback=None, **kwargs):
kwargs['snippets'] = 'snippets' not in kwargs and '/website/snippets' or kwargs['snippets']
kwargs['dont_load_assets'] = False
kwargs['template'] = "mass_mailing.FieldTextHtmlPopupContent"
return self.FieldTextHtml(model, res_id, field, callback, **kwargs)
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -479,7 +479,7 @@ class MassMailing(osv.Model):
'create_date': fields.datetime('Creation Date'),
'sent_date': fields.datetime('Sent Date', oldname='date', copy=False),
'schedule_date': fields.datetime('Schedule in the Future'),
'body_html': fields.html('Body'),
'body_html': fields.html('Body', translate=True),
'attachment_ids': fields.many2many(
'ir.attachment', 'mass_mailing_ir_attachments_rel',
'mass_mailing_id', 'attachment_id', 'Attachments'
@@ -1,55 +1,3 @@
body {
background-color: #fff;
}
p {
margin: initial;
}
a {
color: inherit;
}
a:hover {
color: inherit;
}
#wrapwrap .o_editable {
font: initial;
line-height: initial;
color: initial;
}
#oe_snippets ~ #wrapwrap .o_editable {
margin-bottom: 100px;
}
#wrapwrap > main > div:first-child {
max-width: 600px;
margin-left: auto;
margin-right: auto;
position: relative;
}
.editor_enable #wrapwrap > main > div:first-child:before, #wrapwrap > main > div:first-child:after {
content: " ";
display: block;
height: 100%;
position: fixed;
top: -4px;
width: 0;
overflow: hidden;
}
.editor_enable #wrapwrap > main > div:first-child:before {
border-right: 1px dashed #ccc;
margin-left: -5px;
}
.editor_enable #wrapwrap > main > div:first-child:after {
border-left: 1px dashed #ccc;
margin-left: 605px;
}
.note-color-palette .colorpicker {
display: none;
}
/***************************/
#email_theme_list, #email_template_list {
clear: both;
text-align: center;
@@ -128,17 +76,21 @@ a:hover {
/***************************/
#templates{
margin-top: 50px;
width: 98%;
}
#choose_template{
display: none;
margin: 5px;
padding: 1px 5px;
position: fixed;
top: 0;
right: 50px;
right: 28px;
z-index: 2000;
}
#choose_template span{
padding: 1px 5px;
height: 24px;
}
#templates .template_preview_border{
overflow: hidden !important;
border: 2px solid grey;
@@ -161,4 +113,4 @@ a:hover {
}
.theme_thumbnail:hover>.template_preview{
opacity:0.3;
}
}
@@ -1,85 +1,85 @@
/* ---- thumbnail ---- */
.oe_snippet.o_mail_block_header_center_logo .oe_snippet_thumbnail_img {
background-image: url("/website_mail/static/src/img/blocks/block_header_center_logo.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_header_center_logo.png");
}
.oe_snippet.o_mail_block_header_center_text .oe_snippet_thumbnail_img {
background-image: url("/website_mail/static/src/img/blocks/block_header_center_text.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_header_center_text.png");
}
.oe_snippet.o_mail_block_header_social .oe_snippet_thumbnail_img {
background-image: url("/website_mail/static/src/img/blocks/block_header_social.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_header_social.png");
}
.oe_snippet.o_mail_block_header_text_social .oe_snippet_thumbnail_img {
background-image: url("/website_mail/static/src/img/blocks/block_header_text_social.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_header_text_social.png");
}
.oe_snippet.o_mail_block_text_image .oe_snippet_thumbnail_img {
background-image: url("/website/static/src/img/blocks/block_text_image.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_text-image.png");
}
.oe_snippet.o_mail_block_footer_copyright .oe_snippet_thumbnail_img {
background-image: url("/website_mail/static/src/img/blocks/block_footer_copyright.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_footer_copyright.png");
}
.oe_snippet.o_mail_block_footer_social .oe_snippet_thumbnail_img {
background-image: url("/website_mail/static/src/img/blocks/block_footer_social.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_footer_social.png");
}
.oe_snippet.o_mail_block_footer_text .oe_snippet_thumbnail_img {
background-image: url("/website_mail/static/src/img/blocks/block_footer_text.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_footer_text.png");
}
.oe_snippet.o_mail_block_footer_seprator .oe_snippet_thumbnail_img {
background-image: url("/website_mail/static/src/img/blocks/block_footer_seprator.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_footer_seprator.png");
}
.oe_snippet.o_mail_block_footer_tag_line .oe_snippet_thumbnail_img {
background-image: url("/website_mail/static/src/img/blocks/block_footer_tag_line.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_footer_tag_line.png");
}
.oe_snippet.o_mail_block_two_cols .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_two-column-img.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_two-column-img.png");
}
.oe_snippet.o_mail_block_two_cols_content .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_two-column.png");
background-image: url("/mass_mailing/static/src/img/blocks/block_two-column.png");
}
.oe_snippet.o_mail_block_title_text .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_title_text.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_title_text.png")
}
.oe_snippet.o_mail_block_title_sub .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_title.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_title.png")
}
.oe_snippet.o_mail_block_image_text .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_image-text.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_image-text.png")
}
.oe_snippet.o_mail_block_text_button .oe_snippet_thumbnail_img{
background-image: url("/website/static/src/img/blocks/block_jumbotron.png")
}
.oe_snippet.o_mail_block_table_content .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_table.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_table.png")
}
.oe_snippet.o_mail_block_discount1 .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_discount.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_discount.png")
}
.oe_snippet.o_mail_block_discount2 .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_discount2.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_discount2.png")
}
.oe_snippet.o_mail_block_event .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_event.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_event.png")
}
.oe_snippet.o_mail_block_image .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_image_text.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_image_text.png")
}
.oe_snippet.o_mail_block_profile .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_user.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_user.png")
}
.oe_snippet.o_mail_block_four_cols .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_four_columns.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_four_columns.png")
}
.oe_snippet.o_mail_block_button .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_button.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_button.png")
}
.oe_snippet.o_mail_block_simple_text .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_simple_text.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_simple_text.png")
}
.oe_snippet.o_mail_block_three_cols .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_three_columns.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_three_columns.png")
}
.oe_snippet.o_mail_block_text_on_img .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_text_on_image.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_text_on_image.png")
}
.oe_snippet.o_mail_block_steps .oe_snippet_thumbnail_img{
background-image: url("/website_mail/static/src/img/blocks/block_steps.png")
background-image: url("/mass_mailing/static/src/img/blocks/block_steps.png")
}
@@ -1,7 +1,7 @@
/* Summernote not Support for placeholder text https://github.com/summernote/summernote/issues/581 */
.editor_enable [data-oe-placeholder]:empty:not(:focus):before {
content: attr(data-oe-placeholder);
opacity: 0.3;
content: " \00a0 " attr(data-oe-placeholder);
opacity: 0.4;
}
.o_popup_animated {
-webkit-animation-duration: 1s;

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 974 B

Before

Width:  |  Height:  |  Size: 549 B

After

Width:  |  Height:  |  Size: 549 B

Before

Width:  |  Height:  |  Size: 310 B

After

Width:  |  Height:  |  Size: 310 B

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 312 B

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 322 B

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 595 B

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 308 B

Before

Width:  |  Height:  |  Size: 535 B

After

Width:  |  Height:  |  Size: 535 B

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

Before

Width:  |  Height:  |  Size: 548 B

After

Width:  |  Height:  |  Size: 548 B

Before

Width:  |  Height:  |  Size: 760 B

After

Width:  |  Height:  |  Size: 760 B

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 329 B

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 999 B

After

Width:  |  Height:  |  Size: 999 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 308 B

Before

Width:  |  Height:  |  Size: 815 B

After

Width:  |  Height:  |  Size: 815 B

Before

Width:  |  Height:  |  Size: 949 B

After

Width:  |  Height:  |  Size: 949 B

Before

Width:  |  Height:  |  Size: 348 B

After

Width:  |  Height:  |  Size: 348 B

Before

Width:  |  Height:  |  Size: 686 B

After

Width:  |  Height:  |  Size: 686 B

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before

Width:  |  Height:  |  Size: 153 KiB

After

Width:  |  Height:  |  Size: 153 KiB

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 567 B

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 620 B

Before

Width:  |  Height:  |  Size: 993 B

After

Width:  |  Height:  |  Size: 993 B

Before

Width:  |  Height:  |  Size: 755 B

After

Width:  |  Height:  |  Size: 755 B

@@ -2,18 +2,19 @@ odoo.define('website_mail.website_mail', function (require) {
"use strict";
var Model = require('web.Model');
var editor = require('website.editor');
var snippets_editor = require('website.snippets.editor');
var rte = require('web_editor.rte');
var web_editor = require('web_editor.editor');
var options = require('web_editor.snippets.options');
var snippets_editor = require('web_editor.snippet.editor');
// Snippet option for resizing image and column width inline like excel
snippets_editor.options["width-x"] = snippets_editor.Option.extend({
options.registry["width-x"] = options.Class.extend({
start: function () {
this.container_width = 600;
var parent = this.$target.closest('[data-max-width]');
if( parent.length ){
this.container_width = parseInt(parent.attr('data-max-width'));
}
}
var self = this;
var offset, sib_offset, target_width, sib_width;
this.is_image = false;
@@ -58,7 +59,7 @@ snippets_editor.options["width-x"] = snippets_editor.Option.extend({
if (compass === 'image'){
self.change_width(event, self.$target, target_width, offset ,'plus');
}
};
}
var body_mouseup = function(){
$body.unbind('mousemove', body_mousemove);
$body.unbind('mouseup', body_mouseup);
@@ -89,7 +90,7 @@ snippets_editor.options["width-x"] = snippets_editor.Option.extend({
var self = this;
_.each($el.siblings(),function(sib){
max_width += self.get_int_width($(sib));
});
})
return this.container_width - max_width;
},
on_clone: function ($clone) {
@@ -99,7 +100,7 @@ snippets_editor.options["width-x"] = snippets_editor.Option.extend({
_.each($table.find('tbody>tr'),function(row){
var clone_selector = 'td:eq(' + clone_index + ')';
var $col_to_clone = $(row).find(clone_selector);
if($col_to_clone.length !== 0){
if($col_to_clone.length != 0){
$col_to_clone.after($col_to_clone.clone());
}
});
@@ -128,31 +129,22 @@ $.summernote.eventHandler.popover.update = function ($popover, oStyle, isAirMode
$("span.o_table_handler, div.note-table").remove();
};
editor.EditorBar.include({
web_editor.Class.include({
start: function () {
var self = this;
if (location.search.indexOf("enable_editor") !== -1) {
this.on('rte:ready', this, function () {
this.on('rte:start', this, function () {
$("#choose_template").off("click").on("click", _.bind(self.on_choose_template, self));
$(".theme_thumbnail [data-snippet-theme]").off("click").on("click", _.bind(self.on_set_snippet_theme, self));
$("#wrapwrap").on('click', function (event) {
if ($(event.target).is("#wrapwrap")) {
setTimeout(function () {
var node = $("#wrapwrap .o_editable:first *")
.filter(function () { return this.textContent.match(/\S|\u00A0/); })
.add($("#wrapwrap .o_editable:first"))
.last()[0];
$.summernote.core.range.create(node, $.summernote.core.dom.nodeLength(node)).select();
},0);
}
});
var $editable = $("#editable_area");
$editable.html($editable.prop("innerHTML").replace(/^<p[^>]*>\s*<\/p>$/, ''));
});
this.on("snippets:ready", this, _.bind(self.display_theme_from_html, self));
}
return this._super.apply(this, arguments);
},
display_theme_from_html: function () {
var theme = $("#wrapwrap .o_editable:first [data-snippet-theme]").data("snippet-theme");
var theme = $("#editable_area [data-snippet-theme]").data("snippet-theme");
if (theme) {
$("#choose_template").show();
this.set_snippet_theme(theme);
@@ -170,7 +162,7 @@ editor.EditorBar.include({
if (event) {
$("#choose_template").show();
}
var $editable = $("#wrapwrap .o_editable:first");
var $editable = $("#editable_area");
$(".o_table_handler").remove();
$editable.parent().add("#oe_snippets, #templates, .note-popover").toggleClass("hidden");
$("#choose_template").children().toggleClass("hidden");
@@ -178,7 +170,7 @@ editor.EditorBar.include({
$(window.top).trigger('resize');
},
on_set_snippet_template: function (event) {
var $editable = $("#wrapwrap .o_editable:first");
var $editable = $("#editable_area");
this.rte.historyRecordUndo($editable);
$editable.html( $(event.target).closest(".theme_thumbnail").find(".js_content").html() );
$editable.parent().add("#oe_snippets, #templates, .note-popover").toggleClass("hidden");
@@ -201,7 +193,7 @@ editor.EditorBar.include({
get_snippet_template: function (mailing_model) {
var self = this;
var domain = [['model', '=', mailing_model]];
new Model('mail.template').call('search_read', [domain]).then(function (datas) {
return new Model('mail.template').call('search_read', [domain]).then(function (datas) {
var $template = $("#templates > div:last").addClass("hidden");
var $tclone = $template.find("> div > div:first");
$tclone.siblings().remove();
@@ -221,193 +213,33 @@ editor.EditorBar.include({
}
});
var cache = {};
var rulesCache = [];
function getMatchedCSSRules(a) {
if(cache[a.tagName + "." +a.className]) {
return cache[a.tagName + "." +a.className];
}
if (!rulesCache.length) {
var sheets = document.styleSheets;
for(var i = 0; i < sheets.length; i++) {
var rules = sheets[i].rules || sheets[i].cssRules;
if (rules) {
for(var r = 0; r < rules.length; r++) {
var selectorText = rules[r].selectorText;
if (selectorText &&
rules[r].cssText &&
selectorText.indexOf(".") !== -1 &&
selectorText.indexOf(":hover") === -1 &&
selectorText.indexOf(":before") === -1 &&
selectorText.indexOf(":after") === -1 &&
selectorText.indexOf(":active") === -1 &&
selectorText.indexOf(":link") === -1 &&
selectorText.indexOf("::") === -1) {
var st = selectorText.split(/\s*,\s*/);
for (var k=0; k<st.length; k++) {
rulesCache.push({
'selector': st[k],
'style': rules[r].style,
'point': st[k].split(/\s+/).length
});
}
}
}
}
}
rulesCache.sort(function (a,b) {
return a.point-b.point;
});
}
var css = [];
a.matches = a.matches || a.webkitMatchesSelector || a.mozMatchesSelector || a.msMatchesSelector || a.oMatchesSelector;
for(var r = 0; r < rulesCache.length; r++) {
if (a.matches(rulesCache[r].selector)) {
var style = rulesCache[r].style;
if (style.parentRule) {
var style_obj = {};
for (var k=0, len=style.length; k<len; k++) {
style_obj[style[k]] = style[style[k]];
}
rulesCache[r].style = style = style_obj;
}
css.push(style);
}
}
var style = {};
_.each(css, function (v,k) {
_.each(v, function (v,k) {
if (!style[k] || style[k].indexOf('important') === -1 || v.indexOf('important') !== -1) {
style[k] = v;
}
});
});
return cache[a.tagName + "." +a.className] = style;
}
$.fn.bindFirst = function(name, fn) {
this.bind(name, fn);
var handlers = $._data($(this).get(0), 'events')[name.split('.')[0]];
var handler = handlers.pop();
handlers.splice(0, 0, handler);
};
snippets_editor.BuildingBlock.include({
start: function () {
var self = this;
this._super();
setTimeout(function () {
self.img_to_font();
self.style_to_class();
});
},
snippets_editor.Class.include({
_get_snippet_url: function () {
return snippets_url;
},
clean_for_save: function () {
this._super();
this.class_to_style();
this.font_to_img();
var $editable = $("#wrapwrap .o_editable:first");
var $editable = $("#editable_area");
var theme = ($("#o_left_bar .o_panel_body > div:not(.hidden)").attr("class") || "").replace(/^\s*|\s*o_mail_block[^\s]+\s*|\s*oe_snippet\s*|\s*ui-draggable\s*|\s*$/g, '');
var $theme = $("#wrapwrap .o_editable:first [data-snippet-theme]").removeAttr("data-snippet-theme").removeData("snippet-theme");
var $theme = $("#editable_area [data-snippet-theme]").removeAttr("data-snippet-theme").removeData("snippet-theme");
$editable.children().first().attr("data-snippet-theme", theme);
$editable.find(":hidden").remove();
$editable.find(":not(br):hidden").remove();
},
// convert font awsome into image
font_to_img: function () {
$("#wrapwrap .fa").each(function () {
var $font = $(this);
var content;
_.find(editor.fontIcons, function (font) {
return _.find(editor.getCssSelectors(font.parser), function (css) {
if ($font.is(css[0].replace(/::?before$/, ''))) {
content = css[1].match(/content:\s*['"](.)['"]/)[1];
return true;
}
});
});
if (content) {
var size = parseInt(parseFloat($font.css("font-size"))/parseFloat($font.parent().css("font-size")),10);
var src = _.str.sprintf('/website_mail/font_to_img/%s/%s/'+$font.width(), window.encodeURI(content), window.encodeURI($font.css("color")));
var $img = $("<img/>").attr("src", src)
.attr("data-class", $font.attr("class"))
.attr("style", $font.attr("style"))
.css({"height": size+"em"}).css("font-size", "");
$font.replaceWith($img);
} else {
$font.remove();
}
});
},
// convert image into font awsome
img_to_font: function () {
$("#wrapwrap img[src*='/website_mail/font_to_img/']").each(function () {
var $img = $(this);
var $font = $("<span/>").attr("class", $img.data("class")).attr("style", $img.attr("style")).css("height", "");
$img.replaceWith($font);
});
},
class_to_style: function () {
var $editable = $("#wrapwrap .o_editable:first");
var selector = _.map(rulesCache, function (a) { return a.selector;}).join(",");
$editable.find(selector).each(function () {
var $target = $(this);
var css = getMatchedCSSRules(this);
var style = $target.attr("style") || "";
_.each(css, function (v,k) {
if (style.indexOf(k) === -1) {
style = k+":"+v+";"+style;
}
});
$target.attr("style", style);
});
},
style_to_class: function () {
var $editable = $("#wrapwrap .o_editable:first");
getMatchedCSSRules($editable[0]);
var selector = _.map(rulesCache, function (a) { return a.selector;}).join(",");
var $c = $('<span/>').appendTo("body");
$editable.find(selector).each(function () {
var $target = $(this);
var css = getMatchedCSSRules(this);
var style = "";
_.each(css, function (v,k) {
if (style.indexOf(k) === -1) {
style = k+":"+v+";"+style;
}
});
css = $c.attr("style", style).attr("style").split(/\s*;\s*/);
style = $target.attr("style") || "";
_.each(css, function (v) {
style = style.replace(v, '');
});
$target.attr("style", style.replace(/;+(\s;)*/g, ';').replace(/^;/g, ''));
});
$c.remove();
}
});
window.top.odoo[callback+"_set_value"] = function (value, fields_values, field_name) {
var $editable = $("#wrapwrap .o_editable:first");
var editor_enable = $('body').hasClass('editor_enable');
var _set_value = window.top.odoo[callback+"_updown"];
window.top.odoo[callback+"_updown"] = function (value, fields_values, field_name) {
var $editable = $("#editable_area");
var _val = $editable.prop("innerHTML");
var editor_enable = $('body').hasClass('editor_enable');
value = value || "";
if(value !== _val) {
if(value !==_val) {
if (editor_enable) {
if (value !== fields_values[field_name]) {
editor.editor_bar.rte.historyRecordUndo($editable, true);
rte.history.recordUndo($editable);
}
editor.editor_bar.snippets.make_active(false);
snippets_editor.instance.make_active(false);
}
if (value.indexOf('on_change_model_and_list') === -1) {
@@ -415,11 +247,7 @@ window.top.odoo[callback+"_set_value"] = function (value, fields_values, field_n
$editable.html(value);
if (editor_enable) {
editor.editor_bar.snippets.img_to_font();
editor.editor_bar.snippets.style_to_class();
if (fields_values.mailing_model) {
editor.editor_bar.display_theme_from_html();
}
web_editor.editor_bar.display_theme_from_html();
if (value !== fields_values[field_name]) {
$editable.trigger("content_changed");
@@ -428,17 +256,12 @@ window.top.odoo[callback+"_set_value"] = function (value, fields_values, field_n
}
}
if (fields_values.mailing_model) {
editor.editor_bar.get_snippet_template(fields_values.mailing_model);
if (fields_values.mailing_model && web_editor.editor_bar) {
web_editor.editor_bar.get_snippet_template(fields_values.mailing_model);
if (value.indexOf('on_change_model_and_list') !== -1) {
window.top.odoo[callback+"_downup"](_val);
}
}
};
return {
getMatchedCSSRules: getMatchedCSSRules
};
});
@@ -1,65 +1,31 @@
odoo.define('website_mass_mailing.editor', function (require) {
'use strict';
var Model = require('web.Model');
var ajax = require('web.ajax');
var core = require('web.core');
var editor = require('website.editor');
var snippet_editor = require('website.snippet.editor');
var base = require('web_editor.base');
var web_editor = require('web_editor.editor');
var options = require('web_editor.snippets.options');
var snippet_editor = require('web_editor.snippet.editor');
var website = require('website.website');
var _t = core._t;
snippet_editor.options.mailing_list_subscribe = snippet_editor.Option.extend({
choose_mailing_list: function (type, value) {
var self = this;
if (type !== "click") return;
return website.prompt({
id: "editor_new_mailing_list_subscribe_button",
window_title: _t("Add a Newsletter Subscribe Button"),
select: _t("Newsletter"),
init: function (field) {
return website.session.model('mail.mass_mailing.list')
.call('name_search', ['', []], { context: website.get_context() });
},
}).then(function (mailing_list_id) {
self.$target.attr("data-list-id", mailing_list_id);
});
},
drop_and_build_snippet: function() {
var self = this;
this._super();
this.choose_mailing_list('click').fail(function () {
self.editor.on_remove($.Event( "click" ));
});
},
clean_for_save: function () {
this.$target.addClass("hidden");
},
});
website.snippet.options.newsletter_popup = website.snippet.Option.extend({
select_mailing_list: function (type) {
var mass_mailing_common = options.Class.extend({
popup_template_id: "editor_new_mailing_list_subscribe_button",
popup_title: _t("Add a Newsletter Subscribe Button"),
select_mailing_list: function (type, value) {
var self = this;
if (type !== "click") return;
return website.prompt({
id: "editor_new_mailing_list_subscribe_popup",
window_title: _t("Add a Newsletter Subscribe Popup"),
select: _t("Newsletter"),
init: function () {
return website.session.model('mail.mass_mailing.list')
.call('name_search', [], { context: website.get_context() });
'id': this.popup_template_id,
'window_title': this.popup_title,
'select': _t("Newsletter"),
'init': function (field) {
return new Model('mail.mass_mailing.list').call('name_search', ['', []], { context: base.get_context() });
},
}).then(function (mailing_list_id) {
ajax.jsonRpc('/web/dataset/call', 'call', {
model: 'mail.mass_mailing.list',
method: 'read',
args: [[parseInt(mailing_list_id)], ['popup_content'], website.get_context()],
}).then(function (data) {
self.$target.find(".o_popup_content_dev").empty();
if (data && data[0].popup_content) {
$(data[0].popup_content).appendTo(self.$target.find(".o_popup_content_dev"));
}
});
self.$target.attr("data-list-id", mailing_list_id);
});
},
@@ -72,7 +38,32 @@ website.snippet.options.newsletter_popup = website.snippet.Option.extend({
},
});
editor.EditorBar.include({
options.registry.mailing_list_subscribe = mass_mailing_common.extend({
clean_for_save: function () {
this.$target.addClass("hidden");
},
});
options.registry.newsletter_popup = mass_mailing_common.extend({
popup_template_id: "editor_new_mailing_list_subscribe_popup",
popup_title: _t("Add a Newsletter Subscribe Popup"),
select_mailing_list: function (type, value) {
return this._super(type, value).then(function (mailing_list_id) {
ajax.jsonRpc('/web/dataset/call', 'call', {
model: 'mail.mass_mailing.list',
method: 'read',
args: [[parseInt(mailing_list_id)], ['popup_content'], base.get_context()],
}).then(function (data) {
self.$target.find(".o_popup_content_dev").empty();
if (data && data[0].popup_content) {
$(data[0].popup_content).appendTo(self.$target.find(".o_popup_content_dev"));
}
});
});
},
});
web_editor.Class.include({
edit: function () {
this._super();
$('body').on('click','#edit_dialog',_.bind(this.edit_dialog, this.rte.editor));
@@ -84,7 +75,7 @@ editor.EditorBar.include({
$target.css("display", "none");
$('.o_popup_bounce_small').show();
if (!$target.find('.o_popup_content_dev').length) {
$target.find('.o_popup_modal_body').prepend($('<div class="o_popup_content_dev" data-oe-placeholder="Type Here ..."></div>'));
$target.find('.o_popup_modal_body').prepend($('<div class="o_popup_content_dev" data-oe-placeholder="' + _t("Type Here ...") + '"></div>'));
}
var content = $('#wrapwrap .o_popup_content_dev').html();
var newsletter_id = $target.parent().attr('data-list-id');
@@ -93,7 +84,7 @@ editor.EditorBar.include({
method: 'write',
args: [parseInt(newsletter_id),
{'popup_content':content},
website.get_context()],
base.get_context()],
});
}
return this._super();
@@ -3,10 +3,11 @@ odoo.define('mass_mailing.website_integration', function (require) {
var ajax = require('web.ajax');
var utils = require('web.utils');
var animation = require('website.snippets.animation');
var animation = require('web_editor.snippets.animation');
var website = require('website.website');
animation.registry.subscribe = animation.Animation.extend({
animation.registry.subscribe = animation.Class.extend({
selector: ".js_subscribe",
start: function (editable_mode) {
var self = this;
@@ -59,7 +60,7 @@ animation.registry.subscribe = animation.Animation.extend({
},
});
animation.registry.newsletter_popup = animation.Animation.extend({
animation.registry.newsletter_popup = animation.Class.extend({
selector: ".o_newsletter_popup",
start: function (editable_mode) {
var self = this;
@@ -96,11 +97,11 @@ animation.registry.newsletter_popup = animation.Animation.extend({
ajax.jsonRpc('/website_mass_mailing/subscribe', 'call', {
'list_id': self.$target.data('list-id'),
'email': $email.length ? $email.val() : false
}).then(function () {
}).then(function (subscribe) {
self.$target.find('#o_newsletter_popup').modal('hide');
$(document).off('mouseleave');
if (self.redirect_url) {
if (_.contains(self.redirect_url.split('/'), window.location.host) || self.redirect_url.indexOf('/')=== 0) {
if (_.contains(self.redirect_url.split('/'), window.location.host) || self.redirect_url.indexOf('/')== 0) {
window.location.href = self.redirect_url;
} else { window.open(self.redirect_url, '_blank'); }
}
@@ -136,12 +137,12 @@ website.if_dom_contains('div.o_unsubscribe_form', function() {
});
ajax.jsonRpc('/mail/mailing/unsubscribe', 'call', {'opt_in_ids': checked_ids, 'opt_out_ids': unchecked_ids, 'email': email, 'mailing_id': mailing_id})
.then(function() {
.then(function(result) {
$('.alert-info').html('Your changes has been saved.').removeClass('alert-info').addClass('alert-success');
})
.fail(function() {
$('.alert-info').html('You changes has not been saved, try again later.').removeClass('alert-info').addClass('alert-warning');
});
});
});
});
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Template Choice page -->
<template id="FieldTextHtmlInline" name="Editor layout">
<t t-set="head">
<t t-if="enable_editor">
<link rel="stylesheet" href="/mass_mailing/static/src/css/mass_mailing_editor.css" type="text/css"/>
<link rel="stylesheet" href="/mass_mailing/static/src/css/mass_mailing_editor_thumb.css" type="text/css"/>
<script type="text/javascript" src="/mass_mailing/static/src/js/mass_mailing_editor.js"></script>
</t>
</t>
<t t-set="add_html">
<t t-if="enable_editor">
<span id="choose_template" class="o_not_editable o_css_editor">
<span class="btn btn-primary">Theme</span>
<span class="btn btn-primary hidden">Cancel selection</span>
</span>
</t>
</t>
<t t-call="web_editor.layout">
<div>
<div t-if="not edit_translations" id="editable_area" class="o_editable" t-att-data-oe-model="model" t-att-data-oe-field="field" t-att-data-oe-id="res_id" data-oe-type="html"><t t-raw="content"/></div>
<div t-if="edit_translations" id="editable_area"><t t-raw="content"/></div>
</div>
<div id="templates" class="o_not_editable o_css_editor hidden" t-if="enable_editor">
<h1 class="page-header mt16 email_head panel-primary">
Select a theme
<button type="button" class="btn btn-sm btn-default info_popover fa fa-info-circle" data-toggle="popover" data-trigger="focus" title="Help" data-content="Here you can design your own template from scratch by selecting your favorite theme."></button>
</h1>
<t t-call="mass_mailing.mass_mail_theme_list"/>
<div class="hidden">
<h1 class="page-header mt16">
Choose a Template
</h1>
<div id="email_template_list">
<div class="hidden">
<div class="theme_thumbnail">
<div class="overlay text-center">
<p>template</p>
<a class="btn btn-primary btn-sm js_template_set"> Select </a>
</div>
<div class="template_preview js_content"/>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
</data>
</openerp>
+1 -1
View File
@@ -28,7 +28,7 @@
</group>
<notebook>
<page string="Body">
<field name="body_html" nolabel="1" options="{'editor_url': '/website_mail/field/email_template'}" widget="html_frame"/>
<field name="body_html" nolabel="1" widget="html_frame" options="{'editor_url': '/mass_mailing/field/email_template'}"/>
<field name="attachment_ids" widget="many2many_binary"/>
</page>
</notebook>
+2 -2
View File
@@ -264,7 +264,7 @@
</div>
<notebook>
<page string="Popup Content">
<field name="popup_content" options="{'editor_url': '/website_mass_mailing/field/popup_content'}" widget="html_frame"/>
<field name="popup_content" widget="html_frame" options="{'editor_url': '/website_mass_mailing/field/popup_content'}"/>
</page>
</notebook>
</sheet>
@@ -444,7 +444,7 @@
</group>
<notebook>
<page string="Mail Body">
<field name="body_html" options="{'editor_url': '/website_mail/field/email_template'}" widget="html_frame"/>
<field name="body_html" widget="html_frame" options="{'editor_url': '/mass_mailing/field/email_template'}"/>
<field name="attachment_ids" widget="many2many_binary" string="Attach a file"/>
</page>
<page string="Options">
+66 -66
View File
@@ -32,85 +32,85 @@
<div data-js='mailing_list_subscribe'
data-selector=".js_subscribe"
data-drop-near="p, h1, h2, h3, blockquote, .well, .panel">
<li data-choose_mailing_list=""><a>Change Newsletter</a></li>
<li data-select_mailing_list=""><a>Change Newsletter</a></li>
</div>
</xpath>
</template>
<template id="website_popup_snippet" name="popup snippet" inherit_id="website.snippets">
<xpath expr="//div[@id='snippet_feature']/div[@class='o_panel_body']" position="inside">
<div>
<div class="oe_snippet_thumbnail">
<img class="oe_snippet_thumbnail_img" src="/mass_mailing/static/src/img/blocks/bounce.png" />
<span class="oe_snippet_thumbnail_title">Newsletter Popup</span>
</div>
<template id="website_popup_snippet" name="popup snippet" inherit_id="website.snippets">
<xpath expr="//div[@id='snippet_feature']/div[@class='o_panel_body']" position="inside">
<div>
<div class="oe_snippet_thumbnail">
<img class="oe_snippet_thumbnail_img" src="/mass_mailing/static/src/img/blocks/bounce.png" />
<span class="oe_snippet_thumbnail_title">Newsletter Popup</span>
</div>
<div class="o_newsletter_popup" data-list-id="0">
<div class="alert alert-warning alert-dismissible fade in css_non_editable_mode_hidden o_not_editable" role="alert">
<strong>Newsletter Popup!</strong> The newsletter popup snippet effect is active on this page. Click <a id="edit_dialog" href="#">Here To Edit Dialog Content</a>
</div>
<div class="modal modal-dialog modal-md fade fade-custom" id="o_newsletter_popup" tabindex="-1" role="dialog">
<div class="modal-content o_popup_modal_content">
<a href="#" class="o_popup_btn_close o_not_editable" data-dismiss="modal">&amp;times;</a>
<div class="o_popup_modal_body text-center">
<div class="o_popup_content_dev" data-oe-placeholder="Type Here ..."/>
<div class="input-group o_not_editable o_popup_animated o_popup_bounce_del500ms o_popup_bounce_small" >
<input type="email" name="email" class="popup_subscribe_email form-control" placeholder="your email..." autofocus="autofocus"/>
<span class="input-group-btn">
<a href="#" class="btn btn-success popup_subscribe_btn">Subscribe</a>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="o_newsletter_popup" data-list-id="0">
<div class="alert alert-warning alert-dismissible fade in css_non_editable_mode_hidden o_not_editable" role="alert">
<strong>Newsletter Popup!</strong> The newsletter popup snippet effect is active on this page. Click <a id="edit_dialog" href="#">Here To Edit Dialog Content</a>
</div>
</xpath>
</template>
<template id="website_popup_options" name="Popup Options" inherit_id="website.snippet_options">
<xpath expr="//div" position="after">
<div data-js='newsletter_popup'
data-selector=".o_newsletter_popup"
data-drop-in=".oe_structure, [data-oe-type=html]">
<li data-select_mailing_list=""><a>Change Newsletter</a></li>
</div>
</xpath>
</template>
<template id="FieldTextHtmlPopupContent" name="Editor layout">
<t t-set="head">
<link rel="stylesheet" href="/website_mail/static/src/css/snippets.css" type="text/css"/>
<link rel="stylesheet" href="/mass_mailing/static/src/css/mass_mailing_popup.css" type="text/css"/>
<link rel="stylesheet" href="/website_mail/static/src/css/website_mail_iframe.css" type="text/css"/>
</t>
<t t-call="website.editor_layout">
<div class="modal-dialog modal-md show" id="o_newsletter_popup">
<div class="modal modal-dialog modal-md fade fade-custom" id="o_newsletter_popup" tabindex="-1" role="dialog">
<div class="modal-content o_popup_modal_content">
<a href="#" class="o_popup_btn_close o_not_editable" data-dismiss="modal">&amp;times;</a>
<div class="o_popup_modal_body text-center">
<div class="o_popup_content_dev">
<div class="o_editable" t-att-data-oe-model="model" t-att-data-oe-field="field" t-att-data-oe-id="res_id" data-oe-type="html">
<!-- Can be removed once default values are ok for the editor -->
<t t-raw="content">
<div class="o_popup_modal_header text-center">
<h3 class="o_popup_modal_title mt8">Odoo Presents</h3>
</div>
<div class="o_popup_message">
<font>7</font>
<strong>Business Hacks</strong>
<span> to<br/>boost your marketing</span>
</div>
<p class="o_message_paragraph">Join our Marketing newsletter and get <strong>this white paper instantly</strong></p>
</t>
</div>
<div class="o_popup_content_dev" data-oe-placeholder="Type Here ..."/>
<div class="input-group o_not_editable o_popup_animated o_popup_bounce_del500ms o_popup_bounce_small" >
<input type="email" name="email" class="popup_subscribe_email form-control" placeholder="your email..." autofocus="autofocus"/>
<span class="input-group-btn">
<a href="#" class="btn btn-success popup_subscribe_btn">Subscribe</a>
</span>
</div>
</div>
</div>
</div>
</t>
</template>
</div>
</div>
</xpath>
</template>
<template id="website_popup_options" name="Popup Options" inherit_id="website.snippet_options">
<xpath expr="//div" position="after">
<div data-js='newsletter_popup'
data-selector=".o_newsletter_popup"
data-drop-in=".oe_structure, [data-oe-type=html]">
<li data-select_mailing_list=""><a>Change Newsletter</a></li>
</div>
</xpath>
</template>
<template id="FieldTextHtmlPopupContent" name="Editor layout">
<t t-set="head">
<link rel="stylesheet" href="/mass_mailing/static/src/css/mass_mailing_editor.css" type="text/css"/>
<link rel="stylesheet" href="/mass_mailing/static/src/css/mass_mailing_editor_thumb.css" type="text/css"/>
<link rel="stylesheet" href="/mass_mailing/static/src/css/mass_mailing_popup.css" type="text/css"/>
</t>
<t t-call="web_editor.layout">
<div class="modal-dialog modal-md show" id="o_newsletter_popup">
<div class="modal-content o_popup_modal_content">
<div class="o_popup_modal_body text-center">
<div class="o_popup_content_dev">
<div class="o_editable" t-att-data-oe-model="model" t-att-data-oe-field="field" t-att-data-oe-id="res_id" data-oe-type="html">
<!-- Can be removed once default values are ok for the editor -->
<t t-raw="content">
<div class="o_popup_modal_header text-center">
<h3 class="o_popup_modal_title mt8">Odoo Presents</h3>
</div>
<div class="o_popup_message">
<font>7</font>
<strong>Business Hacks</strong>
<span> to<br/>boost your marketing</span>
</div>
<p class="o_message_paragraph">Join our Marketing newsletter and get <strong>this white paper instantly</strong></p>
</t>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
</data>
</openerp>
@@ -100,19 +100,19 @@
<table border="0" cellpadding="0" cellspacing="0" align="right" style="border-collapse:collapse;background:inherit;color:inherit">
<tr>
<td align="right">
<a t-att-href="(website.social_facebook) or '#'"><img src="/website_mail/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon"/></a>
<a t-att-href="(website.social_facebook) or '#'"><img src="/mass_mailing/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon"/></a>
</td>
<td align="right" style="padding-left:5px">
<a t-att-href="(website.social_twitter) or '#'"><img src="/website_mail/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon" /></a>
<a t-att-href="(website.social_twitter) or '#'"><img src="/mass_mailing/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon" /></a>
</td>
<td align="right" style="padding-left:5px">
<a t-att-href="(website.social_googleplus) or '#'"><img src="/website_mail/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon" /></a>
<a t-att-href="(website.social_googleplus) or '#'"><img src="/mass_mailing/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon" /></a>
</td>
<td align="right" style="padding-left:5px">
<a t-att-href="(website.social_linkedin) or '#'"><img src="/website_mail/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon" /></a>
<a t-att-href="(website.social_linkedin) or '#'"><img src="/mass_mailing/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon" /></a>
</td>
<td align="right" style="padding-left:5px">
<a href="#"><img src="/website_mail/static/src/img/theme_imgs/social_rss.png" style="height:auto;max-width:70px" alt="social icon" /></a>
<a href="#"><img src="/mass_mailing/static/src/img/theme_imgs/social_rss.png" style="height:auto;max-width:70px" alt="social icon" /></a>
</td>
</tr>
</table>
@@ -137,19 +137,19 @@
<table border="0" cellpadding="0" cellspacing="0" align="right" style="border-collapse:collapse;background:inherit;color:inherit">
<tr>
<td align="right">
<a t-att-href="(website.social_facebook) or '#'"><img src="/website_mail/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon" /></a>
<a t-att-href="(website.social_facebook) or '#'"><img src="/mass_mailing/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon" /></a>
</td>
<td align="right" style="padding-left:5px">
<a t-att-href="(website.social_twitter) or '#'"><img src="/website_mail/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon" /></a>
<a t-att-href="(website.social_twitter) or '#'"><img src="/mass_mailing/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon" /></a>
</td>
<td align="right" style="padding-left:5px">
<a t-att-href="(website.social_googleplus) or '#'"><img src="/website_mail/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon" /></a>
<a t-att-href="(website.social_googleplus) or '#'"><img src="/mass_mailing/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon" /></a>
</td>
<td align="right" style="padding-left:5px">
<a t-att-href="(website.social_linkedin) or '#'"><img src="/website_mail/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon" /></a>
<a t-att-href="(website.social_linkedin) or '#'"><img src="/mass_mailing/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon" /></a>
</td>
<td align="right" style="padding-left:5px">
<a href="#"><img src="/website_mail/static/src/img/theme_imgs/social_rss.png" style="height:auto;max-width:70px" alt="social icon" /></a>
<a href="#"><img src="/mass_mailing/static/src/img/theme_imgs/social_rss.png" style="height:auto;max-width:70px" alt="social icon" /></a>
</td>
</tr>
</table>
@@ -412,27 +412,27 @@
<td align="right">
&amp;nbsp;
<a t-att-href="(website.social_facebook) or '#'">
<img src="/website_mail/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon" />
</a>
</td>
<td align="right" style="padding-left:5px">
<a t-att-href="(website.social_twitter) or '#'">
<img src="/website_mail/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon" />
</a>
</td>
<td align="right" style="padding-left:5px">
<a t-att-href="(website.social_googleplus) or '#'">
<img src="/website_mail/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon" />
</a>
</td>
<td align="right" style="padding-left:5px">
<a t-att-href="(website.social_linkedin) or '#'">
<img src="/website_mail/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon" />
</a>
</td>
<td align="right" style="padding-left:5px">
<a href="#">
<img src="/website_mail/static/src/img/theme_imgs/social_rss.png" style="height:auto;max-width:70px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_rss.png" style="height:auto;max-width:70px" alt="social icon" />
</a>
&amp;nbsp;
</td>
@@ -496,7 +496,8 @@
</div>
<div id="snippet_options" class="hidden">
<t t-call="website_mail.snippet_options"/>
<t t-call="web_editor.snippet_options"/>
<t t-call="mass_mailing.snippet_options"/>
</div>
</template>
@@ -9,11 +9,6 @@
data-selector="img, .mv, .col_mv">
</div>
<div data-js='media'
data-selector="img:not(.cke_iframe)">
<li data-edition="edition"><a>Change Image ...</a></li>
</div>
<div data-js='table_row'
data-selector=".row"
data-drop-near=".row">
@@ -35,7 +30,6 @@
data-drop-in="[data-oe-field='body_html']">
</div>
<div data-js='resize'
data-selector="div.snippet_row"
data-drop-in=".oe_structure, [data-oe-type=html]">
@@ -5,7 +5,7 @@
<xpath expr="//div[@id='email_designer_default_headers']/div[2]" position="inside">
<div name="Center Logo" class="airmail o_mail_block_header_center_logo">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: #f9f8f8 repeat top /100%">
<div style=" width:600px; background-image: url('/website_mail/static/src/img/theme_imgs/airmail.png'); background-repeat: repeat-x; background-size: contain; height: 7px; background-position:-2% 0%; display:block"/>
<div style=" width:600px; background-image: url('/mass_mailing/static/src/img/theme_imgs/airmail.png'); background-repeat: repeat-x; background-size: contain; height: 7px; background-position:-2% 0%; display:block"/>
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;width:600px;">
<tbody>
<tr>
@@ -24,7 +24,7 @@
<div name="Center Text" class="airmail o_mail_block_header_center_text">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: #f9f8f8 repeat top /100%;color: #464646">
<div style=" width:600px; background-image: url('/website_mail/static/src/img/theme_imgs/airmail.png'); background-repeat: repeat-x; background-size: contain; height: 7px; background-position:-2% 0%; display:block"/>
<div style=" width:600px; background-image: url('/mass_mailing/static/src/img/theme_imgs/airmail.png'); background-repeat: repeat-x; background-size: contain; height: 7px; background-position:-2% 0%; display:block"/>
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;width:600px">
<tbody>
<tr>
@@ -43,7 +43,7 @@
<div name="Logo - Social" class="airmail o_mail_block_header_social">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: #f9f8f8 repeat top /100%;color: rgb(70,70,70)">
<div style=" width:600px; background-image: url('/website_mail/static/src/img/theme_imgs/airmail.png'); background-repeat: repeat-x; background-size: contain; height: 7px; background-position:-2% 0%; display:block"/>
<div style=" width:600px; background-image: url('/mass_mailing/static/src/img/theme_imgs/airmail.png'); background-repeat: repeat-x; background-size: contain; height: 7px; background-position:-2% 0%; display:block"/>
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;width:600px">
<tr>
<td width="100%" valign="top" style="font-size: 30px;padding-left:5px">
@@ -94,7 +94,7 @@
<div name="Text - Social" class="airmail o_mail_block_header_text_social">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: #f9f8f8 repeat top /100%;color:#464646">
<div style=" width:600px; background-image: url('/website_mail/static/src/img/theme_imgs/airmail.png'); background-repeat: repeat-x; background-size: contain; height: 7px;color: rgb(70,70,70); background-position:-2% 0%; display:block "/>
<div style=" width:600px; background-image: url('/mass_mailing/static/src/img/theme_imgs/airmail.png'); background-repeat: repeat-x; background-size: contain; height: 7px;color: rgb(70,70,70); background-position:-2% 0%; display:block "/>
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse">
<tr>
<td width="100%" valign="top" style="vertical-align: middle;padding-left:5px;font-size: 30px">
@@ -494,7 +494,7 @@
</div>
<div name="Background Image" class="airmail o_mail_block_text_on_img">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: url('/website_mail/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: url('/mass_mailing/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<table cellspacing="0" cellpadding="0" style="width:100%;border-collapse:collapse;color:inherit">
<tbody>
<tr>
@@ -478,7 +478,7 @@
</div>
<div name="Background Image" class="cleave o_mail_block_text_on_img">
<div class="snippet_row bg-color" style=" padding:0px;width:600px;margin:auto;background: url('/website_mail/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<div class="snippet_row bg-color" style=" padding:0px;width:600px;margin:auto;background: url('/mass_mailing/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<table cellspacing="0" cellpadding="0" style="width:100%;border-collapse:collapse;color:inherit">
<tbody>
<tr>
@@ -523,7 +523,7 @@
</div>
<div name="Background Image" class="go o_mail_block_text_on_img">
<div class="snippet_row bg-color" style=" padding:0px;width:600px;margin:auto;background: url('/website_mail/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<div class="snippet_row bg-color" style=" padding:0px;width:600px;margin:auto;background: url('/mass_mailing/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<table cellspacing="0" cellpadding="0" style="width:100%;border-collapse:collapse;color:inherit">
<tbody>
<tr>
@@ -56,28 +56,28 @@
<t t-if="website.social_facebook">
<td align="right">
<a t-att-href="website.social_facebook">
<img src="/website_mail/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon"/>
<img src="/mass_mailing/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon"/>
</a>
</td>
</t>
<t t-if="website.social_twitter">
<td align="right" style="padding-left:7px">
<a t-att-href="website.social_twitter">
<img src="/website_mail/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon"/>
<img src="/mass_mailing/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon"/>
</a>
</td>
</t>
<t t-if="website.social_googleplus">
<td align="right" style="padding-left:7px">
<a t-att-href="website.social_googleplus">
<img src="/website_mail/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon"/>
<img src="/mass_mailing/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon"/>
</a>
</td>
</t>
<t t-if="website.social_linkedin">
<td align="right" style="padding-left:7px">
<a t-att-href="website.social_linkedin">
<img src="/website_mail/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon"/>
<img src="/mass_mailing/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon"/>
</a>
</td>
</t>
@@ -106,28 +106,28 @@
<t t-if="website.social_facebook">
<td align="right">
<a t-att-href="website.social_facebook">
<img src="/website_mail/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px" alt="social icon" />
</a>
</td>
</t>
<t t-if="website.social_twitter">
<td align="right" style="padding-left:7px">
<a t-att-href="website.social_twitter">
<img src="/website_mail/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px" alt="social icon" />
</a>
</td>
</t>
<t t-if="website.social_googleplus">
<td align="right" style="padding-left:7px">
<a t-att-href="website.social_googleplus">
<img src="/website_mail/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon"/>
<img src="/mass_mailing/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px" alt="social icon"/>
</a>
</td>
</t>
<t t-if="website.social_linkedin">
<td align="right" style="padding-left:7px">
<a t-att-href="website.social_linkedin">
<img src="/website_mail/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon"/>
<img src="/mass_mailing/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px" alt="social icon"/>
</a>
</td>
</t>
@@ -495,7 +495,7 @@
</div>
<div name="Background Image" class="narrative o_mail_block_text_on_img">
<div class="snippet_row bg-color" style=" padding:0px;width:600px;margin:auto;background: url('/website_mail/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<div class="snippet_row bg-color" style=" padding:0px;width:600px;margin:auto;background: url('/mass_mailing/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<table cellspacing="0" cellpadding="0" style="width:100%;border-collapse:collapse;color:inherit">
<tbody>
<tr>
@@ -613,22 +613,22 @@
&amp;nbsp;
<t t-if="website.social_facebook">
<a t-att-href="website.social_facebook">
<img src="/website_mail/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px;padding-right:6px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_facebook.png" style="height:auto;max-width:70px;padding-right:6px" alt="social icon" />
</a>
</t>
<t t-if="website.social_googleplus">
<a t-att-href="website.social_googleplus">
<img src="/website_mail/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px;padding-right:6px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_twitter.png" style="height:auto;max-width:70px;padding-right:6px" alt="social icon" />
</a>
</t>
<t t-if="website.social_linkedin">
<a t-att-href="website.social_linkedin">
<img src="/website_mail/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px;padding-right:6px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_googleplus.png" style="height:auto;max-width:70px;padding-right:6px" alt="social icon" />
</a>
</t>
<t t-if="website.social_twitter">
<a t-att-href="website.social_twitter">
<img src="/website_mail/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px;padding-right:6px" alt="social icon" />
<img src="/mass_mailing/static/src/img/theme_imgs/social_linkedin.png" style="height:auto;max-width:70px;padding-right:6px" alt="social icon" />
</a>
</t>
&amp;nbsp;
@@ -462,7 +462,7 @@
</div>
<div name="Background Image" class="neopolitan o_mail_block_text_on_img">
<div class="snippet_row" style="padding:0px;width:600px;margin:auto;background:url('/website_mail/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<div class="snippet_row" style="padding:0px;width:600px;margin:auto;background:url('/mass_mailing/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<table cellspacing="0" cellpadding="0" style="width:100%;border-collapse:collapse;color:inherit">
<tbody>
<tr>
@@ -477,7 +477,7 @@
</div>
<div name="Background Image" class="skyline o_mail_block_text_on_img">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: url('/website_mail/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: url('/mass_mailing/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<table cellspacing="0" cellpadding="0" style="width:100%;border-collapse:collapse;color:inherit">
<tbody>
<tr>
@@ -478,7 +478,7 @@
</div>
<div name="Background Image" class="sunday o_mail_block_text_on_img">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: url('/website_mail/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: url('/mass_mailing/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<table cellspacing="0" cellpadding="0" style="width:100%;border-collapse:collapse;color:inherit">
<tbody>
<tr>
@@ -26,7 +26,7 @@
<table cellspacing="0" cellpadding="0" style="margin: 0 auto;border-collapse:collapse;width:600px">
<tbody>
<tr>
<td style="font-website_mail/font_to_img: 30px; text-align:center">
<td style="font-web_editor/font_to_img: 30px; text-align:center">
&amp;nbsp;
<a t-att-href="(website.company_id.website) or '#'" style="text-decoration:none;color:#008000">
<strong>Your Company</strong>
@@ -498,7 +498,7 @@
</div>
<div name="Background Image" class="zenflat o_mail_block_text_on_img">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: url('/website_mail/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<div class="snippet_row bg-color" style="padding:0px;width:600px;margin:auto;background: url('/mass_mailing/static/src/img/theme_imgs/skyline_bg.gif') top /cover;background-repeat:no-repeat;color:#fff">
<table cellspacing="0" cellpadding="0" style="width:600px;background:inherit;border-collapse:collapse;color:inherit">
<tbody>
<tr>
@@ -1,22 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_frontend" inherit_id="website.assets_frontend" name="wesbite_mass_mailing assets">
<xpath expr="." position="inside">
</xpath>
</template>
<template id="assets_frontend" inherit_id="website.assets_frontend" name="Mail Frontend Assets">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/css" href="/mass_mailing/static/src/css/mass_mailing_popup.css" />
<script type="text/javascript" src="/mass_mailing/static/src/js/website_mass_mailing.js"></script>
</xpath>
</template>
<script type="text/javascript" src="/mass_mailing/static/src/js/website_mass_mailing.js"></script>
</xpath>
</template>
<template id="assets_editor" inherit_id="website.assets_editor" name="wesbite_mass_mailing Editor assets">
<xpath expr="/t" position="inside">
<script type="text/javascript" src="/mass_mailing/static/src/js/website_mass_mailing.editor.js" groups="base.group_website_publisher"></script>
</xpath>
</template>
<template id="assets_editor" inherit_id="website.assets_editor" name="wesbite_mass_mailing Editor assets">
<xpath expr="/t" position="inside">
<script type="text/javascript" src="/mass_mailing/static/src/js/website_mass_mailing.editor.js" groups="base.group_website_publisher"></script>
</xpath>
</template>
</data>
</openerp>
-12
View File
@@ -10,19 +10,7 @@
'author': 'OpenERP SA',
'depends': ['website', 'mail'],
'data': [
'views/snippets.xml',
'views/website_mail.xml',
'views/website_email_designer.xml',
'views/snippet_options.xml',
'views/theme_list.xml',
'views/theme/neopolitan_snippets.xml',
'views/theme/skyline_snippets.xml',
'views/theme/narrative_snippets.xml',
'views/theme/sunday_snippets.xml',
'views/theme/go_snippets.xml',
'views/theme/airmail_snippets.xml',
'views/theme/zenflat_snippets.xml',
'views/theme/cleave_snippets.xml',
'data/mail_channels.xml',
],
'qweb': [
@@ -1,2 +1 @@
import email_designer
import main
@@ -1,96 +0,0 @@
# -*- coding: utf-8 -*-
import io
from PIL import Image, ImageFont, ImageDraw
import werkzeug.wrappers
from openerp import addons
from openerp.addons.web import http
from openerp.addons.web.http import request
import time
class WebsiteEmailDesigner(http.Controller):
@http.route(['/website_mail/snippets'], type='json', auth="user", website=True)
def snippets(self):
return request.website._render('website_mail.email_designer_snippets')
@http.route([
'/website_mail/font_to_img/<icon>',
'/website_mail/font_to_img/<icon>/<color>',
'/website_mail/font_to_img/<icon>/<color>/<int:size>',
'/website_mail/font_to_img/<icon>/<color>/<int:size>/<int:alpha>',
], auth="public", website=True)
def export_icon_to_png(self, icon, color='#000', size=100, alpha=255, font='/web/static/lib/fontawesome/fonts/fontawesome-webfont.ttf'):
""" This method converts FontAwesom pictograms to Images and is Used only
for mass mailing becuase custom fonts are not supported in mail.
:param icon : character from FontAwesom cheatsheet
:param color : RGB code of the color
:param size : Pixels in integer
:param alpha : transparency of the image from 0 to 255
:param font : font path
:returns PNG image converted from given font
"""
# Initialize font
addons_path = http.addons_manifest['web']['addons_path']
font_obj = ImageFont.truetype(addons_path + font, size)
# Determine the dimensions of the icon
image = Image.new("RGBA", (size, size), color=(0, 0, 0, 0))
draw = ImageDraw.Draw(image)
boxw, boxh = draw.textsize(icon, font=font_obj)
draw.text((0, 0), icon, font=font_obj)
left, top, right, bottom = image.getbbox()
# Create an alpha mask
imagemask = Image.new("L", (boxw, boxh), 0)
drawmask = ImageDraw.Draw(imagemask)
drawmask.text((-left, -top), icon, font=font_obj, fill=alpha)
# Create a solid color image and apply the mask
if color.startswith('rgba'):
color = color.replace('rgba', 'rgb')
color = ','.join(color.split(',')[:-1])+')'
iconimage = Image.new("RGBA", (boxw, boxh), color)
iconimage.putalpha(imagemask)
# Create output image
outimage = Image.new("RGBA", (boxw, size), (0, 0, 0, 0))
outimage.paste(iconimage, (left, top))
# output image
output = io.BytesIO()
outimage.save(output, format="PNG")
response = werkzeug.wrappers.Response()
response.mimetype = 'image/png'
response.data = output.getvalue()
response.headers['Cache-Control'] = 'public, max-age=604800'
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'GET, POST'
response.headers['Connection'] = 'close'
response.headers['Date'] = time.strftime("%a, %d-%b-%Y %T GMT", time.gmtime())
response.headers['Expires'] = time.strftime("%a, %d-%b-%Y %T GMT", time.gmtime(time.time()+604800*60))
return response
class Website(addons.website.controllers.main.Website):
#------------------------------------------------------
# Backend email template field
#------------------------------------------------------
@http.route('/website_mail/field/email', type='http', auth="public", website=True)
def FieldTextHtmlEmail(self, model=None, res_id=None, field=None, callback=None, **kwargs):
kwargs['template'] = "website_mail.FieldTextHtmlEmail"
return self.FieldTextHtml(model, res_id, field, callback, **kwargs)
@http.route('/website_mail/field/email_template', type='http', auth="public", website=True)
def FieldTextHtmlEmailTemplate(self, model=None, res_id=None, field=None, callback=None, **kwargs):
cr, uid, context = request.cr, request.uid, request.context
kwargs['theme'] = True
kwargs['snippets'] = 'snippets' not in kwargs and '/website_mail/snippets' or kwargs['snippets']
kwargs['dont_load_assets'] = not kwargs.get('enable_editor')
return self.FieldTextHtmlEmail(model, res_id, field, callback, **kwargs)
@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mail_wizard_invite_form" model="ir.ui.view">
<field name="name">Add Followers</field>
<field name="model">mail.wizard.invite</field>
<field name="inherit_id" ref="mail.mail_wizard_invite_form"/>
<field name="arch" type="xml">
<data>
<field name="message" position="attributes">
<attribute name="options">{'editor_url': '/website_mail/field/email'}</attribute>
</field>
</data>
</field>
</record>
<record id="email_compose_message_wizard_form" model="ir.ui.view">
<field name="name">mail.compose.message.form</field>
<field name="model">mail.compose.message</field>
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
<field name="arch" type="xml">
<data>
<field name="body" position="attributes">
<attribute name="options">{'editor_url': '/website_mail/field/email'}</attribute>
</field>
</data>
</field>
</record>
<!-- Template Choice page -->
<template id="FieldTextHtmlEmail" name="Editor layout">
<t t-set="head">
<t t-if="enable_editor">
<link rel="stylesheet" href="/website_mail/static/src/css/snippets.css" type="text/css"/>
<script type="text/javascript" src="/website_mail/static/src/js/website_email_designer.js"></script>
</t>
<link rel="stylesheet" href="/website_mail/static/src/css/website_mail_iframe.css" type="text/css"/>
</t>
<t t-set="add_html">
<t t-if="theme and enable_editor">
<span t-if="theme" id="choose_template" class="o_not_editable btn btn-primary"><span>Theme</span><span class="hidden">Cancel selection</span></span>
</t>
</t>
<t t-call="website.editor_layout">
<div>
<div class="o_editable" t-att-data-oe-model="model" t-att-data-oe-field="field" t-att-data-oe-id="res_id" data-oe-type="html"><t t-raw="content"/></div>
</div>
<div id="templates" class="o_not_editable hidden" t-if="theme and enable_editor">
<h1 class="page-header mt16 email_head panel-primary">
Select a theme
<button type="button" class="btn btn-sm btn-default info_popover fa fa-info-circle" data-toggle="popover" data-trigger="focus" title="Help" data-content="Here you can design your own template from scratch by selecting your favorite theme."></button>
</h1>
<t t-call="website_mail.mass_mail_theme_list"/>
<div class="hidden">
<h1 class="page-header mt16">
Choose a Template
</h1>
<div id="email_template_list">
<div class="hidden">
<div class="theme_thumbnail">
<div class="overlay text-center">
<p>template</p>
<a class="btn btn-primary btn-sm js_template_set"> Select </a>
</div>
<div class="template_preview js_content"/>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
</data>
</openerp>
@@ -23,7 +23,6 @@
<xpath expr="." position="inside">
<script type="text/javascript" src="/website_mail/static/src/js/follow.js"></script>
<link rel='stylesheet' href='/website_mail/static/src/css/website_mail.css'/>
<link rel='stylesheet' href='/website_mail/static/src/css/snippets.css'/>
</xpath>
</template>