def url(self, context=None): if self._url: return Action.url(self) endpoint = self.endpoint if endpoint: return endpoint else: return url_for("%s.index" % self.name)
def __init__(self, *args, **kwargs): if "permission" in kwargs: self.permission = kwargs.pop("permission") Action.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): if 'permission' in kwargs: self.permission = kwargs.pop('permission') Action.__init__(self, *args, **kwargs)
# coding=utf-8 from __future__ import print_function from __future__ import division from __future__ import absolute_import from jinja2 import Markup from flask import Flask from abilian.web.action import actions, Action, Glyphicon, StaticIcon from abilian.testing import BaseTestCase BASIC = Action('cat_1', 'basic', 'Basic Action', url='http://some.where', icon='ok') CONDITIONAL = Action('cat_1', 'conditional', 'Conditional Action', url='http://condition.al', condition=lambda ctx: ctx['show_all'], icon=Glyphicon('hand-right'), button='warning') OTHER_CAT = Action('cat_2:sub', 'other', 'Other Action', url=lambda ctx: 'http://count?%d' % len(ctx), icon=StaticIcon('icons/other.png', size=14), css='custom-class')
from flask import Flask from flask.ctx import AppContext, RequestContext from jinja2 import Markup from abilian.app import Application from abilian.web.action import Action, Glyphicon, StaticIcon, actions BASIC = Action("cat_1", "basic", "Basic Action", url="http://some.where", icon="ok") CONDITIONAL = Action( "cat_1", "conditional", "Conditional Action", url="http://condition.al", condition=lambda ctx: ctx["show_all"], icon=Glyphicon("hand-right"), button="warning", ) OTHER_CAT = Action( "cat_2:sub", "other", "Other Action", url=lambda ctx: f"http://count?{len(ctx)}", icon=StaticIcon("icons/other.png", size=14), css="custom-class", ) ALL_ACTIONS = (BASIC, CONDITIONAL, OTHER_CAT) def setup_actions(app: Application) -> None: