def setUp(self):
    layer = self.globs['layer']
    self.globs.update({
        'portal': layer['portal'],
        'portal_url': layer['portal'].absolute_url(),
        'browser': Browser(layer['app']),
    })
    ztc.utils.setupCoreSessions(layer['app'])
    portal = self.globs['portal']
    browser = self.globs['browser']
    portal_url = self.globs['portal_url']
    browser.setBaseUrl(portal_url)

    browser.handleErrors = True
    portal.error_log._ignored_exceptions = ()

    setRoles(portal, TEST_USER_ID, ['Manager'])

    portal.invokeFactory(
        'CartFolder',
        'cfolder',
    )
    cfolder = portal.cfolder
    cfolder.reindexObject()
    portal.invokeFactory(
        'Document',
        'document01',
        title='Document01',
    )
    document01 = portal.document01
    document01.reindexObject()
    alsoProvides(document01, IAddableToCart)
    IAnnotations(document01)['collective.cart.core'] = ProductAnnotations()
    product01 = IProduct(document01)
    product01.price = 10.0
    product01.stock = 20
    product01.unlimited_stock = False
    product01.max_addable_quantity = 30
    portal.invokeFactory(
        'Document',
        'document02',
        title='Document02',
    )
    document02 = portal.document02
    document02.reindexObject()
    alsoProvides(document02, IAddableToCart)
    IAnnotations(document02)['collective.cart.core'] = ProductAnnotations()
    product02 = IProduct(document02)
    product02.price = 5.0
    product02.unlimited_stock = True

    transaction.commit()
def setUp(self):
    layer = self.globs['layer']
    self.globs.update({
        'portal': layer['portal'],
        'portal_url': layer['portal'].absolute_url(),
        'browser': Browser(layer['app']),
    })
    ztc.utils.setupCoreSessions(layer['app'])
    portal = self.globs['portal']
    browser = self.globs['browser']
    portal_url = self.globs['portal_url']
    browser.setBaseUrl(portal_url)

    browser.handleErrors = True
    portal.error_log._ignored_exceptions = ()

    setRoles(portal, TEST_USER_ID, ['Manager'])

    portal.invokeFactory(
        'CartFolder',
        'cfolder',
    )
    cfolder = portal.cfolder
    cfolder.reindexObject()
    portal.invokeFactory(
        'Document',
        'document01',
        title='Document01',
    )
    document01 = portal.document01
    document01.reindexObject()
    alsoProvides(document01, IAddableToCart)
    IAnnotations(document01)['collective.cart.core'] = ProductAnnotations()
    product01 = IProduct(document01)
    product01.price = 10.0
    product01.stock = 20
    product01.unlimited_stock = False
    product01.max_addable_quantity = 30
    portal.invokeFactory(
        'Document',
        'document02',
        title='Document02',
    )
    document02 = portal.document02
    document02.reindexObject()
    alsoProvides(document02, IAddableToCart)
    IAnnotations(document02)['collective.cart.core'] = ProductAnnotations()
    product02 = IProduct(document02)
    product02.price = 5.0
    product02.unlimited_stock = True

    transaction.commit()
Example #3
0
 def __call__(self):
     form = self.request.form
     if form.get('form.button.save', None) is not None:
         context = aq_inner(self.context)
         product = IProduct(context)
         re = getUtility(IRegularExpression)
         price = form.get('price')
         if re.float(price):
             product.price = IPortal(context).decimal_price(price)
         unlimited_stock = form.get('unlimited_stock')
         if unlimited_stock == 'on':
             product.unlimited_stock = True
         if unlimited_stock != 'on':
             product.unlimited_stock = False
         stock = form.get('stock')
         if re.integer(stock):
             product.stock = int(stock)
         max_addable_quantity = form.get('max_addable_quantity')
         if re.integer(max_addable_quantity):
             product.max_addable_quantity = int(max_addable_quantity)
     return self.template()
Example #4
0
 def update(self):
     form = self.request.form
     if form.get("form.button.UpdateProductBasic", None) is not None:
         context = aq_inner(self.context)
         product = IProduct(context)
         re = getUtility(IRegularExpression)
         price = form.get("price")
         if re.float(price):
             product.price = IPortal(context).decimal_price(price)
         unlimited_stock = form.get("unlimited_stock")
         if unlimited_stock == "on":
             product.unlimited_stock = True
         if unlimited_stock != "on":
             product.unlimited_stock = False
         stock = form.get("stock")
         if re.integer(stock):
             product.stock = int(stock)
         max_addable_quantity = form.get("max_addable_quantity")
         if re.integer(max_addable_quantity):
             product.max_addable_quantity = int(max_addable_quantity)
         return self.request.response.redirect(self.current_url)
