Browse Source

Merge pull request #179 from Tecnativa/10.0-website_mass_mailing_name

[MIG][website_mass_mailing_name] Migration to v10
pull/154/merge
Moises Lopez - https://www.vauxoo.com/ 8 years ago
committed by GitHub
parent
commit
c99050432f
  1. 1
      .travis.yml
  2. 60
      website_mass_mailing_name/README.rst
  3. 4
      website_mass_mailing_name/__init__.py
  4. 24
      website_mass_mailing_name/__manifest__.py
  5. 4
      website_mass_mailing_name/controllers/__init__.py
  6. 28
      website_mass_mailing_name/controllers/main.py
  7. 17
      website_mass_mailing_name/demo/assets.xml
  8. 24
      website_mass_mailing_name/i18n/de.po
  9. 23
      website_mass_mailing_name/i18n/es.po
  10. 24
      website_mass_mailing_name/i18n/fr.po
  11. 24
      website_mass_mailing_name/i18n/sl.po
  12. BIN
      website_mass_mailing_name/static/description/icon.png
  13. 10
      website_mass_mailing_name/static/src/css/website_mass_mailing_name.sass
  14. 50
      website_mass_mailing_name/static/src/js/editor_tour.js
  15. 77
      website_mass_mailing_name/static/src/js/public_tour.js
  16. 59
      website_mass_mailing_name/static/src/js/website_mass_mailing_name.js
  17. 17
      website_mass_mailing_name/templates/assets.xml
  18. 18
      website_mass_mailing_name/templates/snippets.xml
  19. 4
      website_mass_mailing_name/tests/__init__.py
  20. 25
      website_mass_mailing_name/tests/test_ui.py

1
.travis.yml

@ -15,6 +15,7 @@ addons:
env: env:
global: global:
- VERSION="10.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0" - VERSION="10.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
- PHANTOMJS_VERSION="2.1.2" WEBSITE_REPO="1"
- TRANSIFEX_USER='transbot@odoo-community.org' - TRANSIFEX_USER='transbot@odoo-community.org'
- secure: "GRXFURohRzzBbzRovVHd+cObj1yBe9x9bddKqUo7jEGPo+MYHKfGo1M7disTDq6HPLgCwacbhWRsMavGORB3AEkoNewP7q31MKGGPiS8Com9wMmYUtDPs4ZiuUlakJjvfsmGlpwTWUe1Xv1YSZweXVGIESAn0SwhzKH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k922pH5Bxmt2hB1BOzeOqCGnE3wTOAuacuDIfyJaIpTmNMALWeWk/EkMghDZXRRCEueZO5QR2LdcxJk86x5ANj6sxKVo+nkl+x93ZBsehqELn4rTHwjAaA+Ck3vWRkzfV8nJ3A="
matrix: matrix:

60
website_mass_mailing_name/README.rst

@ -0,0 +1,60 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-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/10.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/10.0
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.

4
website_mass_mailing_name/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import controllers

24
website_mass_mailing_name/__manifest__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Mass Mailing Subscription Snippet With Name",
"summary": "Ask for name when subscribing, and create and/or link partner",
"version": "10.0.1.0.0",
"category": "Website",
"website": "https://tecnativa.com/",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": [
"website_mass_mailing",
],
"demo": [
"demo/assets.xml",
],
"data": [
"templates/assets.xml",
"templates/snippets.xml",
],
}

4
website_mass_mailing_name/controllers/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import main

28
website_mass_mailing_name/controllers/main.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo.addons.website_mass_mailing.controllers import main
from odoo.http import request, route
class MassMailController(main.MassMailController):
@route()
def is_subscriber(self, *args, **kwargs):
"""Get user name too."""
result = super(MassMailController, self).is_subscriber(*args, **kwargs)
if request.website.user_id != request.env.user:
name = request.env.user.name
else:
name = request.session.get("mass_mailing_name", "")
return dict(result, name=name)
@route()
def subscribe(self, list_id, email, **post):
"""Store email with name in session."""
result = super(MassMailController, self).subscribe(
list_id, email, **post)
name, email = request.env['mail.mass_mailing.contact'].sudo() \
.get_name_email(email)
request.session["mass_mailing_name"] = name if name != email else ""
return result

