Пример #1
0
 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()))
Пример #2
0
 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()))
Пример #3
0
 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(),
             ))
Пример #4
0
 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()))
Пример #5
0
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)
Пример #6
0
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)
Пример #7
0
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')
Пример #8
0
 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))
Пример #9
0
 def get_l10n_field(self, field_name, country=None):
     return get_l10n_field(field_name, country=country)
Пример #10
0
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)
Пример #11
0
 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(), ))
Пример #12
0
 def get_l10n_field(self, field_name, country=None):
     return get_l10n_field(field_name, country=country)
Пример #13
0
 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))
Пример #14
0
 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()))