diff --git a/mass_mailing_custom_unsubscribe/README.rst b/mass_mailing_custom_unsubscribe/README.rst
index dc2c639..5da443d 100644
--- a/mass_mailing_custom_unsubscribe/README.rst
+++ b/mass_mailing_custom_unsubscribe/README.rst
@@ -14,13 +14,13 @@ Customizable unsubscription process on mass mailing emails
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
- :target: https://github.com/OCA/social/tree/13.0/mass_mailing_custom_unsubscribe
+ :target: https://github.com/OCA/social/tree/14.0/mass_mailing_custom_unsubscribe
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/social-13-0/social-13-0-mass_mailing_custom_unsubscribe
+ :target: https://translation.odoo-community.org/projects/social-14-0/social-14-0-mass_mailing_custom_unsubscribe
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/205/13.0
+ :target: https://runbot.odoo-community.org/runbot/205/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -88,7 +88,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -126,6 +126,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-This module is part of the `OCA/social `_ project on GitHub.
+This module is part of the `OCA/social `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/mass_mailing_custom_unsubscribe/__manifest__.py b/mass_mailing_custom_unsubscribe/__manifest__.py
index ac6599e..729fd29 100644
--- a/mass_mailing_custom_unsubscribe/__manifest__.py
+++ b/mass_mailing_custom_unsubscribe/__manifest__.py
@@ -6,7 +6,7 @@
"name": "Customizable unsubscription process on mass mailing emails",
"summary": "Know and track (un)subscription reasons, GDPR compliant",
"category": "Marketing",
- "version": "13.0.2.0.0",
+ "version": "14.0.1.0.0",
"depends": ["mass_mailing"],
"data": [
"security/ir.model.access.csv",
@@ -20,7 +20,7 @@
],
"demo": ["demo/assets.xml"],
"images": ["images/form.png"],
- "author": "Tecnativa," "Odoo Community Association (OCA)",
+ "author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"license": "AGPL-3",
"installable": True,
diff --git a/mass_mailing_custom_unsubscribe/i18n/mass_mailing_custom_unsubscribe.pot b/mass_mailing_custom_unsubscribe/i18n/mass_mailing_custom_unsubscribe.pot
index a9d04bc..c9e58c5 100644
--- a/mass_mailing_custom_unsubscribe/i18n/mass_mailing_custom_unsubscribe.pot
+++ b/mass_mailing_custom_unsubscribe/i18n/mass_mailing_custom_unsubscribe.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 13.0\n"
+"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -47,11 +47,17 @@ msgstr ""
#: code:addons/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js:0
#: code:addons/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js:0
#: code:addons/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js:0
+#, python-format
+msgid "An error occured. Please try again later or contact us."
+msgstr ""
+
+#. module: mass_mailing_custom_unsubscribe
+#. openerp-web
#: code:addons/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js:0
#: code:addons/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js:0
#: code:addons/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js:0
#, python-format
-msgid "An error occured. Please try again later or contact us."
+msgid "An error occurred. Please try again later or contact us."
msgstr ""
#. module: mass_mailing_custom_unsubscribe
@@ -112,8 +118,11 @@ msgid "Details Required"
msgstr ""
#. module: mass_mailing_custom_unsubscribe
+#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mail_blacklist__display_name
#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mail_unsubscription__display_name
#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mail_unsubscription_reason__display_name
+#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mailing_list__display_name
+#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mailing_mailing__display_name
msgid "Display Name"
msgstr ""
@@ -169,8 +178,11 @@ msgid "I'm not interested"
msgstr ""
#. module: mass_mailing_custom_unsubscribe
+#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mail_blacklist__id
#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mail_unsubscription__id
#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mail_unsubscription_reason__id
+#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mailing_list__id
+#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mailing_mailing__id
msgid "ID"
msgstr ""
@@ -200,8 +212,11 @@ msgid "Is Follower"
msgstr ""
#. module: mass_mailing_custom_unsubscribe
+#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mail_blacklist____last_update
#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mail_unsubscription____last_update
#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mail_unsubscription_reason____last_update
+#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mailing_list____last_update
+#: model:ir.model.fields,field_description:mass_mailing_custom_unsubscribe.field_mailing_mailing____last_update
msgid "Last Modified on"
msgstr ""
diff --git a/mass_mailing_custom_unsubscribe/migrations/13.0.2.0.0/pre-migration.py b/mass_mailing_custom_unsubscribe/migrations/13.0.2.0.0/pre-migration.py
deleted file mode 100644
index 9a7dbf8..0000000
--- a/mass_mailing_custom_unsubscribe/migrations/13.0.2.0.0/pre-migration.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2021 Tecnativa - David Vidal
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from openupgradelib import openupgrade
-
-
-@openupgrade.migrate()
-def migrate(env, version):
- openupgrade.logged_query(
- env.cr,
- """
- UPDATE mail_unsubscription
- SET unsubscriber_id = replace(
- unsubscriber_id, 'mail.mass_mailing.contact', 'mailing.contact'
- )
- WHERE unsubscriber_id LIKE 'mail.mass_mailing_contact%'
- """,
- )
diff --git a/mass_mailing_custom_unsubscribe/static/description/index.html b/mass_mailing_custom_unsubscribe/static/description/index.html
index c6ea2ff..01c1476 100644
--- a/mass_mailing_custom_unsubscribe/static/description/index.html
+++ b/mass_mailing_custom_unsubscribe/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This addon extends the unsubscription form to let you:
- Choose which mailing lists are not cross-unsubscriptable when unsubscribing
@@ -440,7 +440,7 @@ duplicated functionality and depending on it instead of replacing it).
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -473,7 +473,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/social project on GitHub.
+
This module is part of the OCA/social project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/mass_mailing_custom_unsubscribe/static/src/js/contact.tour.js b/mass_mailing_custom_unsubscribe/static/src/js/contact.tour.js
index 401b5c0..0642e36 100644
--- a/mass_mailing_custom_unsubscribe/static/src/js/contact.tour.js
+++ b/mass_mailing_custom_unsubscribe/static/src/js/contact.tour.js
@@ -1,15 +1,13 @@
/* Copyright 2016 Jairo Llopis
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
-odoo.define("mass_mailing_custom_unsubscribe.contact_tour", function (require) {
+odoo.define("mass_mailing_custom_unsubscribe.contact_tour", (require) => {
"use strict";
- var base = require("web_editor.base");
- var tour = require("web_tour.tour");
+ const base = require("web_editor.base");
+ const tour = require("web_tour.tour");
// Allow to know if an element is required
$.extend($.expr[":"], {
- propRequired: function (element) {
- return $(element).prop("required");
- },
+ propRequired: (element) => $(element).prop("required"),
});
tour.register(
@@ -59,8 +57,7 @@ odoo.define("mass_mailing_custom_unsubscribe.contact_tour", function (require) {
{
content: "Choose other reason",
trigger: ".radio:contains('Other reason') :radio",
- extra_trigger:
- ".radio:contains('Other reason') " + ":radio:not(:checked)",
+ extra_trigger: ".radio:contains('Other reason') :radio:not(:checked)",
},
{
content: "Add details to reason",
@@ -78,18 +75,13 @@ odoo.define("mass_mailing_custom_unsubscribe.contact_tour", function (require) {
},
{
content: "Subscribe again to list 0",
- // eslint-disable-next-line no-multi-str
trigger:
- "body:not(:has(#unsubscribe_form #custom_div_feedback\
- :visible)):has(.alert-success) li:contains('test list 0') \
- input:not(:checked)",
+ "body:not(:has(#unsubscribe_form #custom_div_feedback:visible)):has(.alert-success) li:contains('test list 0') input:not(:checked)",
},
{
content: "Update subscriptions 3nd time",
- // eslint-disable-next-line no-multi-str
trigger:
- "#unsubscribe_form:not(\
- :has(.js_unsubscription_reason:visible)) :submit",
+ "#unsubscribe_form:not(:has(.js_unsubscription_reason:visible)) :submit",
},
{
content: "Successfully subscribed",
diff --git a/mass_mailing_custom_unsubscribe/static/src/js/partner.tour.js b/mass_mailing_custom_unsubscribe/static/src/js/partner.tour.js
index 46c0b95..e875995 100644
--- a/mass_mailing_custom_unsubscribe/static/src/js/partner.tour.js
+++ b/mass_mailing_custom_unsubscribe/static/src/js/partner.tour.js
@@ -1,15 +1,13 @@
/* Copyright 2016 Jairo Llopis
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
-odoo.define("mass_mailing_custom_unsubscribe.partner_tour", function (require) {
+odoo.define("mass_mailing_custom_unsubscribe.partner_tour", (require) => {
"use strict";
- var base = require("web_editor.base");
- var tour = require("web_tour.tour");
+ const base = require("web_editor.base");
+ const tour = require("web_tour.tour");
// Allow to know if an element is required
$.extend($.expr[":"], {
- propRequired: function (element) {
- return $(element).prop("required");
- },
+ propRequired: (element) => $(element).prop("required"),
});
tour.register(
@@ -26,10 +24,7 @@ odoo.define("mass_mailing_custom_unsubscribe.partner_tour", function (require) {
},
{
content: "Switch to not interested reason",
- // eslint-disable-next-line no-multi-str
- trigger:
- '.radio:contains("I\'m not interested") \
- :radio:not(:checked)',
+ trigger: '.radio:contains("I\'m not interested") :radio:not(:checked)',
extra_trigger: "[name='details']:propRequired",
},
{
diff --git a/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js b/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js
index ce0ff53..dc9c54e 100644
--- a/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js
+++ b/mass_mailing_custom_unsubscribe/static/src/js/unsubscribe.js
@@ -3,35 +3,37 @@
/* This JS module replaces core AJAX submission because it is impossible
* to extend it as it is currently designed. It is almost a copy+paste from
- * upstream, to allow easier version/patch updates, so linter is disabled. */
+ * upstream, to allow easier version/patch updates, so linter is disabled
+ * and prettier is ignore. */
/* eslint-disable */
+// prettier-ignore
odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function (require) {
"use strict";
- var ajax = require("web.ajax");
- var core = require("web.core");
- require("web.dom_ready");
+ var session = require('web.session');
+ var ajax = require('web.ajax');
+ var core = require('web.core');
+ require('web.dom_ready');
var _t = core._t;
- if (!$(".o_unsubscribe_form").length) {
- return $.Deferred().reject("DOM doesn't contain '.o_unsubscribe_form'");
- }
-
var email = $("input[name='email']").val();
var mailing_id = parseInt($("input[name='mailing_id']").val(), 10);
var res_id = parseInt($("input[name='res_id']").val(), 10);
- var token = (location.search.split("token" + "=")[1] || "").split("&")[0];
+ var token = (location.search.split('token' + '=')[1] || '').split('&')[0];
var $mailing_lists = $("input[name='contact_ids']");
var $reasons = $("#custom_div_feedback");
var $details = $("textarea[name='details']");
var $radio = $(":radio");
var $info_state = $("#info_state, #custom_div_feedback");
- $radio.on("change click", function (e) {
+ if (!$('.o_unsubscribe_form').length) {
+ return Promise.reject("DOM doesn't contain '.o_unsubscribe_form'");
+ }
+ $radio.on('change click', function (e) {
$details.prop(
- "required",
- $(e.target).is("[data-details-required]") && $(e.target).is(":visible")
+ 'required',
+ $(e.target).is('[data-details-required]') && $(e.target).is(':visible')
);
});
@@ -40,99 +42,84 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function (require) {
// Find contacts that were checked and now are unchecked
var $disabled = $mailing_lists.filter(function () {
var $this = $(this);
- return !$this.prop("checked") && $this.attr("checked");
+ return !$this.prop('checked') && $this.attr('checked');
});
// Hide reasons form if you are only subscribing
- $reasons.toggleClass("d-none", !$disabled.length);
- var $radios = $reasons.find(":radio");
- if ($reasons.is(":hidden")) {
+ $reasons.toggleClass('d-none', !$disabled.length);
+ var $radios = $reasons.find(':radio');
+ if ($reasons.is(':hidden')) {
// Uncheck chosen reason
$radios
- .prop("checked", false)
+ .prop('checked', false)
// Unrequire specifying a reason
- .prop("required", false)
+ .prop('required', false)
// Remove possible constraints for details
- .trigger("change");
+ .trigger('change');
// Clear textarea
- $details.val("");
+ $details.val('');
} else {
// Require specifying a reason
- $radios.prop("required", true);
+ $radios.prop('required', true);
}
};
-
$mailing_lists.change(function (e) {
toggle_reasons();
- $("#info_state").addClass("invisible");
+ $('#info_state').addClass('invisible');
});
- if (email != "" && email != undefined) {
- ajax.jsonRpc("/mailing/blacklist/check", "call", {
- email: email,
- mailing_id: mailing_id,
- res_id: res_id,
- token: token,
- })
- .then(function (result) {
- if (result == "unauthorized") {
- $("#button_add_blacklist").hide();
- $("#button_remove_blacklist").hide();
- } else if (result == true) {
- $("#button_remove_blacklist").show();
- toggle_opt_out_section(false);
- } else if (result == false) {
- $("#button_add_blacklist").show();
- toggle_opt_out_section(true);
- } else {
- $("#subscription_info").html(
- _t("An error occured. Please try again later or contact us.")
- );
- $info_state
- .removeClass("alert-success")
- .removeClass("alert-info")
- .removeClass("alert-warning")
- .addClass("alert-error");
- }
- })
- .guardedCatch(function () {
- $("#subscription_info").html(
- _t("An error occured. Please try again later or contact us.")
- );
- $info_state
- .removeClass("alert-success")
- .removeClass("alert-info")
- .removeClass("alert-warning")
- .addClass("alert-error");
- });
- } else {
- $("#div_blacklist").hide();
- }
+ session.load_translations().then(function () {
+ if (email != '' && email != undefined){
+ ajax.jsonRpc('/mailing/blacklist/check', 'call', {'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
+ .then(function (result) {
+ if (result == 'unauthorized'){
+ $('#button_add_blacklist').hide();
+ $('#button_remove_blacklist').hide();
+ }
+ else if (result == true) {
+ $('#button_remove_blacklist').show();
+ toggle_opt_out_section(false);
+ }
+ else if (result == false) {
+ $('#button_add_blacklist').show();
+ toggle_opt_out_section(true);
+ }
+ else {
+ $('#subscription_info').html(_t('An error occurred. Please try again later or contact us.'));
+ $info_state.removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
+ }
+ })
+ .guardedCatch(function () {
+ $('#subscription_info').html(_t('An error occurred. Please try again later or contact us.'));
+ $info_state.removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
+ });
+ }
+ else {
+ $('#div_blacklist').hide();
+ }
- var unsubscribed_list = $("input[name='unsubscribed_list']").val();
- if (unsubscribed_list) {
- $("#subscription_info").html(
- _.str.sprintf(
+ var unsubscribed_list = $("input[name='unsubscribed_list']").val();
+ if (unsubscribed_list){
+ $('#subscription_info').html(_.str.sprintf(
_t("You have been successfully unsubscribed from %s."),
- unsubscribed_list
- )
- );
- } else {
- $("#subscription_info").html(
- _t("You have been successfully unsubscribed.")
- );
- }
+ _.escape(unsubscribed_list)
+ ));
+ }
+ else{
+ $('#subscription_info').html(_t('You have been successfully unsubscribed.'));
+ }
+ });
- $("#unsubscribe_form").on("submit", function (e) {
+ $('#unsubscribe_form').on('submit', function (e) {
e.preventDefault();
var checked_ids = [];
$("input[type='checkbox']:checked").each(function (i) {
- checked_ids[i] = parseInt($(this).val(), 10);
+ checked_ids[i] = parseInt($(this).val(), 10);
});
var unchecked_ids = [];
$("input[type='checkbox']:not(:checked)").each(function (i) {
- unchecked_ids[i] = parseInt($(this).val(), 10);
+ unchecked_ids[i] = parseInt($(this).val(), 10);
});
var values = {
@@ -144,222 +131,144 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function (require) {
token: token,
};
// Only send reason and details if an unsubscription was found
- if ($reasons.is(":visible")) {
+ if ($reasons.is(':visible')) {
values.reason_id = parseInt(
- $reasons.find("[name='reason_id']:checked").val(),
- 10
+ $reasons.find("[name='reason_id']:checked").val(), 10
);
values.details = $details.val();
}
- ajax.jsonRpc("/mail/mailing/unsubscribe", "call", values)
+ ajax.jsonRpc('/mail/mailing/unsubscribe', 'call', values)
.then(function (result) {
- if (result == "unauthorized") {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t("You are not authorized to do this!")
- );
- $info_state
- .removeClass("alert-success")
- .removeClass("alert-info")
- .removeClass("alert-error")
- .addClass("alert-warning");
- } else if (result == true) {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(_t("Your changes have been saved."));
- $info_state.removeClass("alert-info").addClass("alert-success");
+ if (result == 'unauthorized'){
+ $('#subscription_info').html(_t('You are not authorized to do this!'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
+ }
+ else if (result == true) {
+ $('#subscription_info').html(_t('Your changes have been saved.'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-info').addClass('alert-success');
// Store checked status, to enable further changes
$mailing_lists.each(function () {
var $this = $(this);
- $this.attr("checked", $this.prop("checked"));
+ $this.attr('checked', $this.prop('checked'));
});
toggle_reasons();
- } else {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t(
- "An error occurred. Your changes have not been saved, try again later."
- )
- );
- $info_state.removeClass("alert-info").addClass("alert-warning");
+ }
+ else {
+ $('#subscription_info').html(_t('An error occurred. Your changes have not been saved, try again later.'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-info').addClass('alert-warning');
}
})
.guardedCatch(function () {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t(
- "An error occurred. Your changes have not been saved, try again later."
- )
- );
- $info_state.removeClass("alert-info").addClass("alert-warning");
+ $('#subscription_info').html(_t('An error occurred. Your changes have not been saved, try again later.'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-info').addClass('alert-warning');
});
});
// ==================
// Blacklist
// ==================
- $("#button_add_blacklist").click(function (e) {
+ $('#button_add_blacklist').click(function (e) {
e.preventDefault();
- if ($reasons.is(":hidden")) {
- $reasons.toggleClass("d-none", false);
- $reasons.find(":radio").prop("required", true);
+ if ($reasons.is(':hidden')) {
+ $reasons.toggleClass('d-none', false);
+ $reasons.find(':radio').prop('required', true);
}
- if (!$("#unsubscribe_form")[0].reportValidity()) {
+ if (!$('#unsubscribe_form')[0].reportValidity()) {
return;
}
- ajax.jsonRpc("/mailing/blacklist/add", "call", {
- email: email,
- mailing_id: mailing_id,
- res_id: res_id,
- token: token,
- reason_id: parseInt($reasons.find("[name='reason_id']:checked").val(), 10),
- details: $details.val(),
+ ajax.jsonRpc('/mailing/blacklist/add', 'call', {'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token,
+ 'reason_id': parseInt($reasons.find("[name='reason_id']:checked").val(), 10),
+ 'details': $details.val(),
})
.then(function (result) {
- if (result == "unauthorized") {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t("You are not authorized to do this!")
- );
- $info_state
- .removeClass("alert-success")
- .removeClass("alert-info")
- .removeClass("alert-error")
- .addClass("alert-warning");
- } else {
+ if (result == 'unauthorized'){
+ $('#subscription_info').html(_t('You are not authorized to do this!'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
+ }
+ else
+ {
if (result) {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t(
- "You have been successfully added to our blacklist. " +
- "You will not be contacted anymore by our services."
- )
- );
- $info_state
- .removeClass("alert-warning")
- .removeClass("alert-info")
- .removeClass("alert-error")
- .addClass("alert-success");
+ $('#subscription_info').html(_t('You have been successfully added to our blacklist. '
+ + 'You will not be contacted anymore by our services.'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-warning').removeClass('alert-info').removeClass('alert-error').addClass('alert-success');
toggle_opt_out_section(false);
// set mailing lists checkboxes to previous state
$mailing_lists.each(function () {
var $this = $(this);
- $this.prop("checked", $(this)[0].hasAttribute("checked"));
+ $this.prop('checked', $(this)[0].hasAttribute('checked'));
});
// Hide reasons and reset reason fields
- $reasons
- .toggleClass("d-none", true)
- .find(":radio")
- .prop("checked", false);
- $details.val("").prop("required", false);
- } else {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t(
- "An error occured. Please try again later or contact us."
- )
- );
- $info_state
- .removeClass("alert-success")
- .removeClass("alert-info")
- .removeClass("alert-warning")
- .addClass("alert-error");
+ $reasons.toggleClass('d-none', true).find(':radio').prop('checked', false);
+ $details.val('').prop('required', false);
}
- $("#button_add_blacklist").hide();
- $("#button_remove_blacklist").show();
- $("#unsubscribed_info").hide();
+ else {
+ $('#subscription_info').html(_t('An error occurred. Please try again later or contact us.'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
+ }
+ $('#button_add_blacklist').hide();
+ $('#button_remove_blacklist').show();
+ $('#unsubscribed_info').hide();
}
})
.guardedCatch(function () {
- $("#subscription_info").html(
- _t("An error occured. Please try again later or contact us.")
- );
- $info_state
- .removeClass("alert-success")
- .removeClass("alert-info")
- .removeClass("alert-warning")
- .addClass("alert-error");
+ $('#subscription_info').html(_t('An error occured. Please try again later or contact us.'));
+ $info_state.removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
});
});
- $("#button_remove_blacklist").click(function (e) {
+ $('#button_remove_blacklist').click(function (e) {
e.preventDefault();
- ajax.jsonRpc("/mailing/blacklist/remove", "call", {
- email: email,
- mailing_id: mailing_id,
- res_id: res_id,
- token: token,
- })
+ ajax.jsonRpc('/mailing/blacklist/remove', 'call', {'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
.then(function (result) {
- if (result == "unauthorized") {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t("You are not authorized to do this!")
- );
- $info_state
- .removeClass("alert-success")
- .removeClass("alert-info")
- .removeClass("alert-error")
- .addClass("alert-warning");
- } else {
+ if (result == 'unauthorized'){
+ $('#subscription_info').html(_t('You are not authorized to do this!'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
+ }
+ else
+ {
if (result) {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t(
- "You have been successfully removed from our blacklist. " +
- "You are now able to be contacted by our services."
- )
- );
- $info_state
- .removeClass("alert-warning")
- .removeClass("alert-info")
- .removeClass("alert-error")
- .addClass("alert-success");
+ $('#subscription_info').html(_t("You have been successfully removed from our blacklist. "
+ + "You are now able to be contacted by our services."));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-warning').removeClass('alert-info').removeClass('alert-error').addClass('alert-success');
toggle_opt_out_section(true);
- } else {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t(
- "An error occured. Please try again later or contact us."
- )
- );
- $info_state
- .removeClass("alert-success")
- .removeClass("alert-info")
- .removeClass("alert-warning")
- .addClass("alert-error");
}
- $("#button_add_blacklist").show();
- $("#button_remove_blacklist").hide();
- $("#unsubscribed_info").hide();
+ else {
+ $('#subscription_info').html(_t('An error occured. Please try again later or contact us.'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
+ }
+ $('#button_add_blacklist').show();
+ $('#button_remove_blacklist').hide();
+ $('#unsubscribed_info').hide();
}
})
.guardedCatch(function () {
- $("#info_state").removeClass("invisible");
- $("#subscription_info").html(
- _t("An error occured. Please try again later or contact us.")
- );
- $info_state
- .removeClass("alert-success")
- .removeClass("alert-info")
- .removeClass("alert-warning")
- .addClass("alert-error");
+ $('#subscription_info').html(_t('An error occured. Please try again later or contact us.'));
+ $('#info_state').removeClass('invisible');
+ $info_state.removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
});
});
});
+// prettier-ignore
function toggle_opt_out_section(value) {
var result = !value;
- $("#div_opt_out").find("*").attr("disabled", result);
- $("#button_add_blacklist").attr("disabled", false);
- $("#button_remove_blacklist").attr("disabled", false);
- $("#custom_div_feedback").find("*").attr("disabled", false);
- if (value) {
- $('[name="button_subscription"]').addClass("clickable");
- } else {
- $('[name="button_subscription"]').removeClass("clickable");
- }
+ $("#div_opt_out").find('*').attr('disabled',result);
+ $("#button_add_blacklist").attr('disabled', false);
+ $("#button_remove_blacklist").attr('disabled', false);
+ if (value) { $('[name="button_subscription"]').addClass('clickable'); }
+ else { $('[name="button_subscription"]').removeClass('clickable'); }
}
diff --git a/mass_mailing_custom_unsubscribe/tests/test_ui.py b/mass_mailing_custom_unsubscribe/tests/test_ui.py
index 37844cc..7a73cc0 100644
--- a/mass_mailing_custom_unsubscribe/tests/test_ui.py
+++ b/mass_mailing_custom_unsubscribe/tests/test_ui.py
@@ -11,14 +11,14 @@ class UICase(HttpCase):
_tour_ready = "odoo.__DEBUG__.services['web_tour.tour'].tours.%s.ready"
def extract_url(self, mail, *args, **kwargs):
- url = mail._get_unsubscribe_url(self.email)
+ url = mail.mailing_id._get_unsubscribe_url(self.email, mail.res_id)
self.assertTrue(urls.url_parse(url).decode_query().get("token"))
self.assertTrue(url.startswith(self.domain))
self.url = url.replace(self.domain, "", 1)
return True
def setUp(self):
- super(UICase, self).setUp()
+ super().setUp()
self.email = "test.contact@example.com"
self.mail_postprocess_patch = mock.patch(
"odoo.addons.mass_mailing.models.mail_mail.MailMail."
@@ -47,7 +47,6 @@ class UICase(HttpCase):
"subject": "Test",
}
)
- self.mailing._onchange_model_and_list()
# HACK https://github.com/odoo/odoo/pull/14429
self.mailing.body_html = """
@@ -59,7 +58,7 @@ class UICase(HttpCase):
def tearDown(self):
del self.email, self.lists, self.contact, self.mailing, self.url
- super(UICase, self).tearDown()
+ super().tearDown()
def test_contact_unsubscription(self):
"""Test a mass mailing contact that wants to unsubscribe."""
diff --git a/mass_mailing_custom_unsubscribe/views/mail_unsubscription_reason_view.xml b/mass_mailing_custom_unsubscribe/views/mail_unsubscription_reason_view.xml
index 8047d1d..60ee0f5 100644
--- a/mass_mailing_custom_unsubscribe/views/mail_unsubscription_reason_view.xml
+++ b/mass_mailing_custom_unsubscribe/views/mail_unsubscription_reason_view.xml
@@ -43,11 +43,11 @@
-
+
+ Unsubscription Reasons
+ mail.unsubscription.reason
+ tree,form
+