rename expand_db_attributes_for_editor to expand_db_attributes, now it doesn't need to differentiate from front-end conversion

pull/4079/merge
Matt Westcott 2017-12-07 22:23:05 +00:00
rodzic 0262c7de00
commit 0316b83541
9 zmienionych plików z 14 dodań i 14 usunięć

Wyświetl plik

@ -131,11 +131,11 @@ class EditorHTMLConverter:
for feature in feature_list:
embed_handlers = features.get_embed_handler_rules(feature)
for handler_name, handler in embed_handlers.items():
embed_rules[handler_name] = handler.expand_db_attributes_for_editor
embed_rules[handler_name] = handler.expand_db_attributes
link_handlers = features.get_link_handler_rules(feature)
for handler_name, handler in link_handlers.items():
link_rules[handler_name] = handler.expand_db_attributes_for_editor
link_rules[handler_name] = handler.expand_db_attributes
return MultiRuleRewriter([
LinkRewriter(link_rules), EmbedRewriter(embed_rules)

Wyświetl plik

@ -20,7 +20,7 @@ class PageLinkHandler:
return {'id': tag['data-id']}
@staticmethod
def expand_db_attributes_for_editor(attrs):
def expand_db_attributes(attrs):
try:
page = Page.objects.get(id=attrs['id'])

Wyświetl plik

@ -24,14 +24,14 @@ class TestPageLinkHandler(TestCase):
self.assertEqual(result, '<a>')
def test_expand_db_attributes_for_editor(self):
result = PageLinkHandler.expand_db_attributes_for_editor({'id': 1})
result = PageLinkHandler.expand_db_attributes({'id': 1})
self.assertEqual(
result,
'<a data-linktype="page" data-id="1" href="None">'
)
events_page_id = Page.objects.get(url_path='/home/events/').pk
result = PageLinkHandler.expand_db_attributes_for_editor({'id': events_page_id})
result = PageLinkHandler.expand_db_attributes({'id': events_page_id})
self.assertEqual(
result,
'<a data-linktype="page" data-id="%d" data-parent-id="2" href="/events/">' % events_page_id

Wyświetl plik

@ -9,7 +9,7 @@ class DocumentLinkHandler:
return {'id': tag['data-id']}
@staticmethod
def expand_db_attributes_for_editor(attrs):
def expand_db_attributes(attrs):
Document = get_document_model()
try:
doc = Document.objects.get(id=attrs['id'])

Wyświetl plik

@ -19,7 +19,7 @@ class TestDocumentRichTextLinkHandler(TestCase):
self.assertEqual(result, '<a>')
def test_expand_db_attributes_for_editor(self):
result = DocumentLinkHandler.expand_db_attributes_for_editor({'id': 1})
result = DocumentLinkHandler.expand_db_attributes({'id': 1})
self.assertEqual(result,
'<a data-linktype="document" data-id="1" href="/documents/1/test.pdf">')

Wyświetl plik

@ -21,7 +21,7 @@ class MediaEmbedHandler:
}
@staticmethod
def expand_db_attributes_for_editor(attrs):
def expand_db_attributes(attrs):
"""
Given a dict of attributes from the <embed> tag, return the real HTML
representation for use within the editor.

Wyświetl plik

@ -557,7 +557,7 @@ class TestMediaEmbedHandler(TestCase):
height=1000,
)
result = MediaEmbedHandler.expand_db_attributes_for_editor(
result = MediaEmbedHandler.expand_db_attributes(
{'url': 'http://www.youtube.com/watch/'}
)
self.assertIn(
@ -577,7 +577,7 @@ class TestMediaEmbedHandler(TestCase):
def test_test_expand_db_attributes_for_editor_catches_embed_not_found(self, get_embed):
get_embed.side_effect = EmbedNotFoundException
result = MediaEmbedHandler.expand_db_attributes_for_editor(
result = MediaEmbedHandler.expand_db_attributes(
{'url': 'http://www.youtube.com/watch/'},
)

Wyświetl plik

@ -23,7 +23,7 @@ class ImageEmbedHandler:
}
@staticmethod
def expand_db_attributes_for_editor(attrs):
def expand_db_attributes(attrs):
"""
Given a dict of attributes from the <embed> tag, return the real HTML
representation for use within the editor.

Wyświetl plik

@ -52,7 +52,7 @@ class TestImageEmbedHandler(TestCase):
def test_expand_db_attributes_for_editor(self):
Image.objects.create(id=1, title='Test', file=get_test_image_file())
result = ImageEmbedHandler.expand_db_attributes_for_editor(
result = ImageEmbedHandler.expand_db_attributes(
{'id': 1,
'alt': 'test-alt',
'format': 'left'},
@ -64,7 +64,7 @@ class TestImageEmbedHandler(TestCase):
def test_expand_db_attributes_for_editor_escapes_alt_text(self):
Image.objects.create(id=1, title='Test', file=get_test_image_file())
result = ImageEmbedHandler.expand_db_attributes_for_editor(
result = ImageEmbedHandler.expand_db_attributes(
{'id': 1,
'alt': 'Arthur "two sheds" Jackson',
'format': 'left'},
@ -77,7 +77,7 @@ class TestImageEmbedHandler(TestCase):
def test_expand_db_attributes_for_editor_with_missing_alt(self):
Image.objects.create(id=1, title='Test', file=get_test_image_file())
result = ImageEmbedHandler.expand_db_attributes_for_editor(
result = ImageEmbedHandler.expand_db_attributes(
{'id': 1,
'format': 'left'},
)