Fixed bug in attachment code
This commit is contained in:
@@ -230,7 +230,7 @@ class Attachment:
|
|||||||
|
|
||||||
from pillar.web import system_util
|
from pillar.web import system_util
|
||||||
|
|
||||||
attachments = node_properties.get('attachments', {})
|
attachments = node_properties.get('properties', {}).get('attachments', {})
|
||||||
attachment = attachments.get(slug)
|
attachment = attachments.get(slug)
|
||||||
if not attachment:
|
if not attachment:
|
||||||
raise self.NoSuchSlug(slug)
|
raise self.NoSuchSlug(slug)
|
||||||
|
@@ -187,11 +187,11 @@ class AttachmentTest(AbstractPillarTest):
|
|||||||
],
|
],
|
||||||
'filename': 'cute_kitten.jpg',
|
'filename': 'cute_kitten.jpg',
|
||||||
})
|
})
|
||||||
node_props = {
|
node_doc = {'properties': {
|
||||||
'attachments': {
|
'attachments': {
|
||||||
'img': {'oid': oid},
|
'img': {'oid': oid},
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
|
|
||||||
# We have to get the file document again, because retrieving it via the
|
# We have to get the file document again, because retrieving it via the
|
||||||
# API (which is what the shortcode rendering is doing) will change its
|
# API (which is what the shortcode rendering is doing) will change its
|
||||||
@@ -204,20 +204,20 @@ class AttachmentTest(AbstractPillarTest):
|
|||||||
f'<img src="{link}" alt="cute_kitten.jpg"/></a>'
|
f'<img src="{link}" alt="cute_kitten.jpg"/></a>'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self_linked,
|
self_linked,
|
||||||
render('{attachment img link}', context=node_props).strip()
|
render('{attachment img link}', context=node_doc).strip()
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self_linked,
|
self_linked,
|
||||||
render('{attachment img link=self}', context=node_props).strip()
|
render('{attachment img link=self}', context=node_doc).strip()
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
f'<img src="{link}" alt="cute_kitten.jpg"/>',
|
f'<img src="{link}" alt="cute_kitten.jpg"/>',
|
||||||
render('{attachment img}', context=node_props).strip()
|
render('{attachment img}', context=node_doc).strip()
|
||||||
)
|
)
|
||||||
|
|
||||||
tag_link = 'https://i.imgur.com/FmbuPNe.jpg'
|
tag_link = 'https://i.imgur.com/FmbuPNe.jpg'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
f'<a href="{tag_link}" target="_blank">'
|
f'<a href="{tag_link}" target="_blank">'
|
||||||
f'<img src="{link}" alt="cute_kitten.jpg"/></a>',
|
f'<img src="{link}" alt="cute_kitten.jpg"/></a>',
|
||||||
render('{attachment img link=%r}' % tag_link, context=node_props).strip()
|
render('{attachment img link=%r}' % tag_link, context=node_doc).strip()
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user