From c9789f46dba2ac59f6c2f0c8af00b48a91fae46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 4 Apr 2018 15:44:52 +0200 Subject: [PATCH] {iframe} shortcode no longer requires cap=xxx --- pillar/shortcodes.py | 18 ++++++++---------- tests/test_shortcodes.py | 4 +++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pillar/shortcodes.py b/pillar/shortcodes.py index 8febd23d..634060ca 100644 --- a/pillar/shortcodes.py +++ b/pillar/shortcodes.py @@ -142,16 +142,14 @@ def iframe(context: typing.Any, import xml.etree.ElementTree as ET from pillar.auth import current_user - cap = kwargs.pop('cap', None) - if not cap: - return html_module.escape('{iframe missing cap="somecap"}') - - nocap = kwargs.pop('nocap', '') - if not current_user.has_cap(cap): - if not nocap: - return '' - html = html_module.escape(nocap) - return f'

{html}

' + cap = kwargs.pop('cap', '') + if cap: + nocap = kwargs.pop('nocap', '') + if not current_user.has_cap(cap): + if not nocap: + return '' + html = html_module.escape(nocap) + return f'

{html}

' kwargs['class'] = f'shortcode {kwargs.get("class", "")}'.strip() element = ET.Element('iframe', kwargs) diff --git a/tests/test_shortcodes.py b/tests/test_shortcodes.py index 9425654e..18422aa7 100644 --- a/tests/test_shortcodes.py +++ b/tests/test_shortcodes.py @@ -109,7 +109,9 @@ class IFrameTest(AbstractPillarTest): def test_missing_cap(self): from pillar.shortcodes import render - self.assertEqual('{iframe missing cap="somecap"}', render('{iframe}')) + md = '{iframe src="https://docs.python.org/3/library/"}' + expect = '' + self.assertEqual(expect, render(md)) def test_user_no_cap(self): from pillar.shortcodes import render