[FIX] mass_mailing: newsletter snippet:
- fixed subscription, was always subscribing to the last created list; - slightly improved the snippet display, now displaying a 'thanks' when subscribed instead of just making everything disabled; - removed unnecessary JS line
This commit is contained in:
parent
1c4825294b
commit
4be1ba8b6f
|
@ -67,7 +67,8 @@ class MassMailController(http.Controller):
|
||||||
|
|
||||||
contact_ids = Contacts.search(cr, SUPERUSER_ID, [('list_id', '=', int(list_id)), ('email', '=', email)], context=context)
|
contact_ids = Contacts.search(cr, SUPERUSER_ID, [('list_id', '=', int(list_id)), ('email', '=', email)], context=context)
|
||||||
if not contact_ids:
|
if not contact_ids:
|
||||||
Contacts.name_create(cr, SUPERUSER_ID, email, context=context)
|
contact_ng = Contacts.name_create(cr, SUPERUSER_ID, email, context=context)
|
||||||
|
Contacts.write(cr, SUPERUSER_ID, [contact_ng[0]], {'list_id': int(list_id)}, context=context)
|
||||||
# add email to session
|
# add email to session
|
||||||
request.session['mass_mailing_email'] = email
|
request.session['mass_mailing_email'] = email
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -18,9 +18,12 @@
|
||||||
.attr("disabled", data.is_subscriber && data.email.length ? "disabled" : false);
|
.attr("disabled", data.is_subscriber && data.email.length ? "disabled" : false);
|
||||||
self.$target.attr("data-subscribe", data.is_subscriber ? 'on' : 'off');
|
self.$target.attr("data-subscribe", data.is_subscriber ? 'on' : 'off');
|
||||||
self.$target.find('a.js_subscribe_btn')
|
self.$target.find('a.js_subscribe_btn')
|
||||||
.val(data.email ? data.email : "")
|
|
||||||
.attr("disabled", data.is_subscriber && data.email.length ? "disabled" : false);
|
.attr("disabled", data.is_subscriber && data.email.length ? "disabled" : false);
|
||||||
self.$target.removeClass("hidden");
|
self.$target.removeClass("hidden");
|
||||||
|
if (data.is_subscriber) {
|
||||||
|
self.$target.find('.js_subscribe_btn').addClass('hidden');
|
||||||
|
self.$target.find('.js_subscribed_btn').removeClass('hidden');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// not if editable mode to allow designer to edit alert field
|
// not if editable mode to allow designer to edit alert field
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
placeholder="your email..."/>
|
placeholder="your email..."/>
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
<a href="#" class="btn btn-primary js_subscribe_btn">Subscribe</a>
|
<a href="#" class="btn btn-primary js_subscribe_btn">Subscribe</a>
|
||||||
|
<a href="#" class="btn btn-success js_subscribed_btn hidden" disabled="disabled">Thanks</a>
|
||||||
</span>
|
</span>
|
||||||
<div class="alert alert-success hidden">Thanks for your subscription!</div>
|
<div class="alert alert-success hidden">Thanks for your subscription!</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue