Merge pull request #251 from odoo-dev/saas-4-follower-route-tde
[FIX] website_mail_group: discussion group snippet - moved into website_mail_group, instead of having the snippet in website_mail and the archives in website_mail_group - fixed routes to avoid security issues - better display of email on groups and archive
This commit is contained in:
commit
57c85a8b7a
|
@ -83,6 +83,7 @@ class WebsiteMail(http.Controller):
|
|||
'is_user': uid != public_id,
|
||||
'email': email,
|
||||
'is_follower': False,
|
||||
'alias_name': False,
|
||||
}
|
||||
|
||||
if not obj:
|
||||
|
@ -97,8 +98,5 @@ class WebsiteMail(http.Controller):
|
|||
('res_id', '=', obj_ids[0]),
|
||||
('partner_id', '=', partner_id.id)
|
||||
], context=context)) == 1
|
||||
if post.get('fields'):
|
||||
record = obj.read(cr, SUPERUSER_ID, obj_ids[0], fields=post.get('fields'), context=context)
|
||||
values.update(record)
|
||||
|
||||
return values
|
||||
|
|
|
@ -493,53 +493,5 @@
|
|||
|
||||
</template>
|
||||
|
||||
|
||||
<template id="subscribe" inherit_id="website.snippets" name="Snippet Subscribe">
|
||||
|
||||
<xpath expr="//div[@id='snippet_content']" position="inside">
|
||||
<div>
|
||||
<div class="oe_snippet_thumbnail">
|
||||
<img class="oe_snippet_thumbnail_img" src="/website_mail/static/src/img/blocks/button_group_subscribe.png"/>
|
||||
<span class="oe_snippet_thumbnail_title">Discussion Group</span>
|
||||
</div>
|
||||
|
||||
<div class="oe_snippet_body js_follow"
|
||||
data-id="0"
|
||||
data-object="mail.group"
|
||||
data-follow="off">
|
||||
<div class="input-group js_mg_follow_form">
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="js_follow_email form-control"
|
||||
placeholder="your email..."/>
|
||||
<span class="input-group-btn">
|
||||
<button href="#" class="btn btn-primary js_follow_btn">Subscribe</button>
|
||||
</span>
|
||||
</div>
|
||||
<p class="js_mg_details hidden well well-sm">
|
||||
<i class="fa fa-envelope-o"/><a href="#" class="js_mg_email"> send mail</a> -
|
||||
<i class="fa fa-file-o"/><a href="#" class="js_mg_link"> archives</a> -
|
||||
<i class="fa fa-times"/><a href="#" class="js_unfollow_btn"> unsubscribe</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
|
||||
<xpath expr="//div[@id='snippet_options']" position="inside">
|
||||
<div data-snippet-option-id='subscribe'
|
||||
data-selector=".js_follow"
|
||||
data-selector-siblings="p, h1, h2, h3, blockquote, .well, .panel"
|
||||
>
|
||||
<li>
|
||||
<a href="#" class="button js_mailing_list">Change Discussion List</a>
|
||||
</li>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
<template id="head" inherit_id="website.layout" name="Mail customization">
|
||||
<xpath expr="//head" position="inside">
|
||||
<script type="text/javascript" src="/website_mail/static/src/js/website_mail.editor.js" groups="base.group_website_publisher"></script>
|
||||
<script type="text/javascript" src="/website_mail/static/src/js/website_mail.js"></script>
|
||||
<link rel='stylesheet' href='/website_mail/static/src/css/website_mail.css'/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
|
|
@ -11,7 +11,8 @@ OpenERP Mail Group : Mailing List Archives
|
|||
'author': 'OpenERP SA',
|
||||
'depends': ['website_mail'],
|
||||
'data': [
|
||||
'views/website_mail_group.xml'
|
||||
'views/website_mail_group.xml',
|
||||
'views/snippets.xml',
|
||||
],
|
||||
'qweb': [],
|
||||
'installable': True,
|
||||
|
|
|
@ -129,3 +129,9 @@ class MailGroup(http.Controller):
|
|||
'replies_per_page': self._replies_per_page,
|
||||
}
|
||||
return request.registry['ir.ui.view'].render(request.cr, request.uid, 'website_mail_group.messages_short', values, engine='ir.qweb', context=request.context)
|
||||
|
||||
@http.route("/groups/<model('mail.group'):group>/get_alias_info", type='json', auth='public', website=True)
|
||||
def get_alias_info(self, group, **post):
|
||||
return {
|
||||
'alias_name': group.alias_id and group.alias_id.alias_name and group.alias_id.alias_domain and '%s@%s' % (group.alias_id.alias_name, group.alias_id.alias_domain) or False
|
||||
}
|
||||
|
|
|
@ -12,15 +12,12 @@
|
|||
openerp.jsonRpc('/website_mail/is_follower', 'call', {
|
||||
model: this.$target.data('object'),
|
||||
id: this.$target.data('id'),
|
||||
fields: ['name', 'alias_id'],
|
||||
get_alias_info: true,
|
||||
}).always(function (data) {
|
||||
self.is_user = data.is_user;
|
||||
self.$target.find('.js_mg_email').attr('href', 'mailto:' + data.alias_id[1]);
|
||||
self.$target.find('.js_mg_link').attr('href', '/groups/' + data.id);
|
||||
self.toggle_subscription(data.is_follower);
|
||||
self.$target.find('input.js_follow_email')
|
||||
.val(data.email ? data.email : "")
|
||||
.attr("disabled", data.is_follower || (data.email.length && self.is_user) ? "disabled" : false);
|
||||
self.email = data.email;
|
||||
self.$target.find('.js_mg_link').attr('href', '/groups/' + self.$target.data('id'));
|
||||
self.toggle_subscription(data.is_follower, data.email);
|
||||
self.$target.removeClass("hidden");
|
||||
});
|
||||
|
||||
|
@ -36,6 +33,7 @@
|
|||
return;
|
||||
},
|
||||
on_click: function () {
|
||||
event.preventDefault();
|
||||
var self = this;
|
||||
var $email = this.$target.find(".js_follow_email");
|
||||
|
||||
|
@ -51,10 +49,11 @@
|
|||
'message_is_follower': this.$target.attr("data-follow") || "off",
|
||||
'email': $email.length ? $email.val() : false,
|
||||
}).then(function (follow) {
|
||||
self.toggle_subscription(follow);
|
||||
self.toggle_subscription(follow, self.email);
|
||||
});
|
||||
},
|
||||
toggle_subscription: function(follow) {
|
||||
toggle_subscription: function(follow, email) {
|
||||
var alias_done = this.get_alias_info();
|
||||
if (follow) {
|
||||
this.$target.find(".js_mg_follow_form").addClass("hidden");
|
||||
this.$target.find(".js_mg_details").removeClass("hidden");
|
||||
|
@ -63,9 +62,27 @@
|
|||
this.$target.find(".js_mg_follow_form").removeClass("hidden");
|
||||
this.$target.find(".js_mg_details").addClass("hidden");
|
||||
}
|
||||
this.$target.find('input.js_follow_email').attr("disabled", follow || this.is_user ? "disabled" : false);
|
||||
this.$target.find('input.js_follow_email')
|
||||
.val(email ? email : "")
|
||||
.attr("disabled", follow || (email.length && this.is_user) ? "disabled" : false);
|
||||
this.$target.attr("data-follow", follow ? 'on' : 'off');
|
||||
return $.when(alias_done);
|
||||
},
|
||||
get_alias_info: function() {
|
||||
var self = this;
|
||||
if (! this.$target.data('id')) {
|
||||
return $.Deferred().resolve();
|
||||
}
|
||||
return openerp.jsonRpc('/groups/' + this.$target.data('id') + '/get_alias_info', 'call', {}).then(function (data) {
|
||||
if (data.alias_name) {
|
||||
self.$target.find('.js_mg_email').attr('href', 'mailto:' + data.alias_name);
|
||||
self.$target.find('.js_mg_email').removeClass('hidden');
|
||||
}
|
||||
else {
|
||||
self.$target.find('.js_mg_email').addClass('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<template id="subscribe" inherit_id="website.snippets" name="Snippet Subscribe">
|
||||
|
||||
<xpath expr="//div[@id='snippet_content']" position="inside">
|
||||
<div>
|
||||
<div class="oe_snippet_thumbnail">
|
||||
<img class="oe_snippet_thumbnail_img" src="/website_mail/static/src/img/blocks/button_group_subscribe.png"/>
|
||||
<span class="oe_snippet_thumbnail_title">Discussion Group</span>
|
||||
</div>
|
||||
|
||||
<div class="oe_snippet_body js_follow"
|
||||
data-id="0"
|
||||
data-object="mail.group"
|
||||
data-follow="off">
|
||||
<div class="input-group js_mg_follow_form">
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="js_follow_email form-control"
|
||||
placeholder="your email..."/>
|
||||
<span class="input-group-btn">
|
||||
<button href="#" class="btn btn-primary js_follow_btn">Subscribe</button>
|
||||
</span>
|
||||
</div>
|
||||
<p class="js_mg_details hidden well well-sm">
|
||||
<span class="js_mg_email hidden"><i class="fa fa-envelope-o"/><a href="#" class="js_mg_email"> send mail</a> - </span>
|
||||
<i class="fa fa-file-o"/><a href="#" class="js_mg_link"> archives</a> -
|
||||
<i class="fa fa-times"/><a href="#" class="js_unfollow_btn"> unsubscribe</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
|
||||
<xpath expr="//div[@id='snippet_options']" position="inside">
|
||||
<div data-snippet-option-id='subscribe'
|
||||
data-selector=".js_follow"
|
||||
data-selector-siblings="p, h1, h2, h3, blockquote, .well, .panel"
|
||||
>
|
||||
<li>
|
||||
<a href="#" class="button js_mailing_list">Change Discussion List</a>
|
||||
</li>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -8,6 +8,13 @@
|
|||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="head" inherit_id="website.layout" name="Mail Group Customization">
|
||||
<xpath expr="//head" position="inside">
|
||||
<script type="text/javascript" src="/website_mail_group/static/src/js/website_mail_group.editor.js" groups="base.group_website_publisher"></script>
|
||||
<script type="text/javascript" src="/website_mail_group/static/src/js/website_mail_group.snippet.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="mail_groups" name="Mailing Lists">
|
||||
<t t-call="website.layout">
|
||||
<div id="wrap" class="oe_structure oe_empty">
|
||||
|
@ -23,8 +30,10 @@
|
|||
<div class="col-md-3">
|
||||
<img t-att-src="'/website/image?model=mail.group&field=image_small&id='+str(group['id'])" class="pull-left"/>
|
||||
<strong><a t-attf-href="/groups/#{ slug(group) }" t-esc="group.name"/></strong><br />
|
||||
<i class='fa fa-envelope-o'/>
|
||||
<a t-attf-href="mailto:#{group.alias_id.alias_name}@#{group.alias_id.alias_domain}"><span t-field="group.alias_id"/></a>
|
||||
<t t-if="group.alias_id and group.alias_id.alias_name and group.alias_id.alias_domain">
|
||||
<i class='fa fa-envelope-o'/>
|
||||
<a t-attf-href="mailto:#{group.alias_id.alias_name}@#{group.alias_id.alias_domain}"><span t-field="group.alias_id"/></a>
|
||||
</t>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div t-esc="group.description" class="text-muted"/>
|
||||
|
@ -59,7 +68,7 @@
|
|||
<div class="row">
|
||||
<h1 class="text-center">
|
||||
<t t-esc="group.name"/> mailing list archives
|
||||
</h1><h4 class="text-center text-muted">
|
||||
</h1><h4 class="text-center text-muted" t-if="group.alias_id and group.alias_id.alias_name and group.alias_id.alias_domain">
|
||||
<i class='fa fa-envelope-o'/>
|
||||
<a t-attf-href="mailto:#{group.alias_id.alias_name}@#{group.alias_id.alias_domain}"><span t-field="group.alias_id"/></a>
|
||||
</h4>
|
||||
|
@ -123,7 +132,7 @@
|
|||
<div class="row">
|
||||
<h1 class="text-center">
|
||||
<t t-esc="group.name"/> mailing list archives
|
||||
</h1><h4 class="text-center text-muted">
|
||||
</h1><h4 class="text-center text-muted" t-if="group.alias_id and group.alias_id.alias_name and group.alias_id.alias_domain">
|
||||
<i class='fa fa-envelope-o'/>
|
||||
<a t-attf-href="mailto:#{group.alias_id.alias_name}@#{group.alias_id.alias_domain}"><span t-field="group.alias_id"/></a>
|
||||
</h4>
|
||||
|
|
Loading…
Reference in New Issue