def get_namespace(self, resource, context): abspath = resource.get_abspath() cart = ProductCart(context) # Base namespace namespace = STLForm.get_namespace(self, resource, context) # Choose payments payments = resource.get_resource('payments') total_price = cart.get_total_price(resource) view = Payments_ChoosePayment(total_price=total_price) namespace['choose_payment'] = view.GET(payments, context) # Alert MSG namespace['alert_msg'] = MSG( u"""To continue, you have to validate the terms of sales!""") # Progress bar namespace['progress'] = Shop_Progress(index=5).GET(resource, context) # Get delivery and bill address namespace for key in ['delivery_address', 'bill_address']: id = cart.addresses[key] if id is not None: namespace[key] = resource.get_user_address_namespace(id) else: namespace[key] = None # Get products informations namespace['cart'] = Cart_View(see_actions=False).GET(resource, context) # Get user delivery country addresses = resource.get_resource('addresses').handler delivery_address = cart.addresses['delivery_address'] record = addresses.get_record(delivery_address) country = addresses.get_record_value(record, 'country') return namespace
def GET(self, resource, context): reference = context.query['reference'] if reference: order = resource.parent.get_resource(str(reference), soft=True) if order: msg = INFO(u'Reference found !') return context.come_back(msg, goto=context.get_link(order)) else: context.message = ERROR(u'Unknow reference "%s"' % reference) return STLForm.GET(self, resource, context)
def get_namespace(self, resource, context): namespace = STLForm.get_namespace(self, resource, context) # Register link register_link = '/;register' if getattr(resource, 'register', None): register_link = './;register' namespace['register_link'] = register_link # Progress bar ? progress = None if context.resource.name == 'shop': # If user is in shop, it's a payment process, # so we have to show a progress bar progress = Shop_Progress(index=2).GET(resource, context) namespace['progress'] = progress # Go back here on register ? if getattr(resource, 'go_back_here_on_register', False) is True: goto = context.uri.path namespace['register_link'] += '?goto=%s' % goto return namespace
def GET(self, resource, context): cart = ProductCart(context) # Check if cart is valid if not cart.is_valid(): return context.come_back(CART_ERROR, goto='/') return STLForm.GET(self, resource, context)
def GET(self, resource, context): # Back-Office hostname = context.uri.authority if hostname[:6] == 'admin.': return context.uri.resolve('/shop/;administration') return STLForm.GET(self, resource, context)
def get_namespace(self, resource, context): namespace = STLForm.get_namespace(self, resource, context) namespace["name"] = resource.name return namespace
def POST(self, resource, context): real_resource = self.get_real_resource(resource, context) return STLForm.POST(self, real_resource, context)
def get_namespace(self, resource, context): namespace = STLForm.get_namespace(self, resource, context) namespace['name'] = resource.name return namespace
def get_schema(self, resource, context): return merge_dicts(STLForm.get_schema(self, resource, context), resource.get_purchase_options_schema())