def validate_city(value): city_l10n = get_l10n_field('city') state = sysparam.get_string('STATE_SUGGESTED') country = sysparam.get_string('COUNTRY_SUGGESTED') if not city_l10n.validate(value, state=state, country=country): return ValidationError(_("'%s' is not a valid %s.") % (value, city_l10n.label.lower()))
def validate_state(value): state_l10n = get_l10n_field('state') if not state_l10n.validate(value): return ValidationError( _("'%s' is not a valid %s.") % ( value, state_l10n.label.lower(), ))
def validate_city(value): default_store = get_default_store() city_l10n = get_l10n_field(default_store, 'city') state = sysparam(default_store).STATE_SUGGESTED country = sysparam(default_store).COUNTRY_SUGGESTED if not city_l10n.validate(value, state=state, country=country): return ValidationError(_("'%s' is not a valid %s.") % (value, city_l10n.label.lower()))
def get_full_date(date): """Return a date in it's full format taking l10n in consideration For example, for Brazil, it will return something like: 01 de janeiro de 2012 In the generic case, it will return something like: January 01, 2012 """ full_date_format = get_l10n_field("full_date_format") return date.strftime(full_date_format)
def test_api(): store = api.get_default_store() assert store is get_default_store() assert api.get_current_user(store) is get_current_user(store) assert api.db_settings is db_settings assert api.user_settings is get_settings() assert isinstance(api.device_manager, DeviceManager) with pytest.raises(NotImplementedError): assert isinstance(api.config, IStoqConfig) assert api.is_developer_mode() is is_developer_mode() assert api.get_l10n_field('CPF') is get_l10n_field('CPF')
def is_valid_model(self): city_l10n = get_l10n_field('city', self.country) return bool(self.country and self.city and self.state and city_l10n.validate( self.city, state=self.state, country=self.country))
def get_l10n_field(self, field_name, country=None): return get_l10n_field(field_name, country=country)
def get_price_as_cardinal(value): function = get_cardinal_function('to_words_as_money') currency_names = get_l10n_field(get_default_store(), 'currency_names') return function(value, currency_names)
def validate_state(value): state_l10n = get_l10n_field(get_default_store(), 'state') if not state_l10n.validate(value): return ValidationError( _("'%s' is not a valid %s.") % (value, state_l10n.label.lower(), ))
def is_valid_model(self): city_l10n = get_l10n_field(self.store, 'city', self.country) return bool(self.country and self.city and self.state and city_l10n.validate(self.city, state=self.state, country=self.country))
def validate_state(value): state_l10n = get_l10n_field("state") if not state_l10n.validate(value): return ValidationError(_("'%s' is not a valid %s.") % (value, state_l10n.label.lower()))