本文整理汇总了Python中satchmo.configuration.config_get_group函数的典型用法代码示例。如果您正苦于以下问题:Python config_get_group函数的具体用法?Python config_get_group怎么用?Python config_get_group使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_get_group函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:davemerwin,项目名称:satchmo,代码行数:57,代码来源:views.py
示例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)
开发者ID:vallepu,项目名称:py-bankpassweb,代码行数:31,代码来源:views.py
示例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)
开发者ID:jimmcgaw,项目名称:levicci,代码行数:32,代码来源:views.py
示例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')
开发者ID:juderino,项目名称:jelly-roll,代码行数:7,代码来源:views.py
示例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'))
开发者ID:juderino,项目名称:jelly-roll,代码行数:7,代码来源:views.py
示例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)
开发者ID:juderino,项目名称:jelly-roll,代码行数:33,代码来源:views.py
示例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)
开发者ID:davemerwin,项目名称:satchmo,代码行数:32,代码来源:satchmo_googlecheckout.py
示例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
开发者ID:sankroh,项目名称:satchmo,代码行数:8,代码来源:views.py
示例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))
开发者ID:juderino,项目名称:jelly-roll,代码行数:9,代码来源:shipper.py
示例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()
开发者ID:jimmcgaw,项目名称:levicci,代码行数:9,代码来源:satchmo_checkout.py
示例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)))))
开发者ID:davemerwin,项目名称:satchmo,代码行数:11,代码来源:satchmo_googlecheckout.py
示例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)
开发者ID:yusufbs,项目名称:satchmo,代码行数:54,代码来源:common_contact.py
示例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)
开发者ID:juderino,项目名称:jelly-roll,代码行数:53,代码来源:shipper.py
示例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.')
开发者ID:davemerwin,项目名称:satchmo,代码行数:52,代码来源:views.py
示例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)
开发者ID:juderino,项目名称:jelly-roll,代码行数:15,代码来源:models.py
示例16: confirm_info
def confirm_info(request):
payment_module = config_get_group('PAYMENT_PAYPAL')
if not request.session.get('orderID'):
url = lookup_url(payment_module, 'satchmo_checkout-step1')
return HttpResponseRedirect(url)
if request.session.get('cart'):
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))
order = Order.objects.get(id=request.session['orderID'])
# Check if the order is 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)
template = lookup_template(payment_module, 'checkout/paypal/confirm.html')
if payment_module.LIVE.value:
log.debug("live order on %s", payment_module.KEY.value)
url = payment_module.POST_URL.value
account = payment_module.BUSINESS.value
else:
url = payment_module.POST_TEST_URL.value
account = payment_module.BUSINESS_TEST.value
try:
address = lookup_url(payment_module, payment_module.RETURN_ADDRESS.value, include_server=True)
except urlresolvers.NoReverseMatch:
address = payment_module.RETURN_ADDRESS.value
ctx = RequestContext(request, {'order': order,
'post_url': url,
'business': account,
'currency_code': payment_module.CURRENCY_CODE.value,
'return_address': address,
'PAYMENT_LIVE' : payment_live(payment_module)
})
return render_to_response(template, ctx)
开发者ID:davemerwin,项目名称:satchmo,代码行数:47,代码来源:views.py
示例17: register
def register(request, redirect=None, template='registration/registration_form.html'):
"""
Allows a new user to register an account.
"""
success, todo = register_handle_form(request, redirect=redirect)
if success:
return todo
else:
if config_get_group('NEWSLETTER'):
show_newsletter = True
else:
show_newsletter = False
context = RequestContext(request, {
'form': todo,
'title' : _('Registration Form'),
'show_newsletter' : show_newsletter
})
return render_to_response(template, context)
开发者ID:davemerwin,项目名称:satchmo,代码行数:20,代码来源:views.py
示例18: confirm_info
def confirm_info(request):
"""Shows the user its order details and ask confirmation to send to the real payment function"""
payment_module = config_get_group('PAYMENT_PAYPAL_EXPRESS')
try:
order = Order.objects.from_request(request)
except Order.DoesNotExist:
url = lookup_url(payment_module, 'satchmo_checkout-step1')
return HttpResponseRedirect(url)
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))
# Check if the order is 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)
template = lookup_template(payment_module, 'checkout/paypal_express/confirm.html')
create_pending_payment(order, payment_module)
default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX')
recurring = None
order_items = order.orderitem_set.all()
ctx = RequestContext(request, {'order': order,
'post_url': urlresolvers.reverse("PAYPAL_EXPRESS_satchmo_checkout-step4"),
'default_view_tax': default_view_tax,
'currency_code': payment_module.CURRENCY_CODE.value,
'invoice': order.id,
})
return render_to_response(template, ctx)
开发者ID:Lacrymology,项目名称:satchmo-payflow-pro-express-checkout,代码行数:40,代码来源:views.py
示例19: config_tax
def config_tax():
TAX_MODULE = config_get('TAX', 'MODULE')
TAX_MODULE.add_choice(('satchmo.tax.modules.area', _('By Country/Area')))
TAX_GROUP = config_get_group('TAX')
_tax_classes = []
ship_default = ""
try:
for tax in TaxClass.objects.all():
_tax_classes.append((tax.title, tax))
if "ship" in tax.title.lower():
ship_default = tax.title
except:
log.warn("Ignoring database error retrieving tax classes - OK if you are in syncdb.")
if ship_default == "" and len(_tax_classes) > 0:
ship_default = _tax_classes[0][0]
config_register(
BooleanValue(
TAX_GROUP,
'TAX_SHIPPING',
description=_("Tax Shipping?"),
requires=TAX_MODULE,
requiresvalue='satchmo.tax.modules.area',
default=False
)
)
config_register(
StringValue(
TAX_GROUP,
'TAX_CLASS',
description=_("TaxClass for shipping"),
help_text=_("Select a TaxClass that should be applied for shipments."),
default=ship_default,
choices=_tax_classes
)
)
开发者ID:juderino,项目名称:jelly-roll,代码行数:40,代码来源:config.py
示例20: view
def view(request):
"""View contact info."""
try:
user_data = Contact.objects.get(user=request.user.id)
except Contact.DoesNotExist:
user_data = None
show_newsletter = False
newsletter = False
if config_get_group('NEWSLETTER'):
show_newsletter = True
from satchmo.newsletter import is_subscribed
if user_data:
newsletter = is_subscribed(user_data)
context = RequestContext(request, {
'user_data': user_data,
'show_newsletter' : show_newsletter,
'newsletter' : newsletter })
return render_to_response('contact/view_profile.html', context)
开发者ID:davemerwin,项目名称:satchmo,代码行数:22,代码来源:views.py
注:本文中的satchmo.configuration.config_get_group函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论