17
website_mass_mailing_name/demo/assets.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="assets_frontend_demo"
inherit_id="website.assets_frontend">
<xpath expr=".">
<script type="text/javascript"
src="/website_mass_mailing_name/static/src/js/editor_tour.js"/>
<script type="text/javascript"
src="/website_mass_mailing_name/static/src/js/public_tour.js"/>
</xpath>
</template>
</odoo>

24
website_mass_mailing_name/i18n/de.po

@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_mass_mailing_name
#
# Translators:
# Rudolf Schnapka <rs@techno-flex.de>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-30 10:22+0000\n"
"PO-Revision-Date: 2017-04-30 10:22+0000\n"
"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>, 2017\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: website_mass_mailing_name
#: view:website:website.snippets
msgid "your name..."
msgstr "Ihr Name..."

23
website_mass_mailing_name/i18n/es.po

@ -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..."

24
website_mass_mailing_name/i18n/fr.po

@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_mass_mailing_name
#
# Translators:
# Christophe CHAUVET <christophe.chauvet@gmail.com>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-30 01:08+0000\n"
"PO-Revision-Date: 2016-06-30 01:08+0000\n"
"Last-Translator: Christophe CHAUVET <christophe.chauvet@gmail.com>, 2016\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: website_mass_mailing_name
#: view:website:website.snippets
msgid "your name..."
msgstr "votre nom..."

24
website_mass_mailing_name/i18n/sl.po

@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_mass_mailing_name
#
# Translators:
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-30 01:08+0000\n"
"PO-Revision-Date: 2016-06-30 01:08+0000\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>, 2016\n"
"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
#. module: website_mass_mailing_name
#: view:website:website.snippets
msgid "your name..."
msgstr "vaše ime..."

BIN
website_mass_mailing_name/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 15 KiB

10
website_mass_mailing_name/static/src/css/website_mass_mailing_name.sass

