Exemplo n.º 1
0
 def test_infos(self, getToolByName):
     from collective.cart.shopping.interfaces import ICustomerInfo
     adapter = IMember(self.portal)
     getToolByName().getHomeFolder().getPhysicalPath.return_value = ['', 'path']
     adapter.get_brains = mock.Mock()
     adapter.infos()
     adapter.get_brains.assert_called_with(ICustomerInfo, path='/path', depth=1)
Exemplo n.º 2
0
 def test_rest_of_infos(self, getToolByName):
     adapter = IMember(self.portal)
     info1 = mock.Mock()
     info1.UID = 'uuid1'
     info2 = mock.Mock()
     info2.UID = 'uuid2'
     info3 = mock.Mock()
     info3.UID = 'uuid3'
     adapter.get_brains = mock.Mock(return_value=[info1, info2, info3])
     self.assertEqual(adapter.rest_of_infos('uuid1'), [info2, info3])
     self.assertEqual(adapter.rest_of_infos('uuid2'), [info1, info3])
     self.assertEqual(adapter.rest_of_infos('uuid3'), [info1, info2])
Exemplo n.º 3
0
 def __call__(self, context):
     terms = []
     for brain in IMember(context).infos():
         info = u'{} {}: {}'.format(brain.first_name, brain.last_name,
                                    brain.street)
         terms.append(
             SimpleVocabulary.createTerm(info, str(brain.UID), info))
     return SimpleVocabulary(terms)
Exemplo n.º 4
0
def add_shipping_info_to_address_book_for_the_first_time(event):
    member = IMember(event.context)
    if member.area and not member.default_shipping_info:
        data = IShoppingSite(event.context).get_address('shipping')
        oid = u'{}1'.format('shipping')
        info = createContentInContainer(
            member.area, 'collective.cart.shopping.CustomerInfo', id=oid, checkConstraints=False, **data)

        if not IShoppingSite(event.context).billing_same_as_shipping:
            info.info_type = u'shipping'

        modified(info)
Exemplo n.º 5
0
 def addresses(self):
     result = []
     for item in IContentListing(IMember(self.context).infos()):
         res = {
             'name': self._name(item),
             'organization': self._organization(item),
             'street': item.street,
             'city': self._city(item),
             'email': item.email,
             'phone': item.phone,
             'edit_url': '{}/edit'.format(item.getURL()),
         }
         result.append(res)
     return result
Exemplo n.º 6
0
 def test_default_shipping_info(self, getToolByName):
     adapter = IMember(self.portal)
     getToolByName().getHomeFolder().default_shipping_info = 'uuid'
     adapter.get_brain = mock.Mock()
     adapter.default_shipping_info()
     adapter.get_brain.assert_called_with(UID='uuid')