예제 #1
0
파일: helpers.py 프로젝트: NouryG/pychronia
def game_view_url(parser, token):
    """
    Only works if a "game_instance_id" template variable is available (use request processors for that).
    """
    #print ("PARSING IN GAMLEURL", token.contents, "\n")
    sep = " as "
    parts = token.contents.split(sep) # beware of alternate form of url tag
    if len(parts) > 1:
        new_content = " as ".join(parts[:-1]) + " game_instance_id=game_instance_id" + sep + parts[-1]
    else:
        new_content = parts[0] + " game_instance_id=game_instance_id"

    token.contents = new_content # we thus injected template var "game instance id"
    url_node = default_url_tag(parser, token)
    return url_node
예제 #2
0
def game_view_url_tag(parser, token):
    """
    Only works if a "game_instance_id" and "game_username" template variables are available (use request processors for that).
    """
    #print ("PARSING IN GAMLEURL", token.contents, "\n")
    redirector = False
    content = token.contents

    if " redirector" in content:
        redirector = True
        content = content.replace(" redirector", "")

    sep = " as "
    parts = content.rsplit(sep, 1) # beware of alternate form of url tag
    from pychronia_game.authentication import TEMP_URL_USERNAME  # FIXME - move that to a better place
    new_content = parts[0] + " game_instance_id=game_instance_id game_username=%s" % ("game_username" if not redirector else "'%s'" % TEMP_URL_USERNAME)
    if len(parts) > 1:
        assert len(parts) == 2
        new_content += sep + parts[1]

    token.contents = new_content # we thus injected template vars "game instance id" and "game username"
    url_node = default_url_tag(parser, token)
    return url_node