kopia lustrzana https://github.com/wagtail/wagtail
rodzic
0938c8e0c0
commit
b9cfc24b37
|
@ -34,6 +34,7 @@ Changelog
|
|||
* Fix: Very long words in page listings are now broken where necessary (Kevin Howbrook)
|
||||
* Fix: Language chosen in user preferences no longer persists on subsequent requests (Bojan Mihelac)
|
||||
* Fix: Prevent new block IDs from being assigned on repeated calls to `StreamBlock.get_prep_value` (Colin Klein)
|
||||
* Fix: Prevent broken images in notification emails when static files are hosted on a remote domain (Eduard Luca)
|
||||
|
||||
|
||||
2.6.1 (05.08.2019)
|
||||
|
|
|
@ -396,6 +396,7 @@ Contributors
|
|||
* Dani Hodovic
|
||||
* Janne Alatalo
|
||||
* Colin Klein
|
||||
* Eduard Luca
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -58,6 +58,7 @@ Bug fixes
|
|||
* Very long words in page listings are now broken where necessary (Kevin Howbrook)
|
||||
* Language chosen in user preferences no longer persists on subsequent requests (Bojan Mihelac)
|
||||
* Prevent new block IDs from being assigned on repeated calls to ``StreamBlock.get_prep_value`` (Colin Klein)
|
||||
* Prevent broken images in notification emails when static files are hosted on a remote domain (Eduard Luca)
|
||||
|
||||
|
||||
Upgrade considerations
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load i18n static %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
|
@ -86,7 +86,7 @@ body[yahoo] .text {
|
|||
<table width="600" border="0" align="center" class="mobile" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td>
|
||||
{% block branding_logo %}<img width="100%" border="0" style="display: block;" alt="" src="{{ settings.BASE_URL }}{% static 'wagtailadmin/images/email-header.jpg' %}" />{% endblock %}
|
||||
{% block branding_logo %}<img width="100%" border="0" style="display: block;" alt="" src="{% notification_static 'wagtailadmin/images/email-header.jpg' %}" />{% endblock %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import itertools
|
||||
import json
|
||||
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from django import template
|
||||
from django.conf import settings
|
||||
from django.contrib.admin.utils import quote
|
||||
|
@ -480,3 +482,12 @@ def avatar_url(user, size=50):
|
|||
@register.simple_tag
|
||||
def js_translation_strings():
|
||||
return mark_safe(json.dumps(get_js_translation_strings()))
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def notification_static(path):
|
||||
"""
|
||||
Variant of the {% static %}` tag for use in notification emails - tries to form
|
||||
a full URL using BASE_URL if the static URL isn't already a full URL.
|
||||
"""
|
||||
return urljoin(base_url_setting(), static(path))
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.contrib.auth import get_user_model
|
|||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from wagtail.admin.templatetags.wagtailadmin_tags import avatar_url
|
||||
from wagtail.admin.templatetags.wagtailadmin_tags import avatar_url, notification_static
|
||||
from wagtail.images.tests.utils import get_test_image_file
|
||||
from wagtail.users.models import UserProfile
|
||||
|
||||
|
@ -42,3 +42,20 @@ class TestAvatarTemplateTag(TestCase):
|
|||
|
||||
url = avatar_url(self.test_user)
|
||||
self.assertIn('custom-avatar', url)
|
||||
|
||||
|
||||
class TestNotificationStaticTemplateTag(TestCase):
|
||||
@override_settings(STATIC_URL='/static/')
|
||||
def test_local_notification_static(self):
|
||||
url = notification_static('wagtailadmin/images/email-header.jpg')
|
||||
self.assertEqual('/static/wagtailadmin/images/email-header.jpg', url)
|
||||
|
||||
@override_settings(STATIC_URL='/static/', BASE_URL='http://localhost:8000')
|
||||
def test_local_notification_static_baseurl(self):
|
||||
url = notification_static('wagtailadmin/images/email-header.jpg')
|
||||
self.assertEqual('http://localhost:8000/static/wagtailadmin/images/email-header.jpg', url)
|
||||
|
||||
@override_settings(STATIC_URL='https://s3.amazonaws.com/somebucket/static/', BASE_URL='http://localhost:8000')
|
||||
def test_remote_notification_static(self):
|
||||
url = notification_static('wagtailadmin/images/email-header.jpg')
|
||||
self.assertEqual('https://s3.amazonaws.com/somebucket/static/wagtailadmin/images/email-header.jpg', url)
|
||||
|
|
Ładowanie…
Reference in New Issue