mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-16 11:13:15 +00:00
Catch EmbedNotFoundExeception fixes #1324
This commit is contained in:
parent
225f54ad6c
commit
00d558c9be
3 changed files with 16 additions and 11 deletions
|
|
@ -27,11 +27,15 @@ def embed_to_frontend_html(url):
|
|||
|
||||
|
||||
def embed_to_editor_html(url):
|
||||
embed = embeds.get_embed(url)
|
||||
if embed is None:
|
||||
return
|
||||
try:
|
||||
embed = embeds.get_embed(url)
|
||||
if embed is None:
|
||||
return
|
||||
|
||||
# Render template
|
||||
return render_to_string('wagtailembeds/embed_editor.html', {
|
||||
'embed': embed,
|
||||
})
|
||||
# Render template
|
||||
return render_to_string('wagtailembeds/embed_editor.html', {
|
||||
'embed': embed,
|
||||
})
|
||||
except embeds.EmbedNotFoundException:
|
||||
# Could be replaced with a nice error message
|
||||
return ''
|
||||
|
|
|
|||
|
|
@ -9,5 +9,8 @@ register = template.Library()
|
|||
|
||||
@register.filter
|
||||
def embed(url, max_width=None):
|
||||
embed = embeds.get_embed(url, max_width=max_width)
|
||||
return mark_safe(embed.html)
|
||||
try:
|
||||
embed = embeds.get_embed(url, max_width=max_width)
|
||||
return mark_safe(embed.html)
|
||||
except embeds.EmbedNotFoundException:
|
||||
return ''
|
||||
|
|
|
|||
|
|
@ -290,7 +290,6 @@ class TestEmbedFilter(TestCase):
|
|||
|
||||
self.assertEqual(result, '<img src="http://www.example.com" />')
|
||||
|
||||
@unittest.expectedFailure
|
||||
@patch('wagtail.wagtailembeds.embeds.get_embed')
|
||||
def test_catches_embed_not_found(self, get_embed):
|
||||
get_embed.side_effect = EmbedNotFoundException
|
||||
|
|
@ -470,7 +469,6 @@ class TestMediaEmbedHandler(TestCase):
|
|||
self.assertIn('<p>Author: test author name</p>', result)
|
||||
self.assertIn('<img src="http://test/thumbnail.url" alt="test title">', result)
|
||||
|
||||
@unittest.expectedFailure
|
||||
@patch('wagtail.wagtailembeds.embeds.get_embed')
|
||||
def test_test_expand_db_attributes_for_editor_catches_embed_not_found(self, get_embed):
|
||||
get_embed.side_effect = EmbedNotFoundException
|
||||
|
|
|
|||
Loading…
Reference in a new issue