本文整理汇总了Python中satchmo.configuration.config_value函数的典型用法代码示例。如果您正苦于以下问题:Python config_value函数的具体用法?Python config_value怎么用?Python config_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_value函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: check_with_akismet
def check_with_akismet(comment=None, request=None, **kwargs):
if config_value("PRODUCT", "AKISMET_ENABLE"):
key = config_value("PRODUCT", "AKISMET_KEY")
if key:
site = Site.objects.get_current()
shop = urlresolvers.reverse('satchmo_shop_home')
from akismet import Akismet
akismet = Akismet(
key=settings.AKISMET_API_KEY,
blog_url='http://%s' % url_join(site.domain, shop))
if akismet.verify_key():
akismet_data = { 'comment_type': 'comment',
'referrer': request.META.get('HTTP_REFERER', ""),
'user_ip': comment.ip_address,
'user_agent': '' }
if akismet_api.comment_check(smart_str(comment.comment), data=akismet_data, build_data=True):
comment.is_public=False
comment.save()
log.info("Akismet marked comment #%i as spam", comment.id)
else:
log.debug("Akismet accepted comment #%i", comment.id)
else:
log.warn("Akismet key '%s' not accepted by akismet service.", key)
else:
log.info("Akismet enabled, but no key found. Please put in your admin settings.")
开发者ID:jimmcgaw,项目名称:levicci,代码行数:25,代码来源:listeners.py
示例2: process
def process(self, order=None):
"""
Calculate the tax and return it
"""
if order:
self.order = order
else:
order = self.order
percent = config_value("TAX", "PERCENT")
sub_total = Decimal("0.00")
for item in order.orderitem_set.filter(product__taxable=True):
sub_total += item.sub_total
itemtax = sub_total * (percent / 100)
taxrates = {"%i%%" % percent: itemtax}
if config_value("TAX", "TAX_SHIPPING"):
shipping = order.shipping_sub_total
sub_total += shipping
ship_tax = shipping * (percent / 100)
taxrates["Shipping"] = ship_tax
tax = sub_total * (percent / 100)
return tax, taxrates
开发者ID:sankroh,项目名称:satchmo,代码行数:26,代码来源:tax.py
示例3: order_payload
def order_payload(order):
data = {}
data["api_key"] = config_value("satchmo.fulfilment.modules.six", "API_KEY")
data["test"] = config_value("satchmo.fulfilment.modules.six", "TEST_MODE")
data["allow_preorder"] = config_value("satchmo.fulfilment.modules.six", "ALLOW_PREORDER")
data["update_stock"] = config_value("satchmo.fulfilment.modules.six", "UPDATE_STOCK")
data["order"] = {}
despatch_url = external_url(reverse("six_despatch", kwargs={"order_id": order.id, "verification_hash": order.verification_hash}))
data["order"]["client_ref"] = order.id
data["order"]["po_number"] = order.id
data["order"]["date_placed"] = unicode(order.time_stamp)
data["order"]["callback_url"] = despatch_url
data["order"]["postage_speed"] = order.shipping_postage_speed
data["order"]["postage_cost"] = float_price(order.shipping_cost)
data["order"]["total_amount"] = float_price(order.sub_total)
data["order"]["signed_for"] = order.shipping_signed_for
data["order"]["tracked"] = order.shipping_tracked
data["order"]["ShippingContact"] = {
"dear": order.contact.user.first_name,
"name": order.ship_addressee,
"email": order.contact.user.email,
"phone": get_phone_number(order),
"address": order.ship_street1,
"address_contd": order.ship_street2,
"city": order.ship_city,
"county": order.ship_state,
"country": unicode(order.ship_country),
"postcode": order.ship_postal_code,
}
data["order"]["BillingContact"] = {
"name": order.bill_addressee,
"email": order.contact.user.email,
"phone": get_phone_number(order),
"address": order.bill_street1,
"address_contd": order.bill_street2,
"city": order.bill_city,
"county": order.bill_state,
"country": unicode(order.bill_country),
"postcode": order.bill_postal_code,
}
data["order"]["items"] = [
{
# Six limits slugs to 40 characters. Six stores
# client_refs with a length of 40 characters (truncated
# silently). When passing a > 40 character slug, the
# whole slug is checked against the 40 character
# client_ref and doesn't match. So, we just truncate
# slugs to 40 characters.
"client_ref": item.product.slug[:40],
"quantity": item.quantity,
"price": float_price(item.unit_price),
}
for item in order.orderitem_set.all()
]
return json.dumps(data)
开发者ID:juderino,项目名称:jelly-roll,代码行数:59,代码来源:api.py
示例4: make_urlpatterns
def make_urlpatterns():
patterns = []
for key in config_value('PAYMENT', 'MODULES'):
cfg = config_get(key, 'MODULE')
modulename = cfg.editor_value
urlmodule = "%s.urls" % modulename
patterns.append(url(config_value(key, 'URL_BASE'), [urlmodule, modulename, '']))
return tuple(patterns)
开发者ID:juderino,项目名称:jelly-roll,代码行数:8,代码来源:urls.py
示例5: test_custom_product
def test_custom_product(self):
"""
Verify that the custom product is working as expected.
"""
pm = config_get("PRODUCT", "PRODUCT_TYPES")
pm.update(
[
"product::ConfigurableProduct",
"product::ProductVariation",
"product::CustomProduct",
"product::SubscriptionProduct",
]
)
response = self.client.get(prefix + "/")
self.assertContains(response, "Computer", count=1)
response = self.client.get(prefix + "/product/satchmo-computer/")
self.assertContains(response, "Memory", count=1)
self.assertContains(response, "Case", count=1)
self.assertContains(response, "Monogram", count=1)
response = self.client.post(
prefix + "/cart/add/",
{"productname": "satchmo-computer", "5": "1.5gb", "6": "mid", "custom_monogram": "CBM", "quantity": 1},
)
self.assertRedirects(response, prefix + "/cart/", status_code=302, target_status_code=200)
response = self.client.get(prefix + "/cart/")
self.assertContains(response, '/satchmo-computer/">satchmo computer', count=1, status_code=200)
self.assertContains(response, smart_str("%s168.00" % config_value("SHOP", "CURRENCY")), count=3)
self.assertContains(response, smart_str("Monogram: CBM %s10.00" % config_value("SHOP", "CURRENCY")), count=1)
self.assertContains(
response, smart_str("Case - External Case: Mid %s10.00" % config_value("SHOP", "CURRENCY")), count=1
)
self.assertContains(
response, smart_str("Memory - Internal RAM: 1.5 GB %s25.00" % config_value("SHOP", "CURRENCY")), count=1
)
response = self.client.post(url("satchmo_checkout-step1"), get_step1_post_data(self.US))
self.assertRedirects(response, url("DUMMY_satchmo_checkout-step2"), status_code=302, target_status_code=200)
data = {
"credit_type": "Visa",
"credit_number": "4485079141095836",
"month_expires": "1",
"year_expires": "2012",
"ccv": "552",
"shipping": "FlatRate",
}
response = self.client.post(url("DUMMY_satchmo_checkout-step2"), data)
self.assertRedirects(response, url("DUMMY_satchmo_checkout-step3"), status_code=302, target_status_code=200)
response = self.client.get(url("DUMMY_satchmo_checkout-step3"))
self.assertContains(
response,
smart_str("satchmo computer - %s168.00" % config_value("SHOP", "CURRENCY")),
count=1,
status_code=200,
)
response = self.client.post(url("DUMMY_satchmo_checkout-step3"), {"process": "True"})
self.assertRedirects(response, url("DUMMY_satchmo_checkout-success"), status_code=302, target_status_code=200)
self.assertEqual(len(mail.outbox), 1)
开发者ID:sankroh,项目名称:satchmo,代码行数:57,代码来源:tests.py
示例6: process
def process(self):
"""
Calculate the tax and return it
"""
subtotal = self.order.sub_total - self.order.discount
if config_value('TAX','TAX_SHIPPING'):
subtotal += self.order.shipping_cost
percent = config_value('TAX','PERCENT')
return subtotal * (percent/100)
开发者ID:davemerwin,项目名称:satchmo,代码行数:11,代码来源:tax.py
示例7: test_checkout
def test_checkout(self):
"""
Run through a full checkout process
"""
cache_delete()
tax = config_get("TAX", "MODULE")
tax.update("satchmo.tax.modules.percent")
pcnt = config_get("TAX", "PERCENT")
pcnt.update("10")
shp = config_get("TAX", "TAX_SHIPPING")
shp.update(False)
self.test_cart_adding()
response = self.client.post(url("satchmo_checkout-step1"), get_step1_post_data(self.US))
self.assertRedirects(response, url("DUMMY_satchmo_checkout-step2"), status_code=302, target_status_code=200)
data = {
"credit_type": "Visa",
"credit_number": "4485079141095836",
"month_expires": "1",
"year_expires": "2009",
"ccv": "552",
"shipping": "FlatRate",
}
response = self.client.post(url("DUMMY_satchmo_checkout-step2"), data)
self.assertRedirects(response, url("DUMMY_satchmo_checkout-step3"), status_code=302, target_status_code=200)
response = self.client.get(url("DUMMY_satchmo_checkout-step3"))
self.assertContains(
response, smart_str("Shipping + %s4.00" % config_value("SHOP", "CURRENCY")), count=1, status_code=200
)
self.assertContains(
response, smart_str("Tax + %s4.60" % config_value("SHOP", "CURRENCY")), count=1, status_code=200
)
self.assertContains(
response, smart_str("Total = %s54.60" % config_value("SHOP", "CURRENCY")), count=1, status_code=200
)
response = self.client.post(url("DUMMY_satchmo_checkout-step3"), {"process": "True"})
self.assertRedirects(response, url("DUMMY_satchmo_checkout-success"), status_code=302, target_status_code=200)
self.assertEqual(len(mail.outbox), 1)
# Log in as a superuser
user = User.objects.create_user("fredsu", "[email protected]", "passwd")
user.is_staff = True
user.is_superuser = True
user.save()
self.client.login(username="fredsu", password="passwd")
# Test pdf generation
response = self.client.get("/admin/print/invoice/1/")
self.assertContains(response, "reportlab", status_code=200)
response = self.client.get("/admin/print/packingslip/1/")
self.assertContains(response, "reportlab", status_code=200)
response = self.client.get("/admin/print/shippinglabel/1/")
self.assertContains(response, "reportlab", status_code=200)
开发者ID:sankroh,项目名称:satchmo,代码行数:53,代码来源:tests.py
示例8: display_featured
def display_featured():
"""
Used by the index generic view to choose how the featured products are displayed.
Items can be displayed randomly or all in order
"""
random_display = config_value('SHOP','RANDOM_FEATURED')
num_to_display = config_value('SHOP','NUM_DISPLAY')
q = Product.objects.featured_by_site()
if not random_display:
return q[:num_to_display]
else:
return q.order_by('?')[:num_to_display]
开发者ID:jimmcgaw,项目名称:levicci,代码行数:12,代码来源:views.py
示例9: _get_shipping_choices
def _get_shipping_choices(request, paymentmodule, cart, contact, default_view_tax=False):
"""Iterate through legal shipping modules, building the list for display to the user.
Returns the shipping choices list, along with a dictionary of shipping choices, useful
for building javascript that operates on shipping choices.
"""
shipping_options = []
shipping_dict = {}
if not cart.is_shippable:
methods = [shipping_method_by_key('NoShipping'), ]
else:
methods = shipping_methods()
valid_methods = []
for method in methods:
method.calculate(cart, contact)
if method.valid():
valid_methods.append((method, method.cost()))
# sort methods by cost
valid_methods.sort(key=lambda method_cost: int(method_cost[1]))
for method, shipcost in valid_methods:
template = lookup_template(paymentmodule, 'shipping_options.html')
t = loader.get_template(template)
shipping_tax = None
taxed_shipping_price = None
if config_value('TAX', 'TAX_SHIPPING'):
shipping_tax = config_value('TAX', 'TAX_CLASS')
taxer = _get_taxprocessor(request)
total = shipcost + taxer.by_price(shipping_tax, shipcost)
taxed_shipping_price = money_format(total)
data = {
'amount': shipcost,
'description': method.description(),
'method': method.method(),
'expected_delivery': method.expectedDelivery(),
'default_view_tax': default_view_tax,
'shipping_tax': shipping_tax,
'taxed_shipping_price': taxed_shipping_price
}
if hasattr(method, 'shipping_discount'):
data['discount'] = method.shipping_discount()
c = RequestContext(request, data)
shipping_options.append((method.id, t.render(c)))
shipping_dict[method.id] = shipcost
return shipping_options, shipping_dict
开发者ID:juderino,项目名称:jelly-roll,代码行数:52,代码来源:forms.py
示例10: shipping
def shipping(self, subtotal=None):
if subtotal is None and self.order:
subtotal = self.order.shipping_sub_total
if subtotal:
subtotal = self.order.shipping_sub_total
if config_value("TAX", "TAX_SHIPPING"):
percent = config_value("TAX", "PERCENT")
t = subtotal * (percent / 100)
else:
t = Decimal("0.00")
else:
t = Decimal("0.00")
return t
开发者ID:sankroh,项目名称:satchmo,代码行数:15,代码来源:tax.py
示例11: get_newsletter_module
def get_newsletter_module():
try:
modulename = config_value("NEWSLETTER", "MODULE")
except AttributeError:
modulename = "satchmo.newsletter.ignore"
return load_module(modulename)
开发者ID:sankroh,项目名称:satchmo,代码行数:7,代码来源:__init__.py
示例12: home
def home(request, template="base_index.html"):
# Display the category, its child categories, and its products.
if request.method == "GET":
currpage = request.GET.get('page', 1)
else:
currpage = 1
featured = display_featured()
count = config_value('SHOP','NUM_PAGINATED')
paginator = Paginator(featured, count)
is_paged = False
page = None
try:
paginator.validate_number(currpage)
except EmptyPage:
return bad_or_missing(request, _("Invalid page number"))
is_paged = paginator.num_pages > 1
page = paginator.page(currpage)
ctx = RequestContext(request, {
'all_products_list' : page.object_list,
'is_paginated' : is_paged,
'page_obj' : page,
'paginator' : paginator
})
return render_to_response(template, ctx)
开发者ID:jimmcgaw,项目名称:levicci,代码行数:33,代码来源:home.py
示例13: cartitem_total
def cartitem_total(parser, token):
"""Returns the line total for the cartitem, possibly with tax added. If currency evaluates true,
then return the total formatted through money_format.
Example::
{% cartitem_total cartitem [show_tax] [currency] %}
"""
tokens = token.contents.split()
if len(tokens) < 2:
raise template.TemplateSyntaxError, "'%s' tag requires a cartitem argument" % tokens[0]
cartitem = tokens[1]
if len(tokens) > 2:
show_tax = tokens[2]
else:
show_tax = config_value('TAX', 'DEFAULT_VIEW_TAX')
if len(tokens) >3:
show_currency = tokens[3]
else:
show_currency = 'True'
return CartitemTotalNode(cartitem, show_currency, show_tax)
开发者ID:juderino,项目名称:jelly-roll,代码行数:26,代码来源:satchmo_cart.py
示例14: displayDoc
def displayDoc(request, id, doc):
# Create the HttpResponse object with the appropriate PDF headers for an invoice or a packing slip
order = get_object_or_404(Order, pk=id)
shopDetails = Config.objects.get_current()
filename_prefix = shopDetails.site.domain
if doc == "invoice":
filename = "%s-invoice.pdf" % filename_prefix
template = "invoice.rml"
elif doc == "packingslip":
filename = "%s-packingslip.pdf" % filename_prefix
template = "packing-slip.rml"
elif doc == "shippinglabel":
filename = "%s-shippinglabel.pdf" % filename_prefix
template = "shipping-label.rml"
else:
return HttpResponseRedirect('/admin')
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=%s' % filename
icon_uri = config_value('SHOP', 'LOGO_URI')
t = loader.get_template(os.path.join('pdf', template))
c = Context({
'filename' : filename,
'iconURI' : icon_uri,
'shopDetails' : shopDetails,
'order' : order,
})
pdf = trml2pdf.parseString(smart_str(t.render(c)))
response.write(pdf)
return response
开发者ID:jimmcgaw,项目名称:levicci,代码行数:29,代码来源:views.py
示例15: __init__
def __init__(self, request, payment_module):
self.request = request
self.paymentModule = payment_module
processor_module = payment_module.MODULE.load_module('processor')
self.processor = processor_module.PaymentProcessor(self.paymentModule)
self.viewTax = config_value('TAX', 'DEFAULT_VIEW_TAX')
self.order = None
self.cart = None
self.extra_context = {}
#to override the form_handler, set this
#otherwise it will use the built-in `_onForm`
self.onForm = self._onForm
#to override the success method, set this
#othewise it will use the built-in `_onSuccess`
self.onSuccess = self._onSuccess
#false on any "can not continue" error
self.valid = False
#the value to be returned from the view
#an HttpResponse or a HttpRedirect
self.response = None
self.processorMessage = ""
self.processorReasonCode = ""
self.processorResults = None
self.templates = {
'CONFIRM' : 'checkout/confirm.html',
'EMPTY_CART': 'checkout/empty_cart',
'404': 'shop_404.html',
}
开发者ID:jimmcgaw,项目名称:levicci,代码行数:34,代码来源:confirm.py
示例16: activate
def activate(request, activation_key):
"""
Activates a user's account, if their key is valid and hasn't
expired.
"""
from registration.models import RegistrationProfile
activation_key = activation_key.lower()
account = RegistrationProfile.objects.activate_user(activation_key)
if account:
# ** hack for logging in the user **
# when the login form is posted, user = authenticate(username=data['username'], password=data['password'])
# ...but we cannot authenticate without password... so we work-around authentication
account.backend = settings.AUTHENTICATION_BACKENDS[0]
login(request, account)
contact = Contact.objects.get(user=account)
request.session['custID'] = contact.id
send_welcome_email(contact.email, contact.first_name, contact.last_name)
context = RequestContext(request, {
'account': account,
'expiration_days': config_value('SHOP', 'ACCOUNT_ACTIVATION_DAYS'),
})
return render_to_response('registration/activate.html', context)
开发者ID:davemerwin,项目名称:satchmo,代码行数:27,代码来源:views.py
示例17: testBalanceMethods
def testBalanceMethods(self):
order = make_test_order(self.US, "", include_non_taxed=True)
order.recalculate_total(save=False)
price = order.total
subtotal = order.sub_total
self.assertEqual(subtotal, Decimal("105.00"))
self.assertEqual(price, Decimal("115.00"))
self.assertEqual(order.balance, price)
paytype = config_value("PAYMENT", "MODULES")[0]
pmt = OrderPayment(order=order, payment=paytype, amount=Decimal("5.00"))
pmt.save()
self.assertEqual(order.balance, Decimal("110.00"))
self.assertEqual(order.balance_paid, Decimal("5.00"))
self.assert_(order.is_partially_paid)
pmt = OrderPayment(order=order, payment=paytype, amount=Decimal("110.00"))
pmt.save()
self.assertEqual(order.balance, Decimal("0.00"))
self.assertEqual(order.is_partially_paid, False)
self.assert_(order.paid_in_full)
开发者ID:sankroh,项目名称:satchmo,代码行数:25,代码来源:tests.py
示例18: get_newsletter_module
def get_newsletter_module():
try:
modulename = config_value('NEWSLETTER', 'MODULE')
except AttributeError:
modulename = 'satchmo.newsletter.ignore'
return load_module(modulename)
开发者ID:davemerwin,项目名称:satchmo,代码行数:7,代码来源:__init__.py
示例19: __init__
def __init__(self, request, paymentmodule, *args, **kwargs):
super(SimplePayShipForm, self).__init__(*args, **kwargs)
self.order = None
self.orderpayment = None
try:
self.tempCart = Cart.objects.from_request(request)
if self.tempCart.numItems > 0:
products = [item.product for item in self.tempCart.cartitem_set.all()]
sale = find_best_auto_discount(products)
if sale:
self.fields['discount'].initial = sale.code
except Cart.DoesNotExist:
self.tempCart = None
try:
self.tempContact = Contact.objects.from_request(request)
except Contact.DoesNotExist:
self.tempContact = None
if 'default_view_tax' in kwargs:
default_view_tax = kwargs['default_view_tax']
else:
default_view_tax = config_value('TAX', 'TAX_SHIPPING')
shipping_choices, shipping_dict = _get_shipping_choices(request, paymentmodule, self.tempCart, self.tempContact, default_view_tax=default_view_tax)
self.fields['shipping'].choices = shipping_choices
self.shipping_dict = shipping_dict
signals.payment_form_init.send(SimplePayShipForm, form=self)
开发者ID:juderino,项目名称:jelly-roll,代码行数:32,代码来源:forms.py
示例20: testCronRebill
def testCronRebill(self):
for order in OrderItem.objects.all():
price, expire_length = self.getTerms(order.product)
if price is None:
continue
self.assertEqual(order.expire_date, datetime.date.today() + datetime.timedelta(days=expire_length))
#set expire date to today for upcoming cron test
order.expire_date = datetime.date.today()
order.save()
order_count = OrderItem.objects.count()
self.c = Client()
self.response = self.c.get(prefix+'/checkout/cron/')
self.assertEqual(self.response.status_code, 200)
self.assertEqual(self.response.content, 'Authentication Key Required')
from django.conf import settings
self.response = self.c.get(prefix+'/checkout/cron/', data={'key': config_value('PAYMENT','CRON_KEY')})
self.assertEqual(self.response.status_code, 200)
self.assertEqual(self.response.content, '')
self.assert_(order_count < OrderItem.objects.count())
self.assertEqual(order_count, OrderItem.objects.count()/2.0)
for order in OrderItem.objects.filter(expire_date__gt=datetime.datetime.now()):
price, expire_length = self.getTerms(order.product, ignore_trial=True)
if price is None:
continue
self.assertEqual(order.expire_date, datetime.date.today() + datetime.timedelta(days=expire_length))
self.assertEqual(order.order.balance, Decimal('0.00'))
开发者ID:jimmcgaw,项目名称:levicci,代码行数:27,代码来源:tests.py
注:本文中的satchmo.configuration.config_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论