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)
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
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
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