示例#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)
示例#2
0
文件: utils.py 项目: 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)
示例#3
0
文件: ajax.py 项目: errorcode7/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
示例#4
0
文件: ajax.py 项目: 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
示例#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
示例#6
0
文件: ajax.py 项目: CaptainBerg/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()

    # 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