Example #5
0
 def __call__(self):
     form = self.request.form
     if form.get('form.button.save', None) is not None:
         context = aq_inner(self.context)
         product = IProduct(context)
         re = getUtility(IRegularExpression)
         price = form.get('price')
         if re.float(price):
             product.price = IPortal(context).decimal_price(price)
         unlimited_stock = form.get('unlimited_stock')
         if unlimited_stock == 'on':
             product.unlimited_stock = True
         if unlimited_stock != 'on':
             product.unlimited_stock = False
         stock = form.get('stock')
         if re.integer(stock):
             product.stock = int(stock)
         max_addable_quantity = form.get('max_addable_quantity')
         if re.integer(max_addable_quantity):
             product.max_addable_quantity = int(max_addable_quantity)
     return self.template()
def setUp(self):
    layer = self.globs['layer']
    # Update global variables within the tests.
    self.globs.update({
        'portal': layer['portal'],
        'portal_url': layer['portal'].absolute_url(),
        'browser': Browser(layer['app']),
    })
    ztc.utils.setupCoreSessions(layer['app'])
    portal = self.globs['portal']
    browser = self.globs['browser']
    portal_url = self.globs['portal_url']
    browser.setBaseUrl(portal_url)

    browser.handleErrors = True
    portal.error_log._ignored_exceptions = ()

    setRoles(portal, TEST_USER_ID, ['Manager'])

    portal.invokeFactory('CartFolder', 'cfolder')
    portal.invokeFactory(
        'ShippingMethod',
        'method01',
        title="ShippingMethod01",
        base_charge=10.0,
        weight_charge=5.0,
    )
    method01 = portal.method01
    method01.reindexObject()

    ## Create Product00
    portal.invokeFactory(
        'Document',
        'doc00',
        title='Product00',
        description='Description of Product00',
    )
    doc00 = portal.doc00
    alsoProvides(doc00, IAddableToCart)
    IAnnotations(doc00)['collective.cart.core'] = ProductAnnotations()
    product00 = IProduct(doc00)
    product00.price = Decimal('100.00')
    product00.unlimited_stock = True
    product00.max_addable_quantity = 5

    ## Create Product01
    portal.invokeFactory(
        'Document',
        'doc01',
        title='Product01',
        description='Description of Product01',
    )
    doc01 = portal.doc01
    alsoProvides(doc01, IAddableToCart)
    IAnnotations(doc01)['collective.cart.core'] = ProductAnnotations()
    product01 = IProduct(doc01)
    product01.price = Decimal('10.00')
    product01.stock = 50
    product01.max_addable_quantity = 30

    ## Create Product02
    portal.invokeFactory(
        'Document',
        'doc02',
        title='Product02',
        description='Description of Product02',
    )
    doc02 = portal.doc02
    alsoProvides(doc02, IAddableToCart)
    IAnnotations(doc02)['collective.cart.core'] = ProductAnnotations()
    product02 = IProduct(doc02)
    product02.price = Decimal('5.00')
    product02.stock = 20
    product02.max_addable_quantity = 50

    transaction.commit()
def setUp(self):
    layer = self.globs['layer']
    # Update global variables within the tests.
    self.globs.update({
        'portal': layer['portal'],
        'portal_url': layer['portal'].absolute_url(),
        'browser': Browser(layer['app']),
    })
    ztc.utils.setupCoreSessions(layer['app'])
    portal = self.globs['portal']
    browser = self.globs['browser']
    portal_url = self.globs['portal_url']
    browser.setBaseUrl(portal_url)

    browser.handleErrors = True
    portal.error_log._ignored_exceptions = ()

    setRoles(portal, TEST_USER_ID, ['Manager'])

    portal.invokeFactory('CartFolder', 'cfolder')
    portal.invokeFactory(
        'ShippingMethod',
        'method01',
        title="ShippingMethod01",
        base_charge=10.0,
        weight_charge=5.0,
    )
    method01 = portal.method01
    method01.reindexObject()

    ## Create Product00
    portal.invokeFactory(
        'Document',
        'doc00',
        title='Product00',
        description='Description of Product00',
    )
    doc00 = portal.doc00
    alsoProvides(doc00, IAddableToCart)
    IAnnotations(doc00)['collective.cart.core'] = ProductAnnotations()
    product00 = IProduct(doc00)
    product00.price = Decimal('100.00')
    product00.unlimited_stock = True
    product00.max_addable_quantity = 5

    ## Create Product01
    portal.invokeFactory(
        'Document',
        'doc01',
        title='Product01',
        description='Description of Product01',
    )
    doc01 = portal.doc01
    alsoProvides(doc01, IAddableToCart)
    IAnnotations(doc01)['collective.cart.core'] = ProductAnnotations()
    product01 = IProduct(doc01)
    product01.price = Decimal('10.00')
    product01.stock = 50
    product01.max_addable_quantity = 30

    ## Create Product02
    portal.invokeFactory(
        'Document',
        'doc02',
        title='Product02',
        description='Description of Product02',
    )
    doc02 = portal.doc02
    alsoProvides(doc02, IAddableToCart)
    IAnnotations(doc02)['collective.cart.core'] = ProductAnnotations()
    product02 = IProduct(doc02)
    product02.price = Decimal('5.00')
    product02.stock = 20
    product02.max_addable_quantity = 50

    transaction.commit()