Пример #1
0
def watcher_link(parser, token):
    """
    Renders a watch or ignore link for the specified context.

    Example::

        {% watcher_link owner=user content_type="document" %}
    """
    del parser
    bits = split_and_honor_quotation_marks(token.contents)
    if len(bits) < 2:
        raise TemplateSyntaxError, "%r tag at least one argument" % bits[0]

    return WatcherLinkNode(bits[1:])
Пример #2
0
def watcher_link(parser, token):
    """
    Renders a watch or ignore link for the specified context.

    Example::

        {% watcher_link owner=user content_type="document" %}
    """
    del parser
    bits = split_and_honor_quotation_marks(token.contents)
    if len(bits) < 2:
        raise TemplateSyntaxError, "%r tag at least one argument" % bits[0]
    
    return WatcherLinkNode(bits[1:])
Пример #3
0
def curia_include(parser, token):
    """
    Loads a template and renders it with the current context. Passes any named parameters that are in the form of "a=b".

    Example::

        {% include "foo/some_include" object=user %}
    """
    del parser
    bits = split_and_honor_quotation_marks(token.contents)
    if len(bits) < 2:
        raise TemplateSyntaxError, "%r tag takes one argument: the name of the template to be included" % bits[0]
    
    return IncludeNode(bits[1], bits[2:])
Пример #4
0
def link(parser, token):
    """
    Renders a link for the specified object and command.
    Available commands are "edit", "delete" and "view", the default command is "view".

    Example::

        {% link obj=document command="edit" %}
    """
    del parser
    bits = split_and_honor_quotation_marks(token.contents)
    if len(bits) < 2:
        raise TemplateSyntaxError, "%r tag at least one argument" % bits[0]

    return LinkNode(bits[1:])
Пример #5
0
def curia_include(parser, token):
    """
    Loads a template and renders it with the current context. Passes any named parameters that are in the form of "a=b".

    Example::

        {% include "foo/some_include" object=user %}
    """
    del parser
    bits = split_and_honor_quotation_marks(token.contents)
    if len(bits) < 2:
        raise TemplateSyntaxError, "%r tag takes one argument: the name of the template to be included" % bits[
            0]

    return IncludeNode(bits[1], bits[2:])
Пример #6
0
def link(parser, token):
    """
    Renders a link for the specified object and command.
    Available commands are "edit", "delete" and "view", the default command is "view".

    Example::

        {% link obj=document command="edit" %}
    """
    del parser
    bits = split_and_honor_quotation_marks(token.contents)
    if len(bits) < 2:
        raise TemplateSyntaxError, "%r tag at least one argument" % bits[0]
    
    return LinkNode(bits[1:])
Пример #7
0
def has_permission(parser, token):
    """
    Renders the body if the user has the specified access on the given object.
    Available commands are "edit", "delete" and "view", the default command is "view".

    Example::

        {% has_permission obj=document command="edit" %}you have access!{% endhas_permission %}
    """
    bits = split_and_honor_quotation_marks(token.contents)

    nodelist_true = parser.parse(('else', 'endhas_permission'))
    token = parser.next_token()
    if token.contents == 'else':
        nodelist_false = parser.parse(('endhas_permission', ))
        parser.delete_first_token()
    else:
        nodelist_false = NodeList()

    if len(bits) < 2:
        raise TemplateSyntaxError, "%r tag at least one argument" % bits[0]

    return HasPermissionNode(bits[1:], nodelist_true, nodelist_false)
Пример #8
0
def has_permission(parser, token):
    """
    Renders the body if the user has the specified access on the given object.
    Available commands are "edit", "delete" and "view", the default command is "view".

    Example::

        {% has_permission obj=document command="edit" %}you have access!{% endhas_permission %}
    """
    bits = split_and_honor_quotation_marks(token.contents)
    
    nodelist_true = parser.parse(('else', 'endhas_permission'))
    token = parser.next_token()
    if token.contents == 'else':
        nodelist_false = parser.parse(('endhas_permission',))
        parser.delete_first_token()
    else:
        nodelist_false = NodeList()
    
    if len(bits) < 2:
        raise TemplateSyntaxError, "%r tag at least one argument" % bits[0]

    return HasPermissionNode(bits[1:], nodelist_true, nodelist_false)