Exemplo n.º 1
0
def render_template(template_name_or_list, **context):
    """add "user" and "settings" for every response"""
    context.update({
        "user": User.get_current_user(),
        "settings": get_site_settings(),
    })
    return flask_render_template(template_name_or_list, **context)
Exemplo n.º 2
0
Arquivo: utils.py Projeto: zky001/me
def render_template(template_name_or_list, **context):
    """add "user" and "settings" for every response"""
    context.update({
        "user": User.get_current_user(),
        "settings": get_site_settings(),
    })
    return flask_render_template(template_name_or_list, **context)
Exemplo n.º 3
0
def update_site_settings(**settings):
    """update site settings.
    Args:
        settings: a dict of settings
    Returns:
        settings: a dict of settings"""
    dbsettings = apis.get_site_settings()
    dbsettings.update(**settings)
    result = {
        "settings": dbsettings
    }
    return result
Exemplo n.º 4
0
Arquivo: ajax.py Projeto: yyy921104/me
def update_site_settings(**settings):
    """update site settings.
    Args:
        settings: a dict of settings
    Returns:
        settings: a dict of settings"""
    dbsettings = apis.get_site_settings()
    dbsettings.update(**settings)
    result = {
        "settings": dbsettings
    }
    return result
Exemplo n.º 5
0
def update_site_settings(**settings):
    """update site settings.
    Args:
        settings: a dict of settings
    Returns:
        settings: a dict of settings"""
    dbsettings = apis.get_site_settings()

    # check setting values
    if "mirror_site" in settings:
        mirror_site = settings["mirror_site"]
        if not mirror_site:
            mirror_site = ""
        if not mirror_site.startswith(
                "//") and not mirror_site.lower().startswith("http"):
            mirror_site = "//" + mirror_site

        mirror_site = mirror_site.rstrip("/")
        settings["mirror_site"] = mirror_site

    dbsettings.update(**settings)
    result = {"settings": dbsettings}
    return result
Exemplo n.º 6
0
def update_site_settings(**settings):
    """update site settings.
    Args:
        settings: a dict of settings
    Returns:
        settings: a dict of settings"""
    dbsettings = apis.get_site_settings()

    # check setting values
    if "mirror_site" in settings:
        mirror_site = settings["mirror_site"]
        if not mirror_site:
            mirror_site = ""
        if not mirror_site.startswith("//") and not mirror_site.lower().startswith("http"):
            mirror_site = "//" + mirror_site

        mirror_site = mirror_site.rstrip("/")
        settings["mirror_site"] = mirror_site

    dbsettings.update(**settings)
    result = {
        "settings": dbsettings
    }
    return result