@ -0,0 +1,10 @@
/*! Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
.js_subscribe
.form-control
width: 50%
&[data-subscribe="on"]
.js_subscribe_name:not([disabled])
display: none

50
website_mass_mailing_name/static/src/js/editor_tour.js

@ -0,0 +1,50 @@
/* Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define("website_mass_mailing_name.editor_tour", function (require) {
"use strict";
var base = require("web_editor.base");
var tour = require("web_tour.tour");
tour.register(
"mass_mailing_name_editor",
{
test: true,
wait_for: base.ready(),
},
[
{
content: "Edit the homepage",
trigger: ".o_menu_systray a[data-action=edit]",
},
{
content: "Drag and drop a text snippet",
trigger: ".oe_snippet[name='Text Block'] .oe_snippet_thumbnail",
run: "drag_and_drop #wrap",
},
{
content: "Drag and drop a newsletter snippet",
trigger: ".oe_snippet[name='Newsletter'] .oe_snippet_thumbnail",
run: "drag_and_drop #wrap .s_text_block",
},
{
content: "Let the default mailing list",
trigger: ".modal-dialog button:contains('Continue')",
},
{
content: "Save changes",
extra_trigger: "body:not(:has(.modal:visible))",
trigger: "#web_editor-top-edit button[data-action=save]",
},
{
content: "Subscribe Administrator",
extra_trigger: "body:not(:has(#web_editor-top-edit))",
trigger: ".js_subscribe_btn",
},
{
content: "Open user menu",
extra_trigger: ".js_subscribe .alert-success",
trigger: "#top_menu span:contains('Administrator')",
},
]
);
});

77
website_mass_mailing_name/static/src/js/public_tour.js

@ -0,0 +1,77 @@
/* Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define("website_mass_mailing_name.public_tour", function (require) {
"use strict";
var base = require("web_editor.base");
var tour = require("web_tour.tour");
tour.register(
"mass_mailing_name_public",
{
test: true,
wait_for: base.ready(),
},
[
{
content: "Try to subscribe without data",
trigger: ".js_subscribe_btn",
},
{
content: "Enter a name",
extra_trigger: ".js_subscribe.has-error",
trigger: ".js_subscribe_name",
run: "text Visitor",
},
{
content: "Try to subscribe without email",
trigger: ".js_subscribe_btn",
},
{
content: "Remove the name",
extra_trigger: ".js_subscribe.has-error",
trigger: ".js_subscribe_name",
run: function () {
$(".js_subscribe_name").val("");
},
},
{
content: "Enter an email",
trigger: ".js_subscribe_email",
run: "text example@example.com",
},
{
content: "Try to subscribe without name",
trigger: ".js_subscribe_btn",
},
{
content: "Enter the name again",
extra_trigger: ".js_subscribe.has-error",
trigger: ".js_subscribe_name",
run: "text Visitor",
},
{
content: "Enter a wrong email",
trigger: ".js_subscribe_email",
run: "text bad email",
},
{
content: "Try to subscribe with a bad email",
trigger: ".js_subscribe_btn",
},
{
content: "Enter the good email",
extra_trigger: ".js_subscribe.has-error",
trigger: ".js_subscribe_email",
run: "text example@example.com",
},
{
content: "Try to subscribe with good information",
trigger: ".js_subscribe_btn",
},
{
content: "Subscription successful",
trigger: ".js_subscribe:not(.has-error) .alert-success",
},
]
);
});

59
website_mass_mailing_name/static/src/js/website_mass_mailing_name.js

@ -0,0 +1,59 @@
/* Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define("website_mass_mailing_name.subscribe", function (require) {
"use strict";
require("mass_mailing.website_integration");
var animation = require("web_editor.snippets.animation");
animation.registry.subscribe.include({
start: function(editable_mode) {
this.$email = this.$target.find(".js_subscribe_email");
this.$name = this.$target.find(".js_subscribe_name");
// Thanks upstream for your @$&#?!! inheritance-ready code.
// Injecting ajax events to modify behavior of snippet.
if (this.$name) {
$(document).ajaxSend($.proxy(this.on_ajax_send, this));
}
return this._super(editable_mode);
},
on_click: function() {
var email_error = !this.$email.val().match(/.+@.+/),
name_error = this.$name.length && !this.$name.val(),
values = {
"list_id": this.$target.data('list-id'),
"email": this.$email.val(),
};
// Stop on error
if (email_error || name_error) {
this.$target.addClass("has-error")
return false;
}
return this._super.apply(this, arguments);
},
on_ajax_send: function(event, jqXHR, ajaxOptions) {
// Add handlers on correct requests
if (ajaxOptions.url == "/website_mass_mailing/is_subscriber") {
jqXHR.done($.proxy(this.on_start, this));
} else if (ajaxOptions.url == "/website_mass_mailing/subscribe") {
var data = JSON.parse(ajaxOptions.data);
data.params.email = _.str.sprintf(
"%s <%s>",
this.$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)
);
},
});
});

17
website_mass_mailing_name/templates/assets.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="assets_frontend"
inherit_id="website.assets_frontend">
<xpath expr=".">
<link rel="stylesheet"
href="/website_mass_mailing_name/static/src/css/website_mass_mailing_name.sass"/>
<script type="text/javascript"
src="/website_mass_mailing_name/static/src/js/website_mass_mailing_name.js"/>
</xpath>
</template>
</odoo>

18
website_mass_mailing_name/templates/snippets.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="s_newsletter_subscribe_form"
inherit_id="website_mass_mailing.s_newsletter_subscribe_form">
<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>
</odoo>

4
website_mass_mailing_name/tests/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import test_ui

25
website_mass_mailing_name/tests/test_ui.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo.http import root
from odoo.tests.common import HttpCase
class UICase(HttpCase):
def test_ui(self):
"""Test snippet behavior."""
tour = "odoo.__DEBUG__.services['web_tour.tour'].%s"
# Admin edits home page and adds subscription snippet
self.phantom_js(
"/",
tour % "run('mass_mailing_name_editor')",
tour % "tours.mass_mailing_name_editor.ready",
login="admin")
# Forced log out
root.session_store.delete(self.session)
# Public user uses subscription snippet
self.phantom_js(
"/",
tour % "run('mass_mailing_name_public')",
tour % "tours.mass_mailing_name_public.ready")
Loading…
Cancel
Save