[FIX] event: emails: no map if no location (webinar)

[FIX] event: emails: format of date: 31 Janvier instead of '20160131T1010110'
[IMP] event: better emails (button to zoom to event, cleaner text, show
      organizer phone and email)
This commit is contained in:
Fabien Pinckaers
2016-12-05 22:37:07 +01:00
parent d5a99319b0
commit f8c6c76044
3 changed files with 182 additions and 110 deletions
+164 -91
View File
@@ -42,7 +42,7 @@
</td>
<td style="text-align:right;vertical-align:middle;">
% if 'website_url' in object.event_id and object.event_id.website_url:
<a href="/event" style="text-decoration:none;color:#717188;">More Events</a>
<a href="${object.event_id.website_url}" style="background-color: #1abc9c; padding: 12px; font-weight: 12px; text-decoration: none; color: #fff; border-radius: 5px; font-size:16px;">View Event</a>
% endif
</td>
</tr>
@@ -51,50 +51,53 @@
<table style="width:600px;margin:0px auto;background:white;border:1px solid #e1e1e1;">
<tbody>
<tr>
<td style="padding:15px 20px 0px 20px;">
<h2 style="font-weight:300;">
Hi ${object.name}, here is your order confirmation for
<td style="padding:15px 20px 0px 20px; font-size:16px; font-weight:300;">
<p style="font-size:16px;">
Hi,
</p><p style="font-size:16px;">
We are happy to confirm your registration to the event:
</p>
<ul>
<li>Event:
% if 'website_url' in object.event_id and object.event_id.website_url:
<a href="${object.event_id.website_url}" style="color:#875A7B;text-decoration:none;">${object.event_id.name}</a>
% else:
<strong>${object.event_id.name}</strong>
% endif
</h2>
</li>
<li>Attendee: ${object.name}</li>
</ul>
<p style="font-size:16px;">
See you soon,
</p>
<p style="font-size:16px; margin-bottom: 30px">
<i>
-- <br/>
% if object.event_id.organizer_id:
${object.event_id.organizer_id.name}
% else:
The organizers.
% endif
</i>
</p>
</td>
</tr>
<tr>
<td style="padding:15px 20px 0px 20px;">
<table style="width:100%;border-top:1px solid #e1e1e1;">
<tr>
<td style="padding:25px 0px;vertical-align:top;">
<img src="/web_editor/font_to_img/61505/rgb(81,81,102)/34" style="padding:4px;max-width:inherit;" height="34">
</td>
<td style="padding:30px 10px 25px 10px;width:50%;vertical-align:top;">
% if object.event_id.address_id.street:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.street},</p>
% set location = object.event_id.address_id.street
% endif
% if object.event_id.address_id.street2:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.street2},</p>
% set location = '%s, %s' % (location, object.event_id.address_id.street2)
% endif
% if object.event_id.address_id.city:
${object.event_id.address_id.city},
% set location = '%s, %s' % (location, object.event_id.address_id.city)
% endif
% if object.event_id.address_id.state_id.name:
${object.event_id.address_id.state_id.name},
% set location = '%s, %s' % (location, object.event_id.address_id.state_id.name)
% endif
% if object.event_id.address_id.zip:
${object.event_id.address_id.zip},
% set location = '%s, %s' % (location, object.event_id.address_id.zip)
% endif
% if object.event_id.address_id.country_id.name:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.country_id.name}</p>
% set location = '%s, %s' % (location, object.event_id.address_id.country_id.name)
% endif
<td style="padding:25px 0px; text-align:center;">
<p>
Don't forget to <strong>add it to your calendar</strong>:
</p>
<a href="https://www.google.com/calendar/render?action=TEMPLATE&text=${object.event_id.name}&dates=${date_begin}/${date_end}&location=${location}" style="padding:3px 5px;border:1px solid #875A7B;color:#875A7B;text-decoration:none;border-radius:3px;" target="new"><img src="/web_editor/font_to_img/61525/rgb(135,90,123)/16" style="vertical-align:middle;" height="16"> Google</a>
<a href="https://bay02.calendar.live.com/calendar/calendar.aspx?rru=addevent&summary=${object.event_id.name}&dtstart=${date_begin}&dtend=${date_end}&location=${location}" style="padding:3px 5px;border:1px solid #875A7B;color:#875A7B;text-decoration:none;border-radius:3px;" target="new"><img src="/web_editor/font_to_img/61525/rgb(135,90,123)/16" style="vertical-align:middle;" height="16"> Outlook</a>
<a href="https://calendar.yahoo.com/?v=60&view=d&type=20&title=${object.event_id.name}&in_loc=${location}&st=${format_tz(object.event_id.date_begin, tz='UTC', format='%Y%m%dT%H%M%S')}&et=${format_tz(object.event_id.date_end, tz='UTC', format='%Y%m%dT%H%M%S')}" style="padding:3px 5px;border:1px solid #875A7B;color:#875A7B;text-decoration:none;border-radius:3px;" target="new"><img src="/web_editor/font_to_img/61525/rgb(135,90,123)/16" style="vertical-align:middle;" height="16"> Yahoo</a>
</td>
</tr>
</table>
<table style="width:100%;border-top:1px solid #e1e1e1;">
<tr>
<td style="padding:25px 0px;vertical-align:top;">
<img src="/web_editor/font_to_img/61555/rgb(81,81,102)/34" style="padding:4px;max-width:inherit;" height="34">
</td>
@@ -103,43 +106,82 @@
<div><strong>To</strong> ${object.event_id.date_end_located}</div>
<div style="font-size:12px;color:#9e9e9e"><i><strong>TZ</strong> ${object.event_id.date_tz}</i></div>
</td>
% if object.event_id.address_id.country_id.name:
<td style="padding:25px 0px;vertical-align:top;">
<img src="/web_editor/font_to_img/61505/rgb(81,81,102)/34" style="padding:4px;max-width:inherit;" height="34">
</td>
<td style="padding:30px 10px 25px 10px;width:50%;vertical-align:top;">
% if object.event_id.address_id.street:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.street}</p>
% set location = object.event_id.address_id.street
% endif
% if object.event_id.address_id.street2:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.street2}</p>
% set location = '%s, %s' % (location, object.event_id.address_id.street2)
% endif
<p style="margin:0px 0px 0px 0px;">
% if object.event_id.address_id.city:
${object.event_id.address_id.city},
% set location = '%s, %s' % (location, object.event_id.address_id.city)
% endif
% if object.event_id.address_id.state_id.name:
${object.event_id.address_id.state_id.name},
% set location = '%s, %s' % (location, object.event_id.address_id.state_id.name)
% endif
% if object.event_id.address_id.zip:
${object.event_id.address_id.zip}
% set location = '%s, %s' % (location, object.event_id.address_id.zip)
% endif
</p>
% if object.event_id.address_id.country_id.name:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.country_id.name}</p>
% set location = '%s, %s' % (location, object.event_id.address_id.country_id.name)
% endif
</td>
% endif
</tr>
</table>
% if object.event_id.organizer_id.email:
% if object.event_id.organizer_id:
<table style="width:100%;border-top:1px solid #e1e1e1;">
<tr>
<td style="padding:10px 0px 25px 0px;">
<h2 style="font-weight:300;margin:10px 0px">Questions about this event?</h2>
<div>Please contact the organizer at <a href="mailto:${object.event_id.organizer_id.email}" style="text-decoration:none;color:#875A7B;">${object.event_id.organizer_id.email}</a></div>
<p>Please contact the organizer:</p>
<ul>
<li>${object.event_id.organizer_id.name}</li>
% if object.event_id.organizer_id.email
<li>Mail: <a href="mailto:${object.event_id.organizer_id.email}" style="text-decoration:none;color:#875A7B;">${object.event_id.organizer_id.email}</a></li>
% endif
% if object.event_id.organizer_id.phone
<li>Phone: ${object.event_id.organizer_id.phone}</li>
% endif
</ul>
</td>
</tr>
</table>
% endif
<table style="width:100%;border-top:1px solid #e1e1e1;">
<tr>
<td style="padding:25px 0px;">
<strong>Add this event to your calendar</strong>
<a href="https://www.google.com/calendar/render?action=TEMPLATE&text=${object.event_id.name}&dates=${date_begin}/${date_end}&location=${location}" style="padding:3px 5px;border:1px solid #875A7B;color:#875A7B;text-decoration:none;border-radius:3px;" target="new"><img src="/web_editor/font_to_img/61525/rgb(135,90,123)/16" style="vertical-align:middle;" height="16"> Google</a>
<a href="https://bay02.calendar.live.com/calendar/calendar.aspx?rru=addevent&summary=${object.event_id.name}&dtstart=${date_begin}&dtend=${date_end}&location=${location}" style="padding:3px 5px;border:1px solid #875A7B;color:#875A7B;text-decoration:none;border-radius:3px;" target="new"><img src="/web_editor/font_to_img/61525/rgb(135,90,123)/16" style="vertical-align:middle;" height="16"> Outlook</a>
<a href="https://calendar.yahoo.com/?v=60&view=d&type=20&title=${object.event_id.name}&in_loc=${location}&st=${format_tz(object.event_id.date_begin, tz='UTC', format='%Y%m%dT%H%M%S')}&et=${format_tz(object.event_id.date_end, tz='UTC', format='%Y%m%dT%H%M%S')}" style="padding:3px 5px;border:1px solid #875A7B;color:#875A7B;text-decoration:none;border-radius:3px;" target="new"><img src="/web_editor/font_to_img/61525/rgb(135,90,123)/16" style="vertical-align:middle;" height="16"> Yahoo</a>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
% if object.event_id.address_id:
<div style="width:598px;margin:0px auto;border-left:1px solid #dddddd;border-right:1px solid #dddddd;border-bottom:1px solid #dddddd;">
<a href="https://maps.google.com/maps?q=${location}" target="new">
<img src="http://maps.googleapis.com/maps/api/staticmap?autoscale=1&size=598x100&maptype=roadmap&format=png&visual_refresh=true&markers=size:mid%7Ccolor:0xa5117d%7Clabel:%7C${location}" style="vertical-align:bottom;" />
<img src="http://maps.googleapis.com/maps/api/staticmap?autoscale=1&size=598x200&maptype=roadmap&format=png&visual_refresh=true&markers=size:mid%7Ccolor:0xa5117d%7Clabel:%7C${location}" style="vertical-align:bottom;" />
</a>
</div>
% endif
<table style="width:600px;margin:0px auto;text-align:center;">
<tbody>
<tr>
<td style="padding-top:10px;font-size: 12px;">
<div>This email was sent to <a href="mailto:${object.email}" style="text-decoration:none;color:#875A7B;">${object.email}</a></div>
<p style="margin:0px 0px 9px 0px;padding-top:10px;">Copyright © ${object.company_id.name}</p>
<div>Sent by ${object.company_id.name}</div>
% if 'website_url' in object.event_id and object.event_id.website_url:
<div>
Discover <a href="/event" style="text-decoration:none;color:#717188;">all our events</a>.
</div>
% endif
</td>
</tr>
</tbody>
@@ -155,7 +197,7 @@
<field name="email_to" >${object.partner_id.email or object.email|safe}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="reply_to">${object.event_id.reply_to|safe}</field>
<field name="subject">Reminder for ${object.event_id.name}</field>
<field name="subject">${object.event_id.name}: ${object.get_date_range_str()}</field>
<field name="body_html"><![CDATA[
<div style="background:#F3F5F6;color:#515166;padding:25px 0px;font-family:Arial,Helvetica,sans-serif;font-size:14px;">
% set date_begin = format_tz(object.event_id.date_begin, tz='UTC', format='%Y%m%dT%H%M%SZ')
@@ -170,7 +212,7 @@
</td>
<td style="text-align:right;vertical-align:middle;">
% if 'website_url' in object.event_id and object.event_id.website_url:
<a href="/event" style="text-decoration:none;color:#717188;">More Events</a>
<a href="${object.event_id.website_url}" style="background-color: #1abc9c; padding: 12px; font-weight: 12px; text-decoration: none; color: #fff; border-radius: 5px; font-size:16px;">View Event</a>
% endif
</td>
</tr>
@@ -179,55 +221,38 @@
<table style="width:600px;margin:0px auto;background:white;border:1px solid #e1e1e1;">
<tbody>
<tr>
<td style="padding:15px 20px 0px 20px;">
<h2 style="font-weight:300;">
Hi ${object.name},
</h2>
<td style="padding:15px 20px 0px 20px; font-size:16px;">
<p style="font-size:16px;">
Please keep in mind that the event
Hello,
</p>
<p style="font-size:16px;">
We are excited to remind you that the event
% if 'website_url' in object.event_id and object.event_id.website_url:
<a href="${object.event_id.website_url}" style="color:#875A7B;text-decoration:none;">${object.event_id.name}</a>
% else:
<strong>${object.event_id.name}</strong>
${object.event_id.name}
% endif
takes place on
<strong>${object.get_date_range_str()}</strong>
is starting
<strong>${object.get_date_range_str()}</strong>.
</p><p style="font-size:16px;">
We confirm your registration and hope to meet you there,
</p><p style="font-size:16px; margin-bottom: 30px">
<i>
-- <br/>
% if object.event_id.organizer_id:
${object.event_id.organizer_id.name}
% else:
The organizers.
% endif
</i>
</p>
</td>
</tr>
<tr>
<td style="padding:15px 20px 0px 20px;">
<table style="width:100%;border-top:1px solid #e1e1e1;">
<tr>
<td style="padding:25px 0px;vertical-align:top;">
<img src="/web_editor/font_to_img/61505/rgb(81,81,102)/34" style="padding:4px;max-width:inherit;" height="34">
</td>
<td style="padding:30px 10px 25px 10px;width:50%;vertical-align:top;">
% if object.event_id.address_id.street:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.street},</p>
% set location = object.event_id.address_id.street
% endif
% if object.event_id.address_id.street2:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.street2},</p>
% set location = '%s, %s' % (location, object.event_id.address_id.street2)
% endif
% if object.event_id.address_id.city:
${object.event_id.address_id.city},
% set location = '%s, %s' % (location, object.event_id.address_id.city)
% endif
% if object.event_id.address_id.state_id.name:
${object.event_id.address_id.state_id.name},
% set location = '%s, %s' % (location, object.event_id.address_id.state_id.name)
% endif
% if object.event_id.address_id.zip:
${object.event_id.address_id.zip},
% set location = '%s, %s' % (location, object.event_id.address_id.zip)
% endif
% if object.event_id.address_id.country_id.name:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.country_id.name}</p>
% set location = '%s, %s' % (location, object.event_id.address_id.country_id.name)
% endif
</td>
<td style="padding:25px 0px;vertical-align:top;">
<img src="/web_editor/font_to_img/61555/rgb(81,81,102)/34" style="padding:4px;max-width:inherit;" height="34">
</td>
@@ -236,6 +261,39 @@
<div><strong>To</strong> ${object.event_id.date_end_located}</div>
<div style="font-size:12px;color:#9e9e9e"><i><strong>TZ</strong> ${object.event_id.date_tz}</i></div>
</td>
% if object.event_id.address_id:
<td style="padding:25px 0px;vertical-align:top;">
<img src="/web_editor/font_to_img/61505/rgb(81,81,102)/34" style="padding:4px;max-width:inherit;" height="34">
</td>
<td style="padding:30px 10px 25px 10px;width:50%;vertical-align:top;">
% if object.event_id.address_id.street:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.street}</p>
% set location = object.event_id.address_id.street
% endif
% if object.event_id.address_id.street2:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.street2}</p>
% set location = '%s, %s' % (location, object.event_id.address_id.street2)
% endif
<p style="margin:0px 0px 0px 0px;">
% if object.event_id.address_id.city:
${object.event_id.address_id.city},
% set location = '%s, %s' % (location, object.event_id.address_id.city)
% endif
% if object.event_id.address_id.state_id.name:
${object.event_id.address_id.state_id.name},
% set location = '%s, %s' % (location, object.event_id.address_id.state_id.name)
% endif
% if object.event_id.address_id.zip:
${object.event_id.address_id.zip}
% set location = '%s, %s' % (location, object.event_id.address_id.zip)
% endif
</p>
% if object.event_id.address_id.country_id.name:
<p style="margin:0px 0px 0px 0px;">${object.event_id.address_id.country_id.name}</p>
% set location = '%s, %s' % (location, object.event_id.address_id.country_id.name)
% endif
</td>
% endif
</tr>
</table>
% if object.event_id.organizer_id.email:
@@ -243,7 +301,16 @@
<tr>
<td style="padding:10px 0px 25px 0px;">
<h2 style="font-weight:300;margin:10px 0px">Questions about this event?</h2>
<div>Please contact the organizer at <a href="mailto:${object.event_id.organizer_id.email}" style="text-decoration:none;color:#875A7B;">${object.event_id.organizer_id.email}</a></div>
<p>Please contact the organizer:</p>
<ul>
<li>${object.event_id.organizer_id.name}</li>
% if object.event_id.organizer_id.email
<li>Mail: <a href="mailto:${object.event_id.organizer_id.email}" style="text-decoration:none;color:#875A7B;">${object.event_id.organizer_id.email}</a></li>
% endif
% if object.event_id.organizer_id.phone
<li>Phone: ${object.event_id.organizer_id.phone}</li>
% endif
</ul>
</td>
</tr>
</table>
@@ -262,17 +329,23 @@
</tr>
</tbody>
</table>
% if object.event_id.address_id:
<div style="width:598px;margin:0px auto;border-left:1px solid #dddddd;border-right:1px solid #dddddd;border-bottom:1px solid #dddddd;">
<a href="https://maps.google.com/maps?q=${location}" target="new">
<img src="http://maps.googleapis.com/maps/api/staticmap?autoscale=1&size=598x100&maptype=roadmap&format=png&visual_refresh=true&markers=size:mid%7Ccolor:0xa5117d%7Clabel:%7C${location}" style="vertical-align:bottom;" />
<img src="http://maps.googleapis.com/maps/api/staticmap?autoscale=1&size=598x200&maptype=roadmap&format=png&visual_refresh=true&markers=size:mid%7Ccolor:0xa5117d%7Clabel:%7C${location}" style="vertical-align:bottom;" />
</a>
</div>
% endif
<table style="width:600px;margin:0px auto;text-align:center;">
<tbody>
<tr>
<td style="padding-top:10px;font-size: 12px;">
<div>This email was sent to <a href="mailto:${object.email}" style="text-decoration:none;color:#875A7B;">${object.email}</a></div>
<p style="margin:0px 0px 9px 0px;padding-top:10px;">Copyright © ${object.company_id.name}</p>
<p style="margin:0px 0px 9px 0px;padding-top:10px;">Sent by ${object.company_id.name}</p>
% if 'website_url' in object.event_id and object.event_id.website_url:
<div>
Discover <a href="/event" style="text-decoration:none;color:#717188;">all our events</a>.
</div>
% endif
</td>
</tr>
</tbody>
+12 -10
View File
@@ -61,12 +61,12 @@ class EventEvent(models.Model):
'interval_type': 'after_sub',
'template_id': self.env.ref('event.event_subscription')
}), (0, 0, {
'interval_nbr': 2,
'interval_nbr': 1,
'interval_unit': 'days',
'interval_type': 'before_event',
'template_id': self.env.ref('event.event_reminder')
}), (0, 0, {
'interval_nbr': 15,
'interval_nbr': 10,
'interval_unit': 'days',
'interval_type': 'before_event',
'template_id': self.env.ref('event.event_reminder')
@@ -430,15 +430,17 @@ class EventRegistration(models.Model):
today = fields.Datetime.from_string(fields.Datetime.now())
event_date = fields.Datetime.from_string(self.event_begin_date)
diff = (event_date.date() - today.date())
if diff.days == 0:
return _('Today')
if diff.days <= 0:
return _('today')
elif diff.days == 1:
return _('Tomorrow')
return _('tomorrow')
elif (diff.days < 7):
return _('in %d days') % (diff.days, )
elif (diff.days < 14):
return _('next week')
elif event_date.isocalendar()[1] == today.isocalendar()[1]:
return _('This week')
elif today.month == event_date.month:
return _('This month')
return _('this month')
elif event_date.month == (today + relativedelta(months=+1)):
return _('Next month')
return _('next month')
else:
return format_tz(self.env, self.event_begin_date, tz='UTC', format='%Y%m%dT%H%M%SZ')
return _('on ') + format_tz(self.env, self.event_begin_date, tz=self.event_id.date_tz or 'UTC')
+6 -9
View File
@@ -119,7 +119,7 @@ class TestEventFlow(TestEventCommon):
event_config.execute()
def test_event_data(self):
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'Tomorrow')
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'tomorrow')
def test_event_date_range(self):
self.patcher = patch('odoo.addons.event.models.event.fields.Datetime', wraps=Datetime)
@@ -128,19 +128,16 @@ class TestEventFlow(TestEventCommon):
self.mock_datetime.now.return_value = Datetime.to_string(datetime.datetime(2015, 12, 31, 12, 0))
self.event_0.registration_ids.event_begin_date = datetime.datetime(2015, 12, 31, 18, 0)
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'Today')
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'today')
self.event_0.registration_ids.event_begin_date = datetime.datetime(2016, 1, 1, 6, 0)
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'Tomorrow')
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'tomorrow')
self.event_0.registration_ids.event_begin_date = datetime.datetime(2016, 1, 2, 6, 0)
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'This week')
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'in 2 days')
self.event_0.registration_ids.event_begin_date = datetime.datetime(2016, 2, 1, 6, 0)
self.assertTrue('T' in self.event_0.registration_ids.get_date_range_str())
self.mock_datetime.now.return_value = Datetime.to_string(datetime.datetime(2015, 12, 15, 12, 0))
self.mock_datetime.now.return_value = Datetime.to_string(datetime.datetime(2015, 12, 10, 12, 0))
self.event_0.registration_ids.event_begin_date = datetime.datetime(2015, 12, 31, 6, 0)
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'This month')
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'this month')
self.patcher.stop()