Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _activitylink(offering, macro, environ, *act_name):
act = _find_activity(offering, macro['arg_string'])
attrs = {}
if isinstance(act, Activity):
text = act.name
attrs['href'] = act.get_absolute_url()
else:
# error
text = act
attrs['class'] = 'empty'
return creoleparser.core.bldr.tag.__getattr__('a')(text, **attrs)
def _activitylink(offering, macro, environ, *act_name):
act = _find_activity(offering, macro['arg_string'])
attrs = {}
if isinstance(act, Activity):
text = act.name
attrs['href'] = act.get_absolute_url()
else:
# error
text = act
attrs['class'] = 'empty'
return creoleparser.core.bldr.tag.__getattr__('a')(text, **attrs)
def _build(self, mo, element_store, environ):
lang = mo.group(1)
code = mo.group(2).rstrip()
return creoleparser.core.bldr.tag.__getattr__(self.tag)(
creoleparser.core.fragmentize(code, self.child_elements,
element_store, environ, remove_escapes=False),
class_="highlight lang-" + lang,
lang=lang # the most restrictive markup rendering strips the class attribute, but not lang.
)
# all pages [with the given prefix] for this offering
if prefix:
pages = Page.objects.filter(offering=offering, label__startswith=prefix)
else:
pages = Page.objects.filter(offering=offering)
# ... except this page (if known)
if pageversion:
pages = pages.exclude(id=pageversion.page_id)
elements = []
for p in pages:
link = creoleparser.core.bldr.tag.__getattr__('a')(p.current_version().title or p.label, href=p.label)
li = creoleparser.core.bldr.tag.__getattr__('li')(link)
elements.append(li)
return creoleparser.core.bldr.tag.__getattr__('ul')(elements, **{'class': 'filelist'})