[FIX] website_mail, websit_mail_group: moved discussion group snippet to the right module; it should not be available when the mailing list archives module is not installed. Also fixed get_alias_info route to be mail_group specific and to avoid allowing people to browse the database.
This commit is contained in:
parent
02018563b3
commit
0c89ca0f8f
|
@ -100,20 +100,3 @@ class WebsiteMail(http.Controller):
|
|||
], context=context)) == 1
|
||||
|
||||
return values
|
||||
|
||||
@http.route(['/website_mail/get_alias_info'], type='json', auth='public', website=True)
|
||||
def get_alias_info(self, model, id, **post):
|
||||
id = int(id)
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
obj = request.registry.get(model)
|
||||
|
||||
values = {'alias_name': False}
|
||||
|
||||
if not obj:
|
||||
return values
|
||||
obj_ids = obj.exists(cr, SUPERUSER_ID, [id], context=context)
|
||||
if obj_ids and 'alias_id' in obj._all_columns:
|
||||
alias_id = obj.browse(cr, SUPERUSER_ID, obj_ids[0], context=context).alias_id
|
||||
values['alias_name'] = alias_id and alias_id.alias_domain and '%s@%s' % (alias_id.alias_name, alias_id.alias_domain) or False
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
return;
|
||||
},
|
||||
on_click: function () {
|
||||
event.preventDefault();
|
||||
var self = this;
|
||||
var $email = this.$target.find(".js_follow_email");
|
||||
|
||||
|
@ -69,11 +70,17 @@
|
|||
},
|
||||
get_alias_info: function() {
|
||||
var self = this;
|
||||
return openerp.jsonRpc('/website_mail/get_alias_info', 'call', {
|
||||
model: this.$target.data('object'),
|
||||
id: this.$target.data('id'),
|
||||
}).then(function (data) {
|
||||
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');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
|
@ -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 />
|
||||
<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