], 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
+++ /dev/null
-(function () {
- 'use strict';
-
- var website = openerp.website;
- var _t = openerp._t;
-
- website.snippet.options.subscribe = website.snippet.Option.extend({
- on_prompt: function () {
- var self = this;
- return website.prompt({
- id: "editor_new_subscribe_button",
- window_title: _t("Add a Subscribe Button"),
- select: _t("Discussion List"),
- init: function (field) {
- return website.session.model('mail.group')
- .call('name_search', ['', [['public','=','public']]], { context: website.get_context() });
- },
- }).then(function (mail_group_id) {
- self.$target.attr("data-id", mail_group_id);
- });
- },
- drop_and_build_snippet: function() {
- var self = this;
- this._super();
- this.on_prompt().fail(function () {
- self.editor.on_remove();
- });
- },
- start : function () {
- var self = this;
- this.$el.find(".js_mailing_list").on("click", _.bind(this.on_prompt, this));
- this._super();
- },
- clean_for_save: function () {
- this.$target.addClass("hidden");
- },
- });
-})();
-
-
+++ /dev/null
-(function () {
- 'use strict';
-
- var website = openerp.website;
-
- website.snippet.animationRegistry.follow = website.snippet.Animation.extend({
- selector: ".js_follow",
- start: function (editable_mode) {
- var self = this;
- this.is_user = false;
-
- openerp.jsonRpc('/website_mail/is_follower', 'call', {
- model: this.$target.data('object'),
- id: this.$target.data('id'),
- get_alias_info: true,
- }).always(function (data) {
- self.is_user = data.is_user;
- 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");
- });
-
- // not if editable mode to allow designer to edit alert field
- if (!editable_mode) {
- $('.js_follow > .alert').addClass("hidden");
- $('.js_follow > .input-group-btn.hidden').removeClass("hidden");
- this.$target.find('.js_follow_btn, .js_unfollow_btn').on('click', function (event) {
- event.preventDefault();
- self.on_click();
- });
- }
- return;
- },
- on_click: function () {
- var self = this;
- var $email = this.$target.find(".js_follow_email");
-
- if ($email.length && !$email.val().match(/.+@.+/)) {
- this.$target.addClass('has-error');
- return false;
- }
- this.$target.removeClass('has-error');
-
- openerp.jsonRpc('/website_mail/follow', 'call', {
- 'id': +this.$target.data('id'),
- 'object': this.$target.data('object'),
- 'message_is_follower': this.$target.attr("data-follow") || "off",
- 'email': $email.length ? $email.val() : false,
- }).then(function (follow) {
- self.toggle_subscription(follow, self.email);
- });
- },
- 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");
- }
- else {
- this.$target.find(".js_mg_follow_form").removeClass("hidden");
- this.$target.find(".js_mg_details").addClass("hidden");
- }
- 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;
- return openerp.jsonRpc('/website_mail/get_alias_info', 'call', {
- model: this.$target.data('object'),
- id: this.$target.data('id'),
- }).then(function (data) {
- self.$target.find('.js_mg_email').attr('href', 'mailto:' + data.alias_name);
- });
- }
- });
-
- $(document).ready(function () {
- $('.js_follow_btn').on('click', function (ev) {
- var email = $(ev.currentTarget).parents('.js_mg_follow_form').first().find('.js_follow_email').val();
- $(document).find('.js_follow_email').val(email);
- });
- });
-})();
</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>
<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>
'author': 'OpenERP SA',
'depends': ['website_mail'],
'data': [
- 'views/website_mail_group.xml'
+ 'views/website_mail_group.xml',
+ 'views/snippets.xml',
],
'qweb': [],
'installable': True,
'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
+ }
--- /dev/null
+(function () {
+ 'use strict';
+
+ var website = openerp.website;
+ var _t = openerp._t;
+
+ website.snippet.options.subscribe = website.snippet.Option.extend({
+ on_prompt: function () {
+ var self = this;
+ return website.prompt({
+ id: "editor_new_subscribe_button",
+ window_title: _t("Add a Subscribe Button"),
+ select: _t("Discussion List"),
+ init: function (field) {
+ return website.session.model('mail.group')
+ .call('name_search', ['', [['public','=','public']]], { context: website.get_context() });
+ },
+ }).then(function (mail_group_id) {
+ self.$target.attr("data-id", mail_group_id);
+ });
+ },
+ drop_and_build_snippet: function() {
+ var self = this;
+ this._super();
+ this.on_prompt().fail(function () {
+ self.editor.on_remove();
+ });
+ },
+ start : function () {
+ var self = this;
+ this.$el.find(".js_mailing_list").on("click", _.bind(this.on_prompt, this));
+ this._super();
+ },
+ clean_for_save: function () {
+ this.$target.addClass("hidden");
+ },
+ });
+})();
+
+
--- /dev/null
+(function () {
+ 'use strict';
+
+ var website = openerp.website;
+
+ website.snippet.animationRegistry.follow = website.snippet.Animation.extend({
+ selector: ".js_follow",
+ start: function (editable_mode) {
+ var self = this;
+ this.is_user = false;
+
+ openerp.jsonRpc('/website_mail/is_follower', 'call', {
+ model: this.$target.data('object'),
+ id: this.$target.data('id'),
+ get_alias_info: true,
+ }).always(function (data) {
+ self.is_user = data.is_user;
+ 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");
+ });
+
+ // not if editable mode to allow designer to edit alert field
+ if (!editable_mode) {
+ $('.js_follow > .alert').addClass("hidden");
+ $('.js_follow > .input-group-btn.hidden').removeClass("hidden");
+ this.$target.find('.js_follow_btn, .js_unfollow_btn').on('click', function (event) {
+ event.preventDefault();
+ self.on_click();
+ });
+ }
+ return;
+ },
+ on_click: function () {
+ event.preventDefault();
+ var self = this;
+ var $email = this.$target.find(".js_follow_email");
+
+ if ($email.length && !$email.val().match(/.+@.+/)) {
+ this.$target.addClass('has-error');
+ return false;
+ }
+ this.$target.removeClass('has-error');
+
+ openerp.jsonRpc('/website_mail/follow', 'call', {
+ 'id': +this.$target.data('id'),
+ 'object': this.$target.data('object'),
+ 'message_is_follower': this.$target.attr("data-follow") || "off",
+ 'email': $email.length ? $email.val() : false,
+ }).then(function (follow) {
+ self.toggle_subscription(follow, self.email);
+ });
+ },
+ 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");
+ }
+ else {
+ this.$target.find(".js_mg_follow_form").removeClass("hidden");
+ this.$target.find(".js_mg_details").addClass("hidden");
+ }
+ 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 () {
+ $('.js_follow_btn').on('click', function (ev) {
+ var email = $(ev.currentTarget).parents('.js_mg_follow_form').first().find('.js_follow_email').val();
+ $(document).find('.js_follow_email').val(email);
+ });
+ });
+})();
--- /dev/null
+<?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>
\ No newline at end of file
</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">
<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"/>
<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>
<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>