Browse Source
[MIG][website_mass_mailing_name] Migration to v10
[MIG][website_mass_mailing_name] Migration to v10
- Relicense to LGPL. - Fix all known issues. - Enable tour only in demo instances. - Fix Sass headers. - Remove compiled css and maps. - Update JS modules to new api. - Update tour to new tours api. - Update module structure to match latest template.pull/179/head
Jairo Llopis
7 years ago
committed by
Moisés López
19 changed files with 254 additions and 261 deletions
-
5.travis.yml
-
17website_mass_mailing_name/README.rst
-
3website_mass_mailing_name/__init__.py
-
17website_mass_mailing_name/__manifest__.py
-
3website_mass_mailing_name/controllers/__init__.py
-
28website_mass_mailing_name/controllers/main.py
-
17website_mass_mailing_name/demo/assets.xml
-
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
-
5website_mass_mailing_name/static/src/css/website_mass_mailing_name.sass
-
50website_mass_mailing_name/static/src/js/editor_tour.js
-
77website_mass_mailing_name/static/src/js/public_tour.js
-
58website_mass_mailing_name/static/src/js/website_mass_mailing_name.js
-
138website_mass_mailing_name/static/src/js/website_mass_mailing_name.tour.js
-
17website_mass_mailing_name/templates/assets.xml
-
14website_mass_mailing_name/templates/snippets.xml
-
3website_mass_mailing_name/tests/__init__.py
-
22website_mass_mailing_name/tests/test_ui.py
-
23website_mass_mailing_name/views/assets.xml
@ -1,5 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from . import controllers |
@ -1,21 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
# 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": "8.0.1.0.0", |
|||
"version": "10.0.1.0.0", |
|||
"category": "Website", |
|||
"website": "https://tecnativa.com/", |
|||
"author": "Tecnativa, Odoo Community Association (OCA)", |
|||
"license": "AGPL-3", |
|||
"license": "LGPL-3", |
|||
"application": False, |
|||
"installable": True, |
|||
"depends": [ |
|||
"mass_mailing", |
|||
"website_mass_mailing", |
|||
], |
|||
"demo": [ |
|||
"demo/assets.xml", |
|||
], |
|||
"data": [ |
|||
"views/assets.xml", |
|||
"views/snippets.xml", |
|||
"templates/assets.xml", |
|||
"templates/snippets.xml", |
|||
], |
|||
} |
@ -1,5 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from . import main |
@ -1,22 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from openerp.addons.mass_mailing.controllers.main import MassMailController |
|||
from openerp.http import request, route |
|||
from odoo.addons.website_mass_mailing.controllers import main |
|||
from odoo.http import request, route |
|||
|
|||
|
|||
class MassMailingPartner(MassMailController): |
|||
class MassMailController(main.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 "" |
|||
result = super(MassMailController, self).is_subscriber(*args, **kwargs) |
|||
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 |
|||
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 |
@ -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> |
@ -1,9 +0,0 @@ |
|||
@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:not([disabled]) { |
|||
display: none; } |
|||
|
|||
/*# sourceMappingURL=website_mass_mailing_name.css.map */ |
@ -1,7 +0,0 @@ |
|||
{ |
|||
"version": 3, |
|||
"mappings": ";;;AAKI,2BAAa;EACT,KAAK,EAAE,GAAG;AAGV,qEAAkC;EAC9B,OAAO,EAAE,IAAI", |
|||
"sources": ["website_mass_mailing_name.sass"], |
|||
"names": [], |
|||
"file": "website_mass_mailing_name.css" |
|||
} |
@ -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')", |
|||
}, |
|||
] |
|||
); |
|||
}); |
@ -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", |
|||
}, |
|||
] |
|||
); |
|||
}); |
@ -1,138 +0,0 @@ |
|||
/* © 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", |
|||
}, |
|||
// Expect this test to work in v9 when uncommenting this
|
|||
// {
|
|||
// title: "Subscription successful",
|
|||
// waitFor: ".js_subscribe:not(.has-error) \
|
|||
// .alert-success:visible",
|
|||
// },
|
|||
], |
|||
}); |
|||
})(jQuery); |
@ -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> |
@ -1,5 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from . import test_ui |
@ -1,15 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from openerp.tests.common import HttpCase |
|||
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( |
|||
"/", |
|||
"openerp.Tour.run('mass_mailing_partner', 'test')", |
|||
"openerp.Tour.tours.mass_mailing_partner", |
|||
"admin") |
|||
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") |
@ -1,23 +0,0 @@ |
|||
<?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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue