本文整理汇总了Python中stoqlib.domain.address.CityLocation类的典型用法代码示例。如果您正苦于以下问题:Python CityLocation类的具体用法?Python CityLocation怎么用?Python CityLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CityLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGetCitiesBy
def testGetCitiesBy(self):
location = CityLocation.get_or_create(self.store, u'Sao Carlos',
u'SP', u'Brazil')
for state, country in [
(u'SP', u'Brazil'),
(u'Sp', u'brazil'),
(u'SP', u'brazil'),
(u'sp', u'Brazil'),
(u'sp', u'BraZIL'),
(None, u'Brazil'),
(u'SP', None),
(None, None),
]:
self.assertTrue(location.city in
CityLocation.get_cities_by(self.store,
state=state,
country=country))
for state, country in [
(u'SP', u'Brazi'),
(u'RJ', u'Brazil'),
(u'RJ', None),
(u'BA', None),
(u'SP', u'Albânia'),
]:
self.assertFalse(location.city in
CityLocation.get_cities_by(self.store,
state=state,
country=country))
# Make sure no duplicates are returned
CityLocation.get_or_create(self.store, u'Sao Carlos', u'SP', u'BR')
CityLocation.get_or_create(self.store, u'Sao Carlos', u'SP', u'BR_')
CityLocation.get_or_create(self.store, u'Sao Carlos', u'SP', u'BR__')
cities = list(CityLocation.get_cities_by(self.store, state=u'SP'))
self.assertEqual(len(cities), len(set(cities)))
示例2: testGetDetailsString
def testGetDetailsString(self):
person = self.create_person()
city = u'Stoqlandia'
state = u'SP'
country = u'Brazil'
postal_code = u'12345-678'
location = CityLocation(city=city, state=state, country=country,
store=self.store)
address = Address(person=person, city_location=location,
postal_code=postal_code, store=self.store)
string = address.get_details_string()
self.assertEquals(string, u'%s - %s - %s' % (postal_code,
city, state))
location.city = u''
string = address.get_details_string()
self.assertEquals(string, u'%s' % postal_code)
location.state = u''
string = address.get_details_string()
self.assertEquals(string, u'%s' % postal_code)
address.postal_code = u''
string = address.get_details_string()
self.assertEquals(string, u'')
location.city = city
location.state = state
string = address.get_details_string()
self.assertEquals(string, u'%s - %s' % (city, state))
示例3: process_one
def process_one(self, data, fields, store):
person = Person(
store=store,
name=data.name,
phone_number=data.phone_number,
mobile_number=data.mobile_number)
Company(person=person,
store=store,
cnpj=data.cnpj,
fancy_name=data.name,
state_registry=data.state_registry)
ctloc = CityLocation.get_or_create(store=store,
city=data.city,
state=data.state,
country=data.country)
streetnumber = data.streetnumber and int(data.streetnumber) or None
Address(
is_main_address=True,
person=person,
city_location=ctloc,
store=store,
street=data.street,
streetnumber=streetnumber,
district=data.district
)
dict(open_contract_date=self.parse_date(data.open_contract),
freight_percentage=data.freight_percentage),
Transporter(person=person, store=store)
示例4: process_one
def process_one(self, data, fields, store):
person = Person(
store=store,
name=data.name,
phone_number=data.phone_number,
mobile_number=data.mobile_number)
Company(person=person,
store=store,
cnpj=data.cnpj,
fancy_name=data.name,
state_registry=data.state_registry)
ctloc = CityLocation.get_or_create(store=store,
city=data.city,
state=data.state,
country=data.country)
streetnumber = data.streetnumber and int(data.streetnumber) or None
Address(
is_main_address=True,
person=person,
city_location=ctloc,
store=store,
street=data.street,
streetnumber=streetnumber,
district=data.district
)
supplier = Supplier(person=person, store=store)
self.suppliers.append(supplier)
示例5: process_one
def process_one(self, data, fields, store):
person = Person(
store=store,
name=data.name,
phone_number=data.phone_number,
mobile_number=data.mobile_number)
Individual(person=person,
store=store,
cpf=data.cpf,
rg_number=data.rg)
ctloc = CityLocation.get_or_create(store=store,
city=data.city,
state=data.state,
country=data.country)
streetnumber = data.streetnumber and int(data.streetnumber) or None
Address(
is_main_address=True,
person=person,
city_location=ctloc,
store=store,
street=data.street,
streetnumber=streetnumber,
district=data.district
)
Client(person=person, store=store)
示例6: process_one
def process_one(self, data, fields, store):
person = Person(
store=store,
name=data.name,
phone_number=data.phone_number,
fax_number=data.fax_number)
Company(person=person, cnpj=data.cnpj,
state_registry=data.state_registry,
fancy_name=data.fancy_name,
store=store)
ctloc = CityLocation.get_or_create(store=store,
city=data.city,
state=data.state,
country=data.country)
streetnumber = data.streetnumber and int(data.streetnumber) or None
Address(
is_main_address=True,
person=person,
city_location=ctloc,
store=store,
street=data.street,
streetnumber=streetnumber,
district=data.district,
postal_code=data.postal_code
)
branch = Branch(person=person, store=store)
for user in store.find(LoginUser):
user.add_access_to(branch)
示例7: ensure_birth_location
def ensure_birth_location(self):
changed = self.birth_location_changed()
if changed:
self.target.birth_location = CityLocation.get_or_create(
city=self.city,
state=self.state,
country=self.country,
store=self.store)
示例8: testGetDefault
def testGetDefault(self):
location = CityLocation.get_default(self.store)
self.failUnless(isinstance(location, CityLocation))
self.assertEquals(location.city,
sysparam(self.store).CITY_SUGGESTED)
self.assertEquals(location.state,
sysparam(self.store).STATE_SUGGESTED)
self.assertEquals(location.country,
sysparam(self.store).COUNTRY_SUGGESTED)
示例9: __init__
def __init__(self, target, store):
AttributeForwarder.__init__(self, target)
self.store = store
if not target.birth_location:
target.birth_location = CityLocation.get_default(store)
self.city = target.birth_location.city
self.state = target.birth_location.state
self.country = target.birth_location.country
示例10: ensure_address
def ensure_address(self):
changed = self._city_location_changed()
if changed:
location = CityLocation.get_or_create(
city=self.city,
state=self.state,
country=self.country,
store=self.store)
self.target.city_location = location
示例11: test_get_default
def test_get_default(self):
location = CityLocation.get_default(self.store)
self.failUnless(isinstance(location, CityLocation))
self.assertEquals(location.city,
sysparam.get_string('CITY_SUGGESTED'))
self.assertEquals(location.state,
sysparam.get_string('STATE_SUGGESTED'))
self.assertEquals(location.country,
sysparam.get_string('COUNTRY_SUGGESTED'))
示例12: _create_address
def _create_address(self, person, street, streetnumber, postal_code):
city = CityLocation.get_default(self.store)
return Address(store=self.store,
street=street,
streetnumber=streetnumber,
postal_code=postal_code,
is_main_address=True,
person=person,
city_location=city)
示例13: __init__
def __init__(self, target, store):
"""
:param model: an Individial
:param store: a store
"""
AttributeForwarder.__init__(self, target)
self.store = store
if not target.birth_location:
target.birth_location = CityLocation.get_default(store)
self.city = target.birth_location.city
self.state = target.birth_location.state
self.country = target.birth_location.country
示例14: testGetOrCreate
def testGetOrCreate(self):
loc = CityLocation.get_or_create(self.store, u'City',
u'State', u'Country')
self.failUnless(loc)
self.assertEqual(loc.city, u'City')
self.assertEqual(loc.state, u'State')
self.assertEqual(loc.country, u'Country')
loc2 = CityLocation.get_or_create(self.store, u'city',
u'state', u'country')
self.failUnless(loc2)
self.assertEqual(loc2.city, u'City')
self.assertEqual(loc2.state, u'State')
self.assertEqual(loc2.country, u'Country')
self.assertEqual(loc2, loc)
location = CityLocation.get_or_create(self.store, u'São Carlos',
u'SP', u'Brazil')
for city, state, country in [
(u'sao carlos', u'SP', u'Brazil'),
(u'Sao carlos', u'SP', u'Brazil'),
(u'São carlos', u'SP', u'Brazil'),
(u'sao Carlos', u'SP', u'Brazil'),
(u'sao Carlos', u'sp', u'Brazil'),
(u'sao Carlos', u'sp', u'brazil'),
(u'sao Carlos', u'Sp', u'brazil'),
]:
self.assertEqual(CityLocation.get_or_create(self.store, city,
state, country),
location)
for city, state, country in [
(u'Sao', u'SP', u'Brazil'),
(u'sao', u'SP', u'Brazil'),
(u'Carlos', u'SP', u'Brazil'),
(u'carlos', u'SP', u'Brazil'),
]:
self.assertNotEqual(CityLocation.get_or_create(self.store, city,
state, country),
location)
示例15: _prefill_cities
def _prefill_cities(self, force=False):
completion = self.city.get_completion()
if not completion:
# Completion wasn't set yet
return
if len(completion.get_model()) and not force:
return
self.city.prefill([]) # mimic missing .clear method
cities = CityLocation.get_cities_by(self.store,
state=self.model.state,
country=self.model.country)
self.city.prefill(list(cities))