本文整理汇总了Python中satchmo.configuration.config_get_group函数的典型用法代码示例。如果您正苦于以下问题:Python config_get_group函数的具体用法?Python config_get_group怎么用?Python config_get_group使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_get_group函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
def update(request):
"""Update contact info"""
init_data = {}
areas, countries, only_country = get_area_country_options(request)
contact = Contact.from_request(request, create=False)
if request.POST:
new_data = request.POST.copy()
form = ExtendedContactInfoForm(countries, areas, new_data,
initial=init_data)
if form.is_valid():
if contact is None and request.user:
contact = Contact(user=request.user)
custID = form.save(contact=contact)
request.session['custID'] = custID
url = urlresolvers.reverse('satchmo_account_info')
return http.HttpResponseRedirect(url)
else:
if config_get_group('NEWSLETTER'):
show_newsletter = True
else:
show_newsletter = False
else:
if contact:
#If a person has their contact info, make sure we populate it in the form
for item in contact.__dict__.keys():
init_data[item] = getattr(contact,item)
if contact.shipping_address:
for item in contact.shipping_address.__dict__.keys():
init_data["ship_"+item] = getattr(contact.shipping_address,item)
if contact.billing_address:
for item in contact.billing_address.__dict__.keys():
init_data[item] = getattr(contact.billing_address,item)
if contact.primary_phone:
init_data['phone'] = contact.primary_phone.phone
show_newsletter = False
current_subscriber = False
if config_get_group('NEWSLETTER'):
show_newsletter = True
if contact:
from satchmo.newsletter import is_subscribed
current_subscriber = is_subscribed(contact)
init_data['newsletter'] = current_subscriber
form = ExtendedContactInfoForm(countries, areas, initial=init_data)
context = RequestContext(request, {
'form': form,
'country': only_country,
'show_newsletter': show_newsletter})
return render_to_response('contact/update_form.html', context)
示例2: inner_func
def inner_func(request):
class Collection:
pass
checkout_data = Collection()
payment_module = config_get_group('PAYMENT_BANKPASSWEB')
checkout_data.payment_module = payment_module
checkout_data.processor = processing_module.PaymentProcessor(payment_module)
# Are we really processing an order?
try:
order = Order.objects.from_request(request)
except Order.DoesNotExist:
url = lookup_url(payment_module, 'satchmo_checkout-step1')
return HttpResponseRedirect(url)
# Does our order have items in its cart?
tempCart = Cart.objects.from_request(request)
if tempCart.numItems == 0:
template = lookup_template(payment_module, 'checkout/empty_cart.html')
return render_to_response(template, RequestContext(request))
# Is our order still valid?
if not order.validate(request):
context = RequestContext(request,
{'message': _('Your order is no longer valid.')})
return render_to_response('shop_404.html', context)
# Finally call the view
checkout_data.order = order
checkout_data.cart = tempCart
return func(request, checkout_data)
示例3: register
def register(request, redirect=None, template='registration/registration_form.html'):
"""
Allows a new user to register an account.
"""
ret = register_handle_form(request, redirect)
success = ret[0]
todo = ret[1]
if len(ret) > 2:
extra_context = ret[2]
else:
extra_context = {}
if success:
return todo
else:
if config_get_group('NEWSLETTER'):
show_newsletter = True
else:
show_newsletter = False
ctx = {
'form': todo,
'title' : _('Registration Form'),
'show_newsletter' : show_newsletter
}
if extra_context:
ctx.update(extra_context)
context = RequestContext(request, ctx)
return render_to_response(template, context)
示例4: pay_ship_info
def pay_ship_info(request):
# Check that items are in stock
cart = Cart.objects.from_request(request)
if cart.not_enough_stock():
return HttpResponseRedirect(urlresolvers.reverse("satchmo_cart"))
return payship.simple_pay_ship_info(request, config_get_group('PAYMENT_COD'), 'checkout/cod/pay_ship.html')
示例5: confirm_info
def confirm_info(request):
# Check that items are in stock
cart = Cart.objects.from_request(request)
if cart.not_enough_stock():
return HttpResponseRedirect(urlresolvers.reverse("satchmo_cart"))
return confirm.credit_confirm_info(request, config_get_group('PAYMENT_CYBERSOURCE'))
示例6: one_step
def one_step(request):
# Check that items are in stock
cart = Cart.objects.from_request(request)
if cart.not_enough_stock():
return HttpResponseRedirect(urlresolvers.reverse("satchmo_cart"))
payment_module = config_get_group('PAYMENT_AUTOSUCCESS')
#First verify that the customer exists
try:
contact = Contact.objects.from_request(request, create=False)
except Contact.DoesNotExist:
url = lookup_url(payment_module, 'satchmo_checkout-step1')
return HttpResponseRedirect(url)
#Verify we still have items in the cart
if cart.numItems == 0:
template = lookup_template(payment_module, 'checkout/empty_cart.html')
return render_to_response(template, RequestContext(request))
# Create a new order
newOrder = Order(contact=contact)
pay_ship_save(newOrder, cart, contact,
shipping="", discount="")
request.session['orderID'] = newOrder.id
newOrder.add_status(status='Pending', notes = "Order successfully submitted")
record_payment(newOrder, payment_module, amount=newOrder.balance)
tempCart.empty()
success = lookup_url(payment_module, 'satchmo_checkout-success')
return HttpResponseRedirect(success)
示例7: google_checkout_image_url
def google_checkout_image_url(parser, token):
"""
Render the url for a google checkout image.
Sample usage::
{% google_checkout_image_url [imagesize] ['transparent'] ['disabled'] %}
"""
args = token.split_contents()
payment_module = config_get_group('PAYMENT_GOOGLE')
merchid = payment_module.MERCHANT_ID
sizes = CHECKOUT_BUTTON_SIZES.keys()
imgsize = "MEDIUM"
transparent = False
disabled = False
locale = None
for arg in args[1:]:
k = arg.upper()
if k == 'TRANSPARENT':
transparent = True
elif k == 'DISABLED':
disabled = True
else:
if k in sizes:
imgsize = k
else:
raise template.TemplateSyntaxError("%r tag got an unexpected argument. Perhaps a bad size? Didn't know: %s" % (args[0], arg))
return GoogleCheckoutImageUrlNode(merchid, imgsize, transparent, disabled)
示例8: confirm_info
def confirm_info(request, template='checkout/protx/confirm.html', extra_context={}):
payment_module = config_get_group('PAYMENT_PROTX')
controller = confirm.ConfirmController(request, payment_module)
controller.templates['CONFIRM'] = template
controller.extra_context = extra_context
controller.onForm = secure3d_form_handler
controller.confirm()
return controller.response
示例9: cost
def cost(self):
"""
Complex calculations can be done here as long as the return value is a decimal figure
"""
assert(self._calculated)
settings = config_get_group('satchmo.shipping.modules.usps')
if settings.HANDLING_FEE and float(str(settings.HANDLING_FEE)) > 0.0:
self.charges = Decimal(self.charges) + Decimal(str(settings.HANDLING_FEE))
return Decimal(str(self.charges))
示例10: payment_label
def payment_label(value):
"""convert a payment key into its translated text"""
payments = config_get("PAYMENT", "MODULES")
for mod in payments.value:
config = config_get_group(mod)
if config.KEY.value == value:
return translation.ugettext(config.LABEL)
return value.capitalize()
示例11: checkout_image_url
def checkout_image_url(merchid, imgsize, locale, transparent=False, disabled=False):
payment_module = config_get_group('PAYMENT_GOOGLE')
dimensions = CHECKOUT_BUTTON_SIZES[imgsize]
return ("%s?%s" % (
payment_module.CHECKOUT_BUTTON_URL,
urlencode((('merchant_id', merchid),
('w', dimensions[0]),
('h', dimensions[1]),
('style', _truefalse(transparent, t="trans", f="white")),
('variant', _truefalse(disabled, t="disabled", f="text")),
('loc', locale)))))
示例12: contact_info
def contact_info(request):
"""View which collects demographic information from customer."""
# First verify that the cart exists and has items
if request.session.get("cart"):
tempCart = Cart.objects.get(id=request.session["cart"])
if tempCart.numItems == 0:
return render_to_response("checkout/empty_cart.html", RequestContext(request))
else:
return render_to_response("checkout/empty_cart.html", RequestContext(request))
init_data = {}
areas, countries, only_country = get_area_country_options(request)
contact = Contact.from_request(request, create=False)
if request.POST:
new_data = request.POST.copy()
if not tempCart.is_shippable:
new_data["copy_address"] = True
form = PaymentContactInfoForm(countries, areas, new_data, initial=init_data)
if form.is_valid():
if contact is None and request.user:
contact = Contact(user=request.user)
custID = form.save(contact=contact, update_newsletter=False)
request.session["custID"] = custID
# TODO - Create an order here and associate it with a session
modulename = "PAYMENT_" + new_data["paymentmethod"]
paymentmodule = config_get_group(modulename)
url = lookup_url(paymentmodule, "satchmo_checkout-step2")
return http.HttpResponseRedirect(url)
else:
if contact:
# If a person has their contact info, make sure we populate it in the form
for item in contact.__dict__.keys():
init_data[item] = getattr(contact, item)
if contact.shipping_address:
for item in contact.shipping_address.__dict__.keys():
init_data["ship_" + item] = getattr(contact.shipping_address, item)
if contact.billing_address:
for item in contact.billing_address.__dict__.keys():
init_data[item] = getattr(contact.billing_address, item)
if contact.primary_phone:
init_data["phone"] = contact.primary_phone.phone
else:
# Allow them to login from this page.
request.session.set_test_cookie()
form = PaymentContactInfoForm(countries, areas, initial=init_data)
context = RequestContext(
request, {"form": form, "country": only_country, "paymentmethod_ct": len(config_value("PAYMENT", "MODULES"))}
)
return render_to_response("checkout/form.html", context)
示例13: render_template
def render_template(self, template, cart=None, contact=None):
from satchmo.shop.models import Config
shop_details = Config.objects.get_current()
settings = config_get_group('satchmo.shipping.modules.usps')
if not self.is_intl:
mail_type = CODES[self.service_type_code]
if mail_type == 'INTL': return ''
if mail_type == 'FIRST CLASS':
self.api = None
else:
self.api = APIS[mail_type]
else:
mail_type = None
self.api = None
# calculate the weight of the entire order
weight = Decimal('0.0')
for item in cart.cartitem_set.all():
if item.product.weight:
weight += item.product.weight * item.quantity
self.verbose_log('WEIGHT: %s' % weight)
# I don't know why USPS made this one API different this way...
if self.api == 'ExpressMailCommitment':
zip_ending = 'ZIP'
else:
zip_ending = 'zip'
# get the shipping country (for the international orders)
ship_country = contact.shipping_address.country.printable_name
configuration = {
'userid': settings.USER_ID.value,
'password': settings.USER_PASSWORD.value,
'container': settings.SHIPPING_CONTAINER.value,
'ship_type': mail_type,
'shop_details': shop_details
}
c = Context({
'config': configuration,
'cart': cart,
'contact': contact,
'is_international': self.is_intl,
'api': self.api,
'weight': weight,
'zip': zip_ending,
'country': ship_country,
'first_class_types': ['LETTER', 'FLAT', 'PARCEL']
})
t = loader.get_template(template)
return t.render(c)
示例14: one_step
def one_step(request):
payment_module = config_get_group('PAYMENT_AUTOSUCCESS')
#First verify that the customer exists
contact = Contact.from_request(request, create=False)
if contact is None:
url = lookup_url(payment_module, 'satchmo_checkout-step1')
return http.HttpResponseRedirect(url)
#Verify we still have items in the cart
if request.session.get('cart', False):
tempCart = Cart.objects.get(id=request.session['cart'])
if tempCart.numItems == 0:
template = lookup_template(payment_module, 'checkout/empty_cart.html')
return render_to_response(template, RequestContext(request))
else:
template = lookup_template(payment_module, 'checkout/empty_cart.html')
return render_to_response(template, RequestContext(request))
# Create a new order
newOrder = Order(contact=contact)
pay_ship_save(newOrder, tempCart, contact,
shipping="", discount="")
request.session['orderID'] = newOrder.id
newOrder.add_status(status='Pending', notes = "Order successfully submitted")
orderpayment = OrderPayment(order=newOrder, amount=newOrder.balance, payment=payment_module.KEY.value)
orderpayment.save()
#Now, send a confirmation email
if payment_module['EMAIL'].value:
shop_config = Config.get_shop_config()
shop_email = shop_config.store_email
shop_name = shop_config.store_name
t = loader.get_template('email/order_complete.txt')
c = Context({'order': newOrder,
'shop_name': shop_name})
subject = "Thank you for your order from %s" % shop_name
try:
email = orderToProcess.contact.email
body = t.render(c)
send_mail(subject, body, shop_email,
[email], fail_silently=False)
except SocketError, e:
if settings.DEBUG:
log.error('Error sending mail: %s' % e)
log.warn('Ignoring email error, since you are running in DEBUG mode. Email was:\nTo:%s\nSubject: %s\n---\n%s', email, subject, body)
else:
log.fatal('Error sending mail: %s' % e)
raise IOError('Could not send email, please check to make sure your email settings are correct, and that you are not being blocked by your ISP.')
示例15: apply_to_order
def apply_to_order(self, order):
"""Apply up to the full amount of the balance of this cert to the order.
Returns new balance.
"""
amount = min(order.balance, self.balance)
log.info('applying %s from giftcert #%i [%s] to order #%i [%s]',
money_format(amount),
self.id,
money_format(self.balance),
order.id,
money_format(order.balance))
config = config_get_group('PAYMENT_GIFTCERTIFICATE')
orderpayment = record_payment(order, config, amount)
return self.use(amount, orderpayment=orderpayment)