示例#1
0
 def _inner(*args, **kwargs):
     req = ctx.current_request
     target = req.args.get('_next') or href(default)
     result = func(*args, **kwargs)
     if not isinstance(result, BaseResponse):
         return redirect(target)
     return result
示例#2
0
 def _inner(*args, **kwargs):
     req = ctx.current_request
     target = req.args.get('_next') or href(default)
     result = func(*args, **kwargs)
     if not isinstance(result, BaseResponse):
         return redirect(target)
     return result
示例#3
0
 def __call__(self, field, **kwargs):
     input_html = super(TokenInput, self).__call__(field, **kwargs)
     tags = field.data or []
     serializer, mime = get_serializer("json")
     ro = primitive(tags, config={"show_type": False, Tag.object_type: ("id", "name")})
     tags_json = serializer(ro)
     js = TOKEN_INPUT % (field.id, href("api/core/get_tags", format="json"), tags_json)
     return HTMLString(input_html + js)
示例#4
0
 def __call__(self, field, **kwargs):
     input_html = super(TokenInput, self).__call__(field, **kwargs)
     tags = field.data or []
     serializer, mime = get_serializer('json')
     ro = primitive(tags,
                    config={
                        'show_type': False,
                        Tag.object_type: ('id', 'name')
                    })
     tags_json = serializer(ro)
     js = TOKEN_INPUT % (field.id, href('api/core/get_tags',
                                        format='json'), tags_json)
     return HTMLString(input_html + js)
示例#5
0
    def get_html(self, key, value, nolink=False):
        """
        Returns a HTML link for sorting the table.
        This function is usually called inside the template.

        Usage example in the template file:

        .. sourcecode:: html+jinja

            <tr>
              <th>
                {{ table.get_html('id', '#') }}
              </th>
              <th>
                {{ table.get_html('username', 'Username') }}
              </th>
            </tr>
            {% for user in users %}
              (...)
            {% endfor %}

        :parameter key: The name of the database column that should be used
                        for sorting.
        :param value: The name that is displayed for the link.
        :param nolink: Don't make this column sortable but display a cool link.
        """
        ocol = self.order_by.lstrip('-')
        order = self.order_by.startswith('-')
        if key == ocol:
            new_order = '%s%s' % (('-', '')[order], ocol)
            button = ('down', 'up')[order]
            src = href('static', file='img/%s.png' % button)
            img = build_html_tag('img', src=src)
        else:
            new_order = key
            img = ''

        if nolink:
            return value
        return Markup(u'<a href="?order=%s">%s</a>%s' %
                      (new_order, value, img))
示例#6
0
    def get_html(self, key, value, nolink=False):
        """
        Returns a HTML link for sorting the table.
        This function is usually called inside the template.

        Usage example in the template file:

        .. sourcecode:: html+jinja

            <tr>
              <th>
                {{ table.get_html('id', '#') }}
              </th>
              <th>
                {{ table.get_html('username', 'Username') }}
              </th>
            </tr>
            {% for user in users %}
              (...)
            {% endfor %}

        :parameter key: The name of the database column that should be used
                        for sorting.
        :param value: The name that is displayed for the link.
        :param nolink: Don't make this column sortable but display a cool link.
        """
        ocol = self.order_by.lstrip('-')
        order = self.order_by.startswith('-')
        if key == ocol:
            new_order = '%s%s' % (('-', '')[order], ocol)
            button = ('down', 'up')[order]
            src = href('static', file='img/%s.png' % button)
            img = build_html_tag('img', src=src)
        else:
            new_order = key
            img = ''

        if nolink:
            return value
        return Markup(u'<a href="?order=%s">%s</a>%s' % (new_order, value, img))
示例#7
0
 def __call__(self, field, **kwargs):
     input_html = super(TextInput, self).__call__(field, **kwargs)
     js = AUTOCOMPLETE % (field.id, href(self.url, format='json'))
     return HTMLString(input_html + js)
示例#8
0
def redirect_to(endpoint, **kwargs):
    """Temporarily redirect to an URL rule."""
    return redirect(href(endpoint, **kwargs))
示例#9
0
 def __call__(self, field, **kwargs):
     input_html = super(TextInput, self).__call__(field, **kwargs)
     js = AUTOCOMPLETE % (field.id, href(self.url, format="json"))
     return HTMLString(input_html + js)
示例#10
0
def redirect_to(endpoint, **kwargs):
    """Temporarily redirect to an URL rule."""
    return redirect(href(endpoint, **kwargs))
示例#11
0
 def url(self):
     return href('portal/confirm', key=self.key, _external=True)
示例#12
0
 def url(self):
     return href('portal/confirm', key=self.key, _external=True)