def CustomerNotificationChoices( context ): return TitledVocabulary.fromTitles( [ ("no_notification", _(u"Do not send customer email notification of a completed transaction")), ("notification", _(u"Send customer email notification of a completed transaction")) ] )
def handle_load_template(self, action, data): order_id = self.request.form.get('order-template-id') found = False for o in self.orders: if o.order_id == order_id: found = True break if not found: self.status = _(u"Could not find order") return # fetch cart from view cart = self.manager.__parent__.cart for v in o.shopping_cart.values(): content = v.resolve() item_factory = component.getMultiAdapter( (cart, content), interfaces.ILineItemFactory) if IVariableAmountDonatableMarker.providedBy(content): item_factory.create(amount=v.cost) else: item_factory.create(quantity=v.quantity) self.status = _(u"Previous Order Loaded into Cart")
def renderExtra( self ): translate = lambda msg: utranslate(domain='plonegetpaid', msgid=msg, context=self.request) if not len( self.context ): return super( CartFormatter, self).renderExtra() totals = self.getTotals() tax_list = totals.getTaxCost() shipping_price = totals.getShippingCost() subtotal_price = totals.getSubTotalPrice() total_price = totals.getTotalPrice() buffer = [ u'<div class="getpaid-totals"><table class="listing">'] buffer.append('<tr><th>') buffer.append( translate(_(u"SubTotal")) ) buffer.append( '</th><td style="border-top:1px solid #8CACBB;">%0.2f</td></tr>'%( subtotal_price ) ) # buffer.append( "<tr><th>" ) # buffer.append( translate(_(u"Shipping")) ) # buffer.append( "</th><td>%0.2f</td></tr>"%( shipping_price ) ) for tax in tax_list: buffer.append( "<tr><th>%s</th><td>%0.2f</td></tr>"%( tax['name'], tax['value'] ) ) buffer.append( "<tr><th>" ) buffer.append( translate(_(u"Total")) ) buffer.append( "</th><td>%0.2f</td></tr>"%( total_price ) ) buffer.append('</table></div>') return u''.join( buffer) + super( CartFormatter, self).renderExtra()
class ShoppingCartActions( FormViewlet ): template = ZopeTwoPageTemplateFile('templates/cart-actions.pt') def render( self ): return self.template() def doesCartContainItems( self, *args ): return bool( len( self.__parent__.cart ) ) def isLoggedIn( self, *args ): return getSecurityManager().getUser().getId() is not None def isAnonymous( self, *args ): return getSecurityManager().getUser().getId() is None @form.action(_("Register another person"), name='continue-shopping') def handle_continue_shopping( self, action, data ): # Go back to the registration form portal = getToolByName( self.context, 'portal_url').getPortalObject() url = portal.absolute_url() + '/registrations' return self.request.RESPONSE.redirect( url ) @form.action(_("Checkout and Pay for Registrations"), condition="doesCartContainItems", name="Checkout") def handle_checkout( self, action, data ): # go to order-create # force ssl? redirect host? options portal = getToolByName( self.context, 'portal_url').getPortalObject() url = portal.absolute_url() + '/registrations/@@getpaid-checkout-wizard#content' return self.request.RESPONSE.redirect( url )
class ShoppingCartListing( ContainerViewlet ): actions = ContainerViewlet.actions.copy() columns = [ column.SelectionColumn( lambda item: item.item_id, name="selection"), column.GetterColumn( title=_(u"Name"), getter=lineItemURL ), column.GetterColumn( title=_(u"Price"), getter=lineItemPrice ), ] selection_column = columns[0] template = ZopeTwoPageTemplateFile('templates/cart-listing.pt') formatter_factory = CartFormatter def __init__( self, *args, **kw): super( ShoppingCartListing, self ).__init__( *args, **kw ) for column in self.columns: if hasattr(column, 'title'): column.title = utranslate(domain='plonegetpaid', msgid=column.title, context=self.request) def getContainerContext( self ): return self.__parent__.cart def isOrdered( self, *args ): # shopping cart should not be ordered, so override this with False return False
class GDWShoppingCartListing(ShoppingCartListing): """ """ template = ZopeTwoPageTemplateFile('templates/cart-listing.pt') columns = [ column.SelectionColumn(lambda item: item.item_id, name="selection"), column.FieldEditColumn(_(u"Quantity"), 'edit', interfaces.ILineItem['quantity'], lambda item: item.item_id, name="Quantity"), column.GetterColumn(title=_(u"Name"), name="Name", getter=lineItemURL, cell_formatter=formatLinkCell), column.GetterColumn(title=_(u"Price"), name="Price", getter=lineItemPrice), column.GetterColumn(title=_(u"Total"), name="Total", getter=lineItemTotal), ] def update(self): for column in self.columns: if column.name == 'selection': continue if hasattr(column, 'title'): column.title = utranslate(domain='plonegetpaid', msgid=column.name, context=self.request) super(ShoppingCartListing, self).update()
def handle_load_template( self, action, data): order_id = self.request.form.get('order-template-id') found = False for o in self.orders: if o.order_id == order_id: found = True break if not found: self.status = _(u"Could not find order") return # fetch cart from view cart = self.manager.__parent__.cart for v in o.shopping_cart.values(): content = v.resolve() item_factory = component.getMultiAdapter( (cart, content), interfaces.ILineItemFactory ) if IVariableAmountDonatableMarker.providedBy(content): item_factory.create( amount=v.cost ) else: item_factory.create( quantity=v.quantity ) self.status = _(u"Previous Order Loaded into Cart")
def MerchantNotificationChoices( context ): return TitledVocabulary.fromTitles( [ ("no_notification", _(u"Do not send merchant email notification of a completed transaction")), ("notification", _(u"Send merchant email notification when a transaction happens")), #("encrypted_notification", _u"Send merchant encrypted email notification when a transaction happens")] ] )
def CustomerNotificationChoices(context): return TitledVocabulary.fromTitles([ ("no_notification", _(u"Do not send customer email notification of a completed transaction" )), ("notification", _(u"Send customer email notification of a completed transaction")) ])
class IGetPaidManagementSessionTimeout(igetpaid.IPersistentOptions): """ """ cart_session_timeout = schema.Int( title=_(u"Session Timeout"), required=True, description=_(u"Shopping cart session timeout (in seconds)"), default=3600, )
class IGetPaidManagementLegalDisclaimerOptions(igetpaid.IPersistentOptions): """ """ disclaimer = schema.Text( title=_(u"Disclaimer"), required=False, ) privacy_policy = schema.Text(title=_(u"Privacy Policy"), required=False)
class IGetPaidManagementCheckoutOptions(igetpaid.IPersistentOptions): """ """ use_contact_me_with_offers = schema.Bool( title=_(u"Display 'Contact me with offers' option on Checkout page"), default=True) alternate_opt_in_text = schema.TextLine( title=_(u"Text to use for opt in checkbox"), required=False)
def MerchantNotificationChoices(context): return TitledVocabulary.fromTitles([ ("no_notification", _(u"Do not send merchant email notification of a completed transaction" )), ("notification", _(u"Send merchant email notification when a transaction happens")), #("encrypted_notification", _u"Send merchant encrypted email notification when a transaction happens")] ])
class ShoppingCartListing(ContainerViewlet): actions = ContainerViewlet.actions.copy() columns = [ column.SelectionColumn(lambda item: item.item_id, name="selection"), column.FieldEditColumn(_(u"Quantity"), 'edit', interfaces.ILineItem['quantity'], lambda item: item.item_id), column.GetterColumn(title=_(u"Name"), getter=lineItemURL, cell_formatter=formatLinkCell), column.GetterColumn(title=_(u"Price"), getter=lineItemPrice), column.GetterColumn(title=_(u"Total"), getter=lineItemTotal), ] selection_column = columns[0] quantity_column = columns[1] template = ZopeTwoPageTemplateFile('templates/cart-listing.pt') formatter_factory = CartFormatter def __init__(self, *args, **kw): super(ShoppingCartListing, self).__init__(*args, **kw) for column in self.columns: if hasattr(column, 'title'): column.title = utranslate(domain='plonegetpaid', msgid=column.title, context=self.request) def getContainerContext(self): return self.__parent__.cart def isOrdered(self, *args): # shopping cart should not be ordered, so override this with False return False @form.action(_("Update"), condition="isNotEmpty") def handle_update(self, action, data): try: data = self.quantity_column.input(self.container.values(), self.request) self.form_reset = True self.quantity_column.update(self.container.values(), data) for item_id in self.container: if self.container[item_id].quantity == 0: del self.container[item_id] except: raise self.form_reset = True #reset the form data in the request for i in self.request.form.keys(): self.request.form.pop(i)
def getShippingMethod(self): # check the traversable wrrapper if not interfaces.IShippableOrder.providedBy( self.order ): return _(u"N/A") service = component.queryUtility( interfaces.IShippingRateService, self.order.shipping_service ) # play nice if the a shipping method is removed from the store if not service: return _(u"N/A") return service.getMethodName( self.order.shipping_method )
def getShippingMethod(self): # check the traversable wrrapper if not interfaces.IShippableOrder.providedBy(self.order): return _(u"N/A") service = component.queryUtility(interfaces.IShippingRateService, self.order.shipping_service) # play nice if the a shipping method is removed from the store if not service: return _(u"N/A") return service.getMethodName(self.order.shipping_method)
class IGetPaidManagementCurrencyOptions(igetpaid.IPersistentOptions): """ """ currency_symbol = schema.TextLine(title=_(u"Currency Symbol"), required=True, default=u"$") positive_currency_format = schema.TextLine( title=_(u"Positive Currency Format"), required=False, default=u"") negative_currency_format = schema.TextLine( title=_(u"Negative Currency Format"), required=False, default=u"") digit_grouping_symbol = schema.TextLine(title=_(u"Digit Grouping Symbol"), required=False, default=u"") digit_grouping_symbol = schema.TextLine( title=_(u"Number of Digits in Group"), required=False, default=u"") digit_grouping_symbol = schema.TextLine(title=_(u"Decimal Symbol"), required=False, default=u"") digits_after_decimal = schema.TextLine( title=_(u"Number of Digits After Decimal"), required=False, default=u"2") us_currency_formatting = schema.TextLine( title=_(u"US Currency Formatting"), required=False, default=u"")
class ShoppingCartActions(FormViewlet): template = ZopeTwoPageTemplateFile('templates/cart-actions.pt') def render(self): return self.template() def doesCartContainItems(self, *args): return bool(len(self.__parent__.cart)) def isLoggedIn(self, *args): return getSecurityManager().getUser().getId() is not None def isAnonymous(self, *args): return getSecurityManager().getUser().getId() is None @form.action(_("Continue Shopping"), name='continue-shopping') def handle_continue_shopping(self, action, data): # redirect the user to the last thing they were viewing if there is not # such thing to the came_from variable and if this doesn't exist neither # to the portal base url, it is better than nothing came_from = sessions.get_came_from_url(self.context) if came_from: next_url = came_from else: last_item = getattr(self.__parent__.cart, 'last_item', None) if not last_item: payable = getToolByName(self.context, 'portal_url').getPortalObject() else: # Remove any variable payment indicator from UID last_item = last_item.split('-')[0] payable = getToolByName( self.context, 'reference_catalog').lookupObject(last_item) if not self.request.get('came_from'): next_url = payable.absolute_url() else: next_url = self.request.get('came_from') return self.request.RESPONSE.redirect(next_url) @form.action(_("Checkout"), condition="doesCartContainItems", name="Checkout") def handle_checkout(self, action, data): # go to order-create # force ssl? redirect host? options portal = getToolByName(self.context, 'portal_url').getPortalObject() url = portal.absolute_url() + '/@@getpaid-checkout-wizard' return self.request.RESPONSE.redirect(url)
class IGetPaidManagementContentTypes(igetpaid.IPersistentOptions): buyable_types = schema.List( title=_(u"Buyable Types"), required=False, default=[], description=_(u"Buyable Content delivered through the web/virtually"), value_type=schema.Choice(title=u"buyable_types", source="plone.content_types")) premium_types = schema.List( title=_(u"Premium Content Types"), required=False, default=[], description=_(u"Content Types only available to premium memberships"), value_type=schema.Choice(title=u"premium_types", source="plone.content_types")) donate_types = schema.List( title=_(u"Donatable Content Types"), required=False, default=[], description=_(u"Content Types available for donation"), value_type=schema.Choice(title=u"donate_types", source="plone.content_types")) shippable_types = schema.List( title=_(u"Shippable Product Types"), required=False, default=[], description= _(u"Content Types that represent goods that can be purchased and shipped" ), value_type=schema.Choice(title=u"shippable_types", source="plone.content_types"))
def renderCart(self): cart = component.getUtility(IShoppingCartUtility).get(self.context) if not cart: return _(u"N/A") for column in self.columns: if hasattr(column, 'title'): column.title = utranslate(domain='plonegetpaid', msgid=column.name, context=self.request) # create an order so that tax/shipping utilities have full order information # to determine costs (ie. billing/shipping address ). order = self.createTransientOrder() formatter = OrderFormatter( order, self.request, cart.values(), prefix=self.prefix, visible_column_names=[c.name for c in self.columns], #sort_on = ( ('name', False) columns=self.columns) formatter.cssClasses['table'] = 'listing' return formatter()
class OrderListingComponent( BaseOrderListingComponent ): # template = ZopeTwoPageTemplateFile('templates/orders-listing.pt') columns = [ column.GetterColumn( title=_(u"Order Id"), getter=renderOrderId, cell_formatter=raw_cell_formatter ), column.GetterColumn( title=_(u"Customer Id"), getter=AttrColumn("user_id" ) ), # column.GetterColumn( title=_(u"Last4"), getter=AttrColumn("user_payment_info_last4" ) ), # column.GetterColumn( title=_(u"Proc Trans Id"), getter=AttrColumn("user_payment_info_trans_id" ) ), # column.GetterColumn( title=_(u"Name on Card"), getter=AttrColumn("name_on_card" ) ), # column.GetterColumn( title=_(u"Card Phone#"), getter=AttrColumn("bill_phone_number" ) ), column.GetterColumn( title=_(u"Status"), getter=AttrColumn("finance_state") ), # column.GetterColumn( title=_(u"Fulfillment"), getter=AttrColumn("fulfillment_state") ), column.GetterColumn( title=_(u"Price"), getter=PriceColumn("getTotalPrice") ), column.GetterColumn( title=_(u"Created"), getter=DateColumn("creation_date") ) ]
def listing(self): for column in self.columns: if hasattr(column, 'title'): column.title = utranslate(domain='plonegetpaid', msgid=column.title, context=self.request) columns = self.columns values = self.manager.get('orders-search').results if not values: message = _(u'No orders found for your filter.') return self.context.utranslate(msgid=message, default=message, domain='plonegetpaid') formatter = BatchingFormatter( self.context, self.request, values, prefix="form", batch_size=10, visible_column_names=[c.name for c in columns], #sort_on = ( ('name', False) columns=columns) formatter.cssClasses['table'] = 'listing' return formatter()
def validate(self, action, data): errors = super(CheckoutAddress, self).validate(action, data) reg = findRegistrationObject(self.context, data.get("email")) if reg is None: widget = self.widgets.get("email") error = WidgetInputError(field_name="email", widget_title=_(u"Email"), errors=_(u"Not registered email.")) widget._error = error errors += (error,) elif reg.paid_fee: widget = self.widgets.get("email") error = WidgetInputError( field_name="email", widget_title=_(u"Email"), errors=_(u"This attendee has already paid.") ) widget._error = error errors += (error,) return errors
class OrderCSVComponent(core.ComponentViewlet): template = ZopeTwoPageTemplateFile('templates/orders-export-csv.pt') order = 3 def render(self): return self.template() @form.action(_(u"Export Search")) def export_search(self, action, data): search = self.manager.get('orders-search') listing = self.manager.get('order-listing') io = StringIO.StringIO() writer = csv.writer(io) writer.writerow([c.name for c in listing.columns]) field_getters = [] for column in listing.columns: if column.name == 'Order Id': field_getters.append(lambda x, y: x.order_id) else: field_getters.append(column.getter) for order in search.results: writer.writerow([getter(order, None) for getter in field_getters]) # um.. send to user, we need to inform our view, to do the appropriate thing # since we can't directly control the response rendering from the viewlet self._parent._download_content = ('text/csv', io.getvalue(), 'OrderSearchExport')
def bindTransitions(form_instance, transitions, wf_name=None, collection=False, wf=None): """ bind workflow transitions into formlib actions """ assert not (collection and wf_name) if collection: success_factory = CollectionTransitionHandler elif wf_name: success_factory = lambda tid: TransitionHandler(tid, wf_name) else: success_factory = TransitionHandler actions = [] for tid in transitions: d = {} if success_factory: d['success'] = success_factory(tid) if wf is not None: action = form.Action(_(unicode(wf.getTransitionById(tid).title))) else: action = form.Action(tid, **d) action.form = form_instance action.__name__ = "%s.%s" % (form_instance.prefix, action.__name__) actions.append(action) return actions
def renderCart(self): cart = component.getUtility( interfaces.IShoppingCartUtility).get(self.context) if not cart: return _(u"N/A") for column in self.columns: if hasattr(column, 'title'): column.title = utranslate(domain='plonegetpaid', msgid=column.title, context=self.request) # create an order so that tax/shipping utilities have full order # information to determine costs (ie. billing/shipping address). order = self.createTransientOrder() formatter = OrderFormatter( order, self.request, cart.values(), prefix=self.prefix, visible_column_names=[c.name for c in self.columns], #sort_on = (('name', False) columns=self.columns ) formatter.cssClasses['table'] = 'listing' return formatter()
def renderItemName( item, formatter ): content = item.resolve() if not content: return _(u"N/A") content_url = content.absolute_url() title = unicode(content.Title(), "utf-8") return u'<a href="%s">%s</a>'%( content_url, title )
def renderItemName(item, formatter): content = item.resolve() if not content: return _(u"N/A") content_url = content.absolute_url() title = unicode(content.Title(), "utf-8") return u'<a href="%s">%s</a>' % (content_url, title)
class OrderContentsComponent( BaseOrderContentsComponent ): """ an item listing used to group items by workflow state and present relevant workflow actions """ # interface.implements( ) # template = ZopeTwoPageTemplateFile('templates/order-item-listing.pt') columns = [ column.SelectionColumn( lambda item: item.item_id, name="selection"), column.GetterColumn( title=_(u"Quantity"), getter=AttrColumn("quantity" ) ), column.GetterColumn( title=_(u"Item Id"), getter=renderItemId, cell_formatter=raw_cell_formatter ), column.GetterColumn( title=_(u"Name"), getter=renderItemName, cell_formatter=raw_cell_formatter ), column.GetterColumn( title=_(u"Price"), getter=renderItemCost ), # column.GetterColumn( title=_(u"Total"), getter=renderItemPrice ), # column.GetterColumn( title=_(u"Status"), getter=AttrColumn("fulfillment_state" ) ), ]
class GDWShoppingCartActions(ShoppingCartActions): """ """ template = ZopeTwoPageTemplateFile('templates/cart-actions.pt') @form.action(_("Continue Shopping"), name='continue-shopping') def handle_continue_shopping(self, action, data): portal = getToolByName(self.context, 'portal_url').getPortalObject() boutique = getattr(portal, 'shop') return self.request.RESPONSE.redirect(boutique.absolute_url()) @form.action(_("Checkout"), condition="doesCartContainItems", name="Checkout") def handle_checkout(self, action, data): portal = getToolByName(self.context, 'portal_url').getPortalObject() url = portal.absolute_url() + '/@@getpaid-checkout-wizard' return self.request.RESPONSE.redirect(url)
class IGetPaidManagementShippingMethods(igetpaid.IPersistentOptions): """ """ shipping_methods = schema.List( title=_(u"Shipping Methods"), required=False, default=[], description=_(u"Shipping methods to offer for orders in your store"), value_type=schema.Choice(title=u"shipping_methods", source="getpaid.shipping_methods")) shipping_services = schema.List( title=_(u"Shipping Rate Service"), required=True, default=[], description=_(u"Shipping services to offer for orders in your store"), value_type=schema.Choice(title=u"shipping_services", source="getpaid.shipping_services"))
def setupProcessorOptions( self ): manage_options = interfaces.IGetPaidManagementOptions( self.context ) processor_name = manage_options.payment_processor if not processor_name: self.status = _(u"Please Select Payment Processor in Payment Options Settings") return #NOTE: if a processor name is saved in the configuration but the corresponding payment method package # doesn't exist anymore, a corresponding adapter will not be found. try: processor = component.getAdapter( self.context, igetpaid.IPaymentProcessor, processor_name ) except: self.status = _(u"The currently configured Payment Processor cannot be found; please check if the corresponding package is installed correctly.") return self.form_fields = form.Fields( processor.options_interface )
class IGetPaidManagementPaymentOptions(igetpaid.IPersistentOptions): """ """ payment_processor = schema.Choice(title=_(u"Payment Processor"), source="getpaid.payment_methods", default='Testing Processor') allow_anonymous_checkout = schema.Bool( title=_(u"Allow Anonymous Checkout"), default=False) use_ssl_for_checkout = schema.Bool(title=_(u"Use SSL for checkout"), default=False) accepted_credit_cards = schema.List( title=_(u"Accepted Credit Cards"), required=False, default=list(CREDIT_CARD_TYPES), description=_(u"Credit cards accepted for payment"), value_type=schema.Choice(title=u"accepted_credit_cards", source="getpaid.core.credit_card_types"))
def getShipmentWeight(self): """ Lets return the weight in lbs for the moment """ # check the traversable wrrapper if not interfaces.IShippableOrder.providedBy(self.order): return _(u"N/A") totalShipmentWeight = 0 for eachProduct in self.order.shopping_cart.values(): if interfaces.IShippableLineItem.providedBy(eachProduct): weightValue = eachProduct.weight * eachProduct.quantity totalShipmentWeight += weightValue return totalShipmentWeight
def getShipmentWeight(self): """ Lets return the weight in lbs for the moment """ # check the traversable wrrapper if not interfaces.IShippableOrder.providedBy( self.order ): return _(u"N/A") totalShipmentWeight = 0 for eachProduct in self.order.shopping_cart.values(): if interfaces.IShippableLineItem.providedBy( eachProduct ): weightValue = eachProduct.weight * eachProduct.quantity totalShipmentWeight += weightValue return totalShipmentWeight
class GDWAllItems(AllItems): """ """ columns = [ column.SelectionColumn(lambda item: item.item_id, name="selection"), column.GetterColumn(title=_(u"Item Id"), getter=renderItemId), column.GetterColumn(title=_(u"Name"), getter=renderItemName), column.GetterColumn(title=_(u"Item Code"), getter=renderItemCode), column.GetterColumn(title=_(u"Price"), getter=renderItemCost), column.GetterColumn(title=_(u"Quantity"), getter=AttrColumn("quantity")), column.GetterColumn(title=_(u"Total"), getter=renderItemPrice), column.GetterColumn(title=_(u"Status"), getter=AttrColumn("fulfillment_state")), ]
class PayableCreation(PayableForm): actions = form.Actions() def update(self): marker.mark(self.context, self.marker) # create a temporary object so we don't have to modify context until we're ready to activate # it.. this creates some odd behavior on remarking though, where the user is always filling # in new values even though previously values are present in the underlying contxt annotation. self.adapters = { self.interface: options.PropertyBag.makeinstance(self.interface), igetpaid.IPayable: options.PropertyBag.makeinstance(igetpaid.IPayable) } return super(PayableForm, self).update() @form.action(_("Activate"), condition=form.haveInputWidgets) def activate_payable(self, action, data): self.adapters = {} self.handle_edit_action.success_handler(self, action, data) try: adapter = self.adapters[ self.form_fields['made_payable_by'].interface] except AttributeError: # BBB for Zope 2.10 adapter = self.adapters[ self.form_fields['made_payable_by'].field.interface] adapter.made_payable_by = getSecurityManager().getUser().getId() notify( event.PayableCreationEvent(self.context, adapter, self.interface)) # redirect to view translated_message = self.context.utranslate( u'Changes saved.', domain='plone').encode(self.context.getCharset()) encoded_message = urlencode( {'portal_status_message': translated_message}) extra = view_url(self.context) self.request.response.redirect( '%s%s?%s' % (self.context.absolute_url(), extra, encoded_message))
class TraversableWrapper( SimpleItem ): """ simple indeed, a zope2 transient wrapper around a persistent order so we can publish them ttw. """ interface.implements( igpc.IOrder ) id = title = _(u"Order Details") def Title( self ): return self.title def __init__( self, object ): self._object = object def __getattr__( self, name ): value = getattr( self._object, name, _marker ) if value is not _marker: return value return super( TraversableWrapper, self).__getattr__( name )
def save_address(self, data): """ store the address in the addressbook of the user """ book_key = 'addressbook_entry_name' entry = self.wizard.data_manager.get(book_key) del self.wizard.data_manager[book_key] # if the user fill the name of the entry mean that we have to save the # address if not entry: return elif isinstance(entry, list): entry = filter(None, entry) if not entry: return entry = entry[-1] uid = getSecurityManager().getUser().getId() if uid == 'Anonymous': return book = component.getUtility(IAddressBookUtility).get(uid) if entry in book: return # here we get the shipping address formSchemas = component.getUtility(interfaces.IFormSchemas) ship_address_info = formSchemas.getBagClass('shipping_address')() if data['ship_same_billing']: for field in data.keys(): if field.startswith('bill_'): ship_address_info.__setattr__( field.replace('bill_', 'ship_'), data[field]) else: for field in data.keys(): if field.startswith('ship_'): ship_address_info.__setattr__(field, data[field]) book[entry] = ship_address_info self.context.plone_utils.addPortalMessage( _(u'A new address has been saved') )
def setupShippingOptions(self): """ Queries shipping utilities and adapters to get the available shipping methods and returns a list of them for the template to display and the user to choose among. """ ship_method_code = self.request.form.get('form.shipping_method_code') if type(ship_method_code) == type([]): self.request.form['form.shipping_method_code'] = \ self.request.form['form.shipping_method_code'][-1] siteroot = getToolByName(self.context, "portal_url").getPortalObject() ship_service_names = IGetPaidManagementOptions( siteroot).shipping_services if not ship_service_names: self.status = _( "Misconfigured Store - No Shipping Method Activated" ) return order = self.createTransientOrder() service_options = {} for service_name in ship_service_names: service = component.getUtility( interfaces.IShippingRateService, name=service_name) rates = service.getRates(order) if rates.error is not None: self.status = '%(name)s Error: %(error)s.' % { 'name': service_name, 'error': rates.error } service_options[service_name] = rates.shipments self.ship_service_names = ship_service_names self.service_options = service_options
def renderCart(self): cart = getCart(self.context) if not cart: return _(u"N/A") for column in self.columns: if hasattr(column, "title"): column.title = utranslate(domain="plonegetpaid", msgid=column.title, context=self.request) # create an order so that tax/shipping utilities have full order # information to determine costs (ie. billing/shipping address ). order = self.createTransientOrder() formatter = OrderFormatter( order, self.request, cart.values(), prefix=self.prefix, visible_column_names=[c.name for c in self.columns], columns=self.columns, ) formatter.cssClasses["table"] = "listing" return formatter()
def listing( self ): for column in self.columns: if hasattr(column, 'title'): column.title = utranslate(domain='plonegetpaid', msgid=column.title, context=self.request) columns = self.columns values = self.manager.get('orders-search').results if not values: message = _(u'No orders found for your filter.') return self.context.utranslate(msgid=message, default=message, domain='plonegetpaid') formatter = BatchingFormatter( self.context, self.request, values, prefix="form", batch_size=10, visible_column_names = [c.name for c in columns], #sort_on = ( ('name', False) columns = columns ) formatter.cssClasses['table'] = 'listing' return formatter()
def bindTransitions( form_instance, transitions, wf_name=None, collection=False, wf=None ): """ bind workflow transitions into formlib actions """ assert not (collection and wf_name ) if collection: success_factory = CollectionTransitionHandler elif wf_name: success_factory = lambda tid: TransitionHandler( tid, wf_name ) else: success_factory = TransitionHandler actions = [] for tid in transitions: d = {} if success_factory: d['success'] = success_factory( tid ) if wf is not None: action = form.Action( _(unicode(wf.getTransitionById( tid ).title) ) ) else: action = form.Action( tid, **d ) action.form = form_instance action.__name__ = "%s.%s"%(form_instance.prefix, action.__name__) actions.append( action ) return actions
def title(self): """Title shown in @@manage-portlets. """ return _(u"Shopping Cart")
def title(self): """Title shown in @@manage-portlets. """ return _(u"Shippable")
def title(self): """Title shown in @@manage-portlets. """ return _(u"Registrations Cart")
def title(self): """Title shown in @@manage-portlets. """ return _(u"Premium")
def WeightUnits( context ): return vocabulary.SimpleVocabulary.fromValues( (_(u"Pounds"),) )
def Currencies( context ): return vocabulary.SimpleVocabulary.fromValues( (_(u"US Dollars"),) )
def title(self): """Title shown in @@manage-portlets. """ return _(u"Recurring Payment")
def title(self): """Title shown in @@manage-portlets. """ return _(u"Variable Amount Donation")