Browse Source
[8.0][ADD][website_snippet_mass_mailing_partner] Snippet + name
[8.0][ADD][website_snippet_mass_mailing_partner] Snippet + name
Let you have the name field in the mass mailing subscription snippet. Leave most logic to base module. Make name field autofilled if user data is available. Add tour test.pull/66/head
Jairo Llopis
9 years ago
17 changed files with 432 additions and 0 deletions
-
1oca_dependencies.txt
-
67website_mass_mailing_name/README.rst
-
5website_mass_mailing_name/__init__.py
-
21website_mass_mailing_name/__openerp__.py
-
5website_mass_mailing_name/controllers/__init__.py
-
22website_mass_mailing_name/controllers/main.py
-
23website_mass_mailing_name/i18n/es.po
-
BINwebsite_mass_mailing_name/static/description/icon.png
-
9website_mass_mailing_name/static/src/css/website_mass_mailing_name.css
-
7website_mass_mailing_name/static/src/css/website_mass_mailing_name.css.map
-
11website_mass_mailing_name/static/src/css/website_mass_mailing_name.sass
-
61website_mass_mailing_name/static/src/js/website_mass_mailing_name.js
-
137website_mass_mailing_name/static/src/js/website_mass_mailing_name.tour.js
-
5website_mass_mailing_name/tests/__init__.py
-
15website_mass_mailing_name/tests/test_ui.py
-
23website_mass_mailing_name/views/assets.xml
-
20website_mass_mailing_name/views/snippets.xml
@ -0,0 +1 @@ |
|||||
|
crm |
@ -0,0 +1,67 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
=========================================== |
||||
|
Mass Mailing Subscription Snippet With Name |
||||
|
=========================================== |
||||
|
|
||||
|
This module extends the functionality of mass mailings to support asking for |
||||
|
the contact name directly in the subscription snippet. |
||||
|
|
||||
|
If you want to get partners created automatically and linked to the contacts, |
||||
|
you can additionally install the `mass_mailing_partner |
||||
|
<https://www.odoo.com/apps/modules/8.0/mass_mailing_partner/>`_ module. |
||||
|
|
||||
|
Usage |
||||
|
===== |
||||
|
|
||||
|
To use this module, you need to: |
||||
|
|
||||
|
#. Go to any website page. |
||||
|
#. Insert any structure block. |
||||
|
#. Insert the *Newsletter* block as you would usually, inside a structure one. |
||||
|
#. Choose the newsletter of your liking. |
||||
|
#. Press *Save*. |
||||
|
|
||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
||||
|
:alt: Try me on Runbot |
||||
|
:target: https://runbot.odoo-community.org/runbot/186/8.0 |
||||
|
|
||||
|
Known issues / Roadmap |
||||
|
====================== |
||||
|
|
||||
|
* If you use Firefox, you could hit https://github.com/odoo/odoo/issues/7722. |
||||
|
Just use Chromium to work with this snippet until you update to Odoo 9.0. |
||||
|
* When migrating to v9, improve the tour test to check autofilling of inputs. |
||||
|
|
||||
|
Bug Tracker |
||||
|
=========== |
||||
|
|
||||
|
Bugs are tracked on `GitHub Issues |
||||
|
<https://github.com/OCA/website/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. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. image:: https://odoo-community.org/logo.png |
||||
|
:alt: Odoo Community Association |
||||
|
:target: https://odoo-community.org |
||||
|
|
||||
|
This module is maintained by the OCA. |
||||
|
|
||||
|
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. |
||||
|
|
||||
|
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,5 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
from . import controllers |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
{ |
||||
|
"name": "Mass Mailing Subscription Snippet With Name", |
||||
|
"summary": "Ask for name when subscribing, and create and/or link partner", |
||||
|
"version": "8.0.1.0.0", |
||||
|
"category": "Website", |
||||
|
"website": "https://tecnativa.com/", |
||||
|
"author": "Tecnativa, Odoo Community Association (OCA)", |
||||
|
"license": "AGPL-3", |
||||
|
"application": False, |
||||
|
"installable": True, |
||||
|
"depends": [ |
||||
|
"mass_mailing", |
||||
|
], |
||||
|
"data": [ |
||||
|
"views/assets.xml", |
||||
|
"views/snippets.xml", |
||||
|
], |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
from . import main |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
from openerp.addons.mass_mailing.controllers.main import MassMailController |
||||
|
from openerp.http import request, route |
||||
|
|
||||
|
|
||||
|
class MassMailingPartner(MassMailController): |
||||
|
@route() |
||||
|
def is_subscriber(self, *args, **kwargs): |
||||
|
"""Get user name too.""" |
||||
|
result = super(MassMailingPartner, self).is_subscriber(*args, **kwargs) |
||||
|
email = result.get("email") or "" |
||||
|
if request.website.user_id != request.env.user: |
||||
|
name = request.env.user.name |
||||
|
else: |
||||
|
name, email = (request.env["mail.mass_mailing.contact"] |
||||
|
.get_name_email(email, context=request.context)) |
||||
|
result["name"] = name |
||||
|
result["email"] = email |
||||
|
return result |
@ -0,0 +1,23 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * website_mass_mailing_name |
||||
|
# |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 8.0\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2016-05-24 15:03+0000\n" |
||||
|
"PO-Revision-Date: 2016-05-24 17:04+0200\n" |
||||
|
"Last-Translator: <>\n" |
||||
|
"Language-Team: \n" |
||||
|
"MIME-Version: 1.0\n" |
||||
|
"Content-Type: text/plain; charset=UTF-8\n" |
||||
|
"Content-Transfer-Encoding: 8bit\n" |
||||
|
"Plural-Forms: \n" |
||||
|
"Language: es\n" |
||||
|
"X-Generator: Poedit 1.8.7.1\n" |
||||
|
|
||||
|
#. module: website_mass_mailing_name |
||||
|
#: view:website:website.snippets |
||||
|
msgid "your name..." |
||||
|
msgstr "su nombre..." |
After Width: 128 | Height: 128 | Size: 15 KiB |
@ -0,0 +1,9 @@ |
|||||
|
@charset "UTF-8"; |
||||
|
/* © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ |
||||
|
.js_subscribe .form-control { |
||||
|
width: 50%; } |
||||
|
.js_subscribe[data-subscribe=on] .js_subscribe_name { |
||||
|
display: none; } |
||||
|
|
||||
|
/*# sourceMappingURL=website_mass_mailing_name.css.map */ |
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"version": 3, |
||||
|
"mappings": ";;;AAKI,2BAAa;EACT,KAAK,EAAE,GAAG;AAGV,mDAAkB;EACd,OAAO,EAAE,IAAI", |
||||
|
"sources": ["website_mass_mailing_name.sass"], |
||||
|
"names": [], |
||||
|
"file": "website_mass_mailing_name.css" |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
@charset "UTF-8" |
||||
|
/* © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
.js_subscribe |
||||
|
.form-control |
||||
|
width: 50% |
||||
|
|
||||
|
&[data-subscribe=on] |
||||
|
.js_subscribe_name |
||||
|
display: none |
@ -0,0 +1,61 @@ |
|||||
|
/* © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
|
|
||||
|
"use strict"; |
||||
|
(function ($) { |
||||
|
openerp.website.snippet.animationRegistry.subscribe.include({ |
||||
|
start: function(editable_mode) { |
||||
|
var self = this; |
||||
|
self.$email = self.$target.find(".js_subscribe_email"); |
||||
|
self.$name = self.$target.find(".js_subscribe_name"); |
||||
|
|
||||
|
// Thanks upstream for your @$&#?!! inheritance-ready code.
|
||||
|
// Injecting ajax events to modify behavior of snippet.
|
||||
|
if (self.$name) { |
||||
|
$(document).ajaxSend(function(event, jqXHR, ajaxOptions) { |
||||
|
return self.on_ajax_send(event, jqXHR, ajaxOptions); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
return self._super(editable_mode); |
||||
|
}, |
||||
|
on_click: function() { |
||||
|
var self = this, |
||||
|
email_error = !self.$email.val().match(/.+@.+/), |
||||
|
name_error = self.$name.length && !self.$name.val(), |
||||
|
values = { |
||||
|
"list_id": self.$target.data('list-id'), |
||||
|
"email": self.$email.val(), |
||||
|
}; |
||||
|
|
||||
|
// Stop on error
|
||||
|
if (email_error || name_error) { |
||||
|
self.$target.addClass("has-error") |
||||
|
return false; |
||||
|
} |
||||
|
return self._super(); |
||||
|
}, |
||||
|
on_ajax_send: function(event, jqXHR, ajaxOptions) { |
||||
|
var self = this; |
||||
|
|
||||
|
// Add handlers on correct requests
|
||||
|
if (ajaxOptions.url == "/website_mass_mailing/is_subscriber") { |
||||
|
jqXHR.then(function(data) { |
||||
|
return self.on_start(data); |
||||
|
}); |
||||
|
} else if (ajaxOptions.url == "/website_mass_mailing/subscribe") { |
||||
|
var data = JSON.parse(ajaxOptions.data); |
||||
|
data.params.email = |
||||
|
self.$name.val() + " <" + data.params.email + ">"; |
||||
|
ajaxOptions.data = JSON.stringify(data); |
||||
|
} |
||||
|
}, |
||||
|
on_start: function(data) { |
||||
|
this.$name.val(data.result.name) |
||||
|
.attr( |
||||
|
"disabled", |
||||
|
Boolean(data.result.is_subscriber && data.result.name.length) |
||||
|
); |
||||
|
}, |
||||
|
}); |
||||
|
})(jQuery); |
@ -0,0 +1,137 @@ |
|||||
|
/* © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
|
|
||||
|
"use strict"; |
||||
|
(function ($) { |
||||
|
openerp.Tour.register({ |
||||
|
id: "mass_mailing_partner", |
||||
|
name: "Insert a newsletter snippet and subscribe", |
||||
|
path: "/", |
||||
|
mode: "test", |
||||
|
steps: [ |
||||
|
{ |
||||
|
title: "Edit the homepage", |
||||
|
waitFor: "button[data-action=edit]", |
||||
|
element: "button[data-action=edit]", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Click on Insert Blocks", |
||||
|
waitFor: "button[data-action=snippet]", |
||||
|
element: "button[data-action=snippet]", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Click on Structure", |
||||
|
waitFor: "a[href='#snippet_structure']", |
||||
|
element: "a[href='#snippet_structure']", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Drag and drop a text snippet", |
||||
|
waitFor: ".oe_snippet:contains('Text Block'):visible", |
||||
|
snippet: ".oe_snippet:contains('Text Block')", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Click on Insert Blocks again", |
||||
|
waitFor: "#wrap h2:contains('A Great Headline'), \ |
||||
|
button[data-action=snippet]", |
||||
|
element: "button[data-action=snippet]", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Click on Content", |
||||
|
waitFor: "a[href='#snippet_content']", |
||||
|
element: "a[href='#snippet_content']", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Drag and drop a newsletter snippet", |
||||
|
waitFor: ".oe_snippet:contains('Newsletter'):visible", |
||||
|
snippet: ".oe_snippet:contains('Newsletter')", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Let the default mailing list", |
||||
|
waitFor: ".modal button:contains('Continue'):visible", |
||||
|
element: ".modal button:contains('Continue'):visible", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Save changes", |
||||
|
waitNot: ".modal:visible", |
||||
|
element: "button[data-action=save]", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Subscribe Administrator", |
||||
|
waitFor: "button[data-action=edit]:visible, \ |
||||
|
.js_subscribe_btn:visible", |
||||
|
element: ".js_subscribe_btn", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Open user menu", |
||||
|
waitFor: ".js_subscribe .alert-success:visible", |
||||
|
element: "#top_menu span:contains('Administrator')", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Log out", |
||||
|
waitFor: ".js_usermenu a:contains('Logout'):visible", |
||||
|
element: ".js_usermenu a:contains('Logout'):visible", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Try to subscribe without data", |
||||
|
waitFor: "#top_menu a[href='/web/login']:visible, \ |
||||
|
.js_subscribe_btn:visible", |
||||
|
element: ".js_subscribe_btn", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Enter a name", |
||||
|
waitFor: ".js_subscribe.has-error", |
||||
|
element: ".js_subscribe_name", |
||||
|
sampleText: "Visitor", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Try to subscribe without email", |
||||
|
element: ".js_subscribe_btn", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Remove the name", |
||||
|
waitFor: ".js_subscribe.has-error", |
||||
|
element: ".js_subscribe_name", |
||||
|
sampleText: "", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Enter an email", |
||||
|
element: ".js_subscribe_email", |
||||
|
sampleText: "example@example.com", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Try to subscribe without name", |
||||
|
element: ".js_subscribe_btn", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Enter the name again", |
||||
|
waitFor: ".js_subscribe.has-error", |
||||
|
element: ".js_subscribe_name", |
||||
|
sampleText: "Visitor", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Enter a wrong email", |
||||
|
element: ".js_subscribe_email", |
||||
|
sampleText: "bad email", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Try to subscribe with a bad email", |
||||
|
element: ".js_subscribe_btn", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Enter the good email", |
||||
|
waitFor: ".js_subscribe.has-error", |
||||
|
element: ".js_subscribe_email", |
||||
|
sampleText: "example@example.com", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Try to subscribe with good information", |
||||
|
element: ".js_subscribe_btn", |
||||
|
}, |
||||
|
{ |
||||
|
title: "Subscription successful", |
||||
|
waitFor: ".js_subscribe:not(.has-error) \ |
||||
|
.alert-success:visible", |
||||
|
}, |
||||
|
], |
||||
|
}); |
||||
|
})(jQuery); |
@ -0,0 +1,5 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
from . import test_ui |
@ -0,0 +1,15 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
from openerp.tests.common import HttpCase |
||||
|
|
||||
|
|
||||
|
class UICase(HttpCase): |
||||
|
def test_ui(self): |
||||
|
"""Test snippet behavior.""" |
||||
|
self.phantom_js( |
||||
|
"/", |
||||
|
"openerp.Tour.run('mass_mailing_partner', 'test')", |
||||
|
"openerp.Tour.tours.mass_mailing_partner", |
||||
|
"admin") |
@ -0,0 +1,23 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
||||
|
|
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<template id="assets_frontend" |
||||
|
inherit_id="mass_mailing.assets_frontend"> |
||||
|
<xpath expr="."> |
||||
|
<link rel="stylesheet" |
||||
|
href="/website_mass_mailing_name/static/src/css/website_mass_mailing_name.css"/> |
||||
|
<script type="text/javascript" |
||||
|
src="/website_mass_mailing_name/static/src/js/website_mass_mailing_name.js"/> |
||||
|
<t t-if="request.registry.test_cr"> |
||||
|
<script type="text/javascript" |
||||
|
src="/website_mass_mailing_name/static/src/js/website_mass_mailing_name.tour.js"/> |
||||
|
</t> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1,20 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
||||
|
|
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<template id="mailing_list_subscribe" |
||||
|
inherit_id="mass_mailing.mailing_list_subscribe"> |
||||
|
<xpath expr="//input[@class='js_subscribe_email form-control']" |
||||
|
position="before"> |
||||
|
<input |
||||
|
name="name" |
||||
|
class="js_subscribe_name form-control" |
||||
|
placeholder="your name..."/> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue