{iframe} shortcode no longer requires cap=xxx
This commit is contained in:
parent
289dc39e50
commit
c9789f46db
@ -142,16 +142,14 @@ def iframe(context: typing.Any,
|
|||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from pillar.auth import current_user
|
from pillar.auth import current_user
|
||||||
|
|
||||||
cap = kwargs.pop('cap', None)
|
cap = kwargs.pop('cap', '')
|
||||||
if not cap:
|
if cap:
|
||||||
return html_module.escape('{iframe missing cap="somecap"}')
|
nocap = kwargs.pop('nocap', '')
|
||||||
|
if not current_user.has_cap(cap):
|
||||||
nocap = kwargs.pop('nocap', '')
|
if not nocap:
|
||||||
if not current_user.has_cap(cap):
|
return ''
|
||||||
if not nocap:
|
html = html_module.escape(nocap)
|
||||||
return ''
|
return f'<p class="shortcode nocap">{html}</p>'
|
||||||
html = html_module.escape(nocap)
|
|
||||||
return f'<p class="shortcode nocap">{html}</p>'
|
|
||||||
|
|
||||||
kwargs['class'] = f'shortcode {kwargs.get("class", "")}'.strip()
|
kwargs['class'] = f'shortcode {kwargs.get("class", "")}'.strip()
|
||||||
element = ET.Element('iframe', kwargs)
|
element = ET.Element('iframe', kwargs)
|
||||||
|
@ -109,7 +109,9 @@ class IFrameTest(AbstractPillarTest):
|
|||||||
def test_missing_cap(self):
|
def test_missing_cap(self):
|
||||||
from pillar.shortcodes import render
|
from pillar.shortcodes import render
|
||||||
|
|
||||||
self.assertEqual('{iframe missing cap="somecap"}', render('{iframe}'))
|
md = '{iframe src="https://docs.python.org/3/library/"}'
|
||||||
|
expect = '<iframe class="shortcode" src="https://docs.python.org/3/library/"></iframe>'
|
||||||
|
self.assertEqual(expect, render(md))
|
||||||
|
|
||||||
def test_user_no_cap(self):
|
def test_user_no_cap(self):
|
||||||
from pillar.shortcodes import render
|
from pillar.shortcodes import render
|
||||||
|
Loading…
x
Reference in New Issue
Block a user