def request_args(self): return { "timeout": current_app.config.get("API_CLIENT_TIMEOUT", None), "headers": { "Accept-Language": get_locale() }, }
def __init__(self, formdata=None, obj=None, prefix="", data=None, meta=None, **kwargs): if data is None: data = {"welsh": get_locale()[:2] == "cy"} super(AdaptationsForm, self).__init__(formdata, obj, prefix, data, meta, **kwargs)
def format_time(dt): if isinstance(dt, datetime.datetime): time = dt.time() else: time = dt display_format = "%I:%M" display_string = time.strftime(display_format).lstrip("0") if get_locale()[:2] == "cy": time_suffix = format_time_welsh_suffix(time) else: time_suffix = time.strftime("%p") return "%s %s" % (display_string, time_suffix)
def __init__(self, form_name, config_path=None): """ Loads form yaml file for all forms and sets the config for a specific form :param form_name: Class name f form :return: None """ self.fields = {} self.form_config = None locale = get_locale() path = config_path or current_app.config["FORM_CONFIG_TRANSLATIONS"][locale] with open(path) as f: config_data = yaml.load(f.read()) if form_name in config_data["forms"]: self.form_config = config_data["forms"][form_name] # Convert markdown fields to markdown for field_name, field_config in self.form_config.get("fields").iteritems(): self.fields[field_name] = self.values_to_markdown(field_config)
def __init__(self, form_name, config_path=None): """ Loads form yaml file for all forms and sets the config for a specific form :param form_name: Class name f form :return: None """ self.fields = {} self.form_config = None locale = get_locale() path = config_path or current_app.config["FORM_CONFIG_TRANSLATIONS"][ locale] with open(path) as f: config_data = yaml.load(f.read()) if form_name in config_data["forms"]: self.form_config = config_data["forms"][form_name] # Convert markdown fields to markdown for field_name, field_config in self.form_config.get( "fields").iteritems(): self.fields[field_name] = self.values_to_markdown(field_config)
def get_api_connection(): return slumber.API( current_app.config["BACKEND_API"]["url"], timeout=current_app.config["API_CLIENT_TIMEOUT"], extra_headers={"Accept-Language": get_locale()}, )
def get_api_connection(): return slumber.API( current_app.config["BACKEND_API"]["url"], timeout=current_app.config["API_CLIENT_TIMEOUT"], extra_headers={"Accept-Language": get_locale()}, )
def suffix(day): if get_locale()[:2] == "cy": return suffix_day_welsh(day) return suffix_day_english(day)