• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python address.CityLocation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stoqlib.domain.address.CityLocation的典型用法代码示例。如果您正苦于以下问题:Python CityLocation类的具体用法?Python CityLocation怎么用?Python CityLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CityLocation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)))
开发者ID:romaia,项目名称:stoq,代码行数:35,代码来源:test_address.py


示例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))
开发者ID:romaia,项目名称:stoq,代码行数:26,代码来源:test_address.py


示例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)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:31,代码来源:transporterimporter.py


示例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)
开发者ID:Guillon88,项目名称:stoq,代码行数:30,代码来源:supplierimporter.py


示例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)
开发者ID:romaia,项目名称:stoq,代码行数:28,代码来源:clientimporter.py


示例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)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:31,代码来源:branchimporter.py


示例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)
开发者ID:hackedbellini,项目名称:stoq,代码行数:8,代码来源:individualtemplate.py


示例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)
开发者ID:romaia,项目名称:stoq,代码行数:9,代码来源:test_address.py


示例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
开发者ID:romaia,项目名称:stoq,代码行数:9,代码来源:individualtemplate.py


示例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
开发者ID:hackedbellini,项目名称:stoq,代码行数:9,代码来源:addressslave.py


示例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'))
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:9,代码来源:test_address.py


示例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)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:10,代码来源:test_nfe.py


示例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
开发者ID:LeonamSilva,项目名称:stoq,代码行数:13,代码来源:individualtemplate.py


示例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)
开发者ID:romaia,项目名称:stoq,代码行数:39,代码来源:test_address.py


示例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))
开发者ID:hackedbellini,项目名称:stoq,代码行数:14,代码来源:addressslave.py


示例16: 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)

        role = EmployeeRole(store=store, name=data.role)

        employee = Employee(person=person,
                            store=store,
                            role=role,
                            salary=int(data.salary),
                            registry_number=data.employee_number)

        start = self.parse_date(data.start)
        EmployeeRoleHistory(
            store=store, role=role,
            employee=employee,
            is_active=True,
            began=start,
            salary=int(data.salary))

        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)

        if self.create_users:
            profile = store.find(UserProfile, name=data.profile).one()
            LoginUser(person=person, store=store, profile=profile,
                      username=data.username,
                      password=data.password)

        SalesPerson(person=person, store=store)
开发者ID:hackedbellini,项目名称:stoq,代码行数:48,代码来源:employeeimporter.py


示例17: _create_client

    def _create_client(self, store):
        from stoqlib.domain.address import Address, CityLocation
        from stoqlib.domain.person import Client, Person

        person = Person(name=u'Person', store=store)
        city = CityLocation.get_default(store)
        Address(store=store,
                street=u'Rua Principal',
                streetnumber=123,
                postal_code=u'12345-678',
                is_main_address=True,
                person=person,
                city_location=city)
        client = Client(person=person, store=store)
        client.credit_limit = currency("1000")
        return client
开发者ID:amaurihamasu,项目名称:stoq,代码行数:16,代码来源:test_pos.py


示例18: __init__

    def __init__(self, target, store, ui_form_name=None):
        """
        :param target: an Individial
        :param store: a store
        """
        # Even though we dont use ui_form_name anywhere in this class, its setup
        # is made in a way we need this argument. see persontemplate
        # attach_model_slave method
        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
开发者ID:hackedbellini,项目名称:stoq,代码行数:16,代码来源:individualtemplate.py


示例19: testConfirm

    def testConfirm(self, info):
        city_location = CityLocation.get_or_create(
            self.store, u"São Carlos", u"SP", u"Brazil")
        person = self.create_person()
        address = self.create_address(person=person,
                                      city_location=city_location)
        editor = AddressEditor(self.store, person, address)
        address_slave = editor.address_slave
        self.assertSensitive(editor.main_dialog, ['ok_button'])
        valid_city = address_slave.city.read()

        # Trying to confirm the editor without leaving the entry.
        # Can be reproduced by pressing ALT+O
        address_slave.city.grab_focus()
        address_slave.city.update("INVALID CITY")
        self.assertValid(address_slave, ['city'])
        self.assertSensitive(editor.main_dialog, ['ok_button'])
        self.assertFalse(editor.confirm())
        self.assertInvalid(address_slave, ['city'])
        info.assert_called_once_with("The city is not valid")

        # When city looses focus, validation should be done
        address_slave.city.update(valid_city)
        self.assertSensitive(editor.main_dialog, ['ok_button'])
        address_slave.city.grab_focus()
        address_slave.city.update("INVALID CITY")
        # FIXME: For some reason, this only works here when grabbing the focus
        # on another widget and emitting the focus-out event. On the real
        # editor, pressing TAB or even trying to click on Ok is enough
        address_slave.state.grab_focus()
        address_slave.city.emit('focus-out-event',
                                gtk.gdk.Event(gtk.gdk.FOCUS_CHANGE))
        self.assertNotSensitive(editor.main_dialog, ['ok_button'])
        self.assertInvalid(address_slave, ['city'])

        address_slave.city.update(valid_city)
        self.assertValid(address_slave, ['city'])
        self.assertSensitive(editor.main_dialog, ['ok_button'])

        path = 'stoqlib.domain.address.CityLocation.is_valid_model'
        with mock.patch(path) as is_valid_model:
            is_valid_model.return_value = False
            self.assertFalse(editor.validate_confirm())
            self.assertFalse(editor.confirm())

        self.assertTrue(editor.validate_confirm())
        self.assertTrue(editor.confirm())
开发者ID:leandrorchaves,项目名称:stoq,代码行数:47,代码来源:test_address_editor.py


示例20: create_model

 def create_model(self, store):
     address = Address(person=self.person,
                       city_location=CityLocation.get_default(store),
                       is_main_address=self.is_main_address,
                       store=store)
     return _AddressModel(address, store)
开发者ID:hackedbellini,项目名称:stoq,代码行数:6,代码来源:addressslave.py



注:本文中的stoqlib.domain.address.CityLocation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.Domain类代码示例发布时间:2022-05-27
下一篇:
Python runtime.new_store函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap