def settings(request): shop_config = Config.objects.get_current() cart = Cart.objects.from_request(request) all_categories = Category.objects.by_site() today = datetime.date.today() discs = Discount.objects.filter(automatic=True, active=True, startDate__lte=today, endDate__gt=today).order_by('-percentage') if discs.count() > 0: sale = discs[0] else: sale = None ctx = { 'shop_base': get_satchmo_setting('SHOP_BASE'), 'shop' : shop_config, 'shop_name': shop_config.store_name, 'media_url': current_media_url(request), 'cart_count': cart.numItems, 'cart': cart, 'categories': all_categories, 'is_secure' : request_is_secure(request), 'request' : request, 'login_url': site_settings.LOGIN_URL, 'logout_url': site_settings.LOGOUT_URL, 'sale': sale } satchmo_context.send(shop_config, context=ctx) return ctx
def settings(request): shop_config = Config.objects.get_current() cart = Cart.objects.from_request(request) all_categories = Category.objects.by_site() try: sale = Discount.objects.get_sale() except Discount.DoesNotExist: sale = None ctx = { 'shop_base': get_satchmo_setting('SHOP_BASE'), 'shop' : shop_config, 'shop_name': shop_config.store_name, 'media_url': current_media_url(request), 'cart_count': cart.numItems, 'cart': cart, 'categories': all_categories, 'is_secure' : request_is_secure(request), 'request' : request, 'login_url': site_settings.LOGIN_URL, 'logout_url': site_settings.LOGOUT_URL, 'storewide_sale': sale } satchmo_context.send(shop_config, context=ctx) return ctx
def settings(request): shop_config = Config.objects.get_current() cart = Cart.objects.from_request(request) all_categories = Category.objects.by_site() try: sale = Discount.objects.get_sale() except Discount.DoesNotExist: sale = None ctx = { 'shop_base': get_satchmo_setting('SHOP_BASE'), 'shop': shop_config, 'shop_name': shop_config.store_name, 'media_url': current_media_url(request), 'cart_count': cart.numItems, 'cart': cart, 'categories': all_categories, 'is_secure': request_is_secure(request), 'request': request, 'login_url': site_settings.LOGIN_URL, 'logout_url': site_settings.LOGOUT_URL, 'storewide_sale': sale } satchmo_context.send(shop_config, context=ctx) return ctx
def settings(request): shop_config = Config.objects.get_current() cart = Cart.objects.from_request(request) all_categories = Category.objects.by_site() try: sale = Discount.objects.get_sale() except Discount.DoesNotExist: sale = None ctx = { "shop_base": get_satchmo_setting("SHOP_BASE"), "shop": shop_config, "shop_name": shop_config.store_name, "media_url": current_media_url(request), "cart_count": cart.numItems, "cart": cart, "categories": all_categories, "is_secure": request_is_secure(request), "request": request, "login_url": site_settings.LOGIN_URL, "logout_url": site_settings.LOGOUT_URL, "sale": sale, } satchmo_context.send(shop_config, context=ctx) return ctx
def customorder_management(order): custom = [] for orderitem in order.orderitem_set.all(): if 'CustomProduct' in orderitem.product.get_subtypes(): custom.append(orderitem) return { 'SHOP_BASE': get_satchmo_setting('SHOP_BASE'), 'customitems': custom }
def customorder_management(order): custom = [] for orderitem in order.orderitem_set.all(): if 'CustomProduct' in orderitem.product.get_subtypes(): custom.append(orderitem) return { 'SHOP_BASE' : get_satchmo_setting('SHOP_BASE'), 'customitems' : custom }
def satchmo_main(): base = get_satchmo_setting('SHOP_BASE') rv = urlresolvers.reverse urls = ( (base + '/', 1.0, 'hourly'), (rv('satchmo_contact'), 1.0, 'monthly'), (rv('satchmo_cart'), 0.5, 'monthly'), (rv('auth_login'), 0.8, 'monthly'), (rv('registration_register'), 0.8, 'monthly'), (rv('auth_password_reset'), 0.8, 'monthly'), ) sitemap = MainSitemap() for url in urls: sitemap.add_url(*url) return sitemap
def settings(request): # We only insert Satchmo context if we are in the shop subpages to # avoid unnecessary db queries try: url_name = request.resolver_match.url_name if not url_name or 'satchmo' not in url_name: return {} except AttributeError: return {} shop_config = Config.objects.get_current() cart = Cart.objects.from_request(request) all_categories = Category.objects.by_site() # We don't care about the store-wide sale, commented out to hide extra # SQL queries # try: # sale = Discount.objects.get_sale() # except Discount.DoesNotExist: # sale = None sale = None ctx = { 'shop_base': get_satchmo_setting('SHOP_BASE'), 'shop': shop_config, 'shop_name': shop_config.store_name, 'media_url': current_media_url(request), 'STATIC_URL': current_static_url(request), 'cart_count': cart.numItems, 'cart': cart, 'categories': all_categories, 'is_secure': request_is_secure(request), 'request': request, 'login_url': site_settings.LOGIN_URL, 'logout_url': site_settings.LOGOUT_URL, 'storewide_sale': sale } # the signal can by used to dynamically customize context variables satchmo_context.send(shop_config, context=ctx) return ctx
from django.conf.urls import patterns, include from django.views.generic.base import TemplateView from product.urls import urlpatterns as productpatterns from satchmo_store import shop from satchmo_store.shop.views.sitemaps import sitemaps from satchmo_utils.signals import collect_urls urlpatterns = shop.get_satchmo_setting('SHOP_URLS') urlpatterns += patterns( 'satchmo_store.shop.views', (r'^$', 'home.home', {}, 'satchmo_shop_home'), (r'^add/$', 'smart.smart_add', {}, 'satchmo_smart_add'), (r'^cart/$', 'cart.display', {}, 'satchmo_cart'), (r'^cart/accept/$', 'cart.agree_terms', {}, 'satchmo_cart_accept_terms'), (r'^cart/add/$', 'cart.add', {}, 'satchmo_cart_add'), (r'^cart/add/ajax/$', 'cart.add_ajax', {}, 'satchmo_cart_add_ajax'), (r'^cart/qty/$', 'cart.set_quantity', {}, 'satchmo_cart_set_qty'), (r'^cart/qty/ajax/$', 'cart.set_quantity_ajax', {}, 'satchmo_cart_set_qty_ajax'), (r'^cart/remove/$', 'cart.remove', {}, 'satchmo_cart_remove'), (r'^cart/remove/ajax/$', 'cart.remove_ajax', {}, 'satchmo_cart_remove_ajax'), (r'^checkout/', include('payment.urls')), (r'^contact/$', 'contact.form', {}, 'satchmo_contact'), (r'^history/$', 'orders.order_history', {}, 'satchmo_order_history'), (r'^quickorder/$', 'cart.add_multiple', {}, 'satchmo_quick_order'), (r'^tracking/(?P<order_id>\d+)/$', 'orders.order_tracking', {}, 'satchmo_order_tracking'), (r'^search/$', 'search.search_view', {}, 'satchmo_search'), )
from livesettings import config_get, config_value from product.models import Product from product.utils import rebuild_pricing from satchmo_store.contact import CUSTOMER_ID from satchmo_store.contact.models import Contact, AddressBook from satchmo_store.shop import get_satchmo_setting, signals from satchmo_store.shop.exceptions import CartAddProhibited from satchmo_store.shop.models import * from satchmo_utils.templatetags import get_filter_args from threaded_multihost.threadlocals import get_current_request import keyedcache import datetime domain = "http://example.com" prefix = get_satchmo_setting("SHOP_BASE") if prefix == "/": prefix = "" def get_step1_post_data(US): return { "email": "*****@*****.**", "first_name": "Teddy", "last_name": "Tester", "phone": "456-123-5555", "street1": "8299 Some Street", "city": "Springfield", "state": "MO", "postal_code": "81122", "country": US.pk,
help_text=_("If yes, then all products and the cart will display with tax included."), default=False )) PRODUCTS_TAXABLE_BY_DEFAULT = config_register(BooleanValue(TAX_GROUP, 'PRODUCTS_TAXABLE_BY_DEFAULT', description=_("New products are automatically made taxable"), help_text=_("Whether newly created products should be taxable by default."), default=False )) TAX_AREA_ADDRESS = config_register( StringValue(TAX_GROUP, 'TAX_AREA_ADDRESS', description=_("Should tax be calculated based on shipping or billing address?"), help_text=_("This will only be used if tax is calculated based on an address."), choices = ( (('ship', 'Shipping')), (('bill', 'Billing')), ), default = 'ship') ) # --- Load any extra tax modules. --- extra_tax = get_satchmo_setting('CUSTOM_TAX_MODULES') for extra in extra_tax: try: load_module("%s.config" % extra) except ImportError: log.warn('Could not load tax module configuration: %s' % extra)
earlier in your custom urls.py file, and you want the shop at "store/":: # at the top of the file from satchmo_store.urls import basepatterns [ ... your code here, which includes admin.autodiscover() ... ] urlpatterns += basepatterns + patterns('', (r'^store/', include('satchmo_store.shop.urls')), ) """ from base import urlpatterns as basepatterns from default import urlpatterns as defaultpatterns from django.conf.urls.defaults import patterns, include from l10n.urls import urlpatterns as l10npatterns from satchmo_store.shop import get_satchmo_setting from satchmo_utils import urlhelper shop_base = get_satchmo_setting("SHOP_BASE") if shop_base in ("", "/"): from satchmo_store.shop.urls import urlpatterns as shoppatterns else: shopregex = "^" + shop_base[1:] + "/" shoppatterns = patterns("", (shopregex, include("satchmo_store.shop.urls"))) urlpatterns = basepatterns + shoppatterns + defaultpatterns + l10npatterns urlhelper.remove_duplicate_urls(urlpatterns, [])
description=_("Use discounts"), help_text=_("""If disabled, customers will not be asked for any discount codes."""), default=True) ) # --- Load default payment modules. Ignore import errors, user may have deleted them. --- _default_modules = ('authorizenet','dummy','google','paypal', 'trustcommerce', 'cybersource', 'autosuccess', 'cod', 'protx', 'sermepa') for module in _default_modules: try: load_module("payment.modules.%s.config" % module) except ImportError: log.debug('Could not load default payment module configuration: %s', module) # --- Load any extra payment modules. --- extra_payment = get_satchmo_setting('CUSTOM_PAYMENT_MODULES') for extra in extra_payment: try: load_module("%s.config" % extra) except ImportError: log.warn('Could not load payment module configuration: %s' % extra) # --- helper functions --- def active_modules(): """Get a list of activated payment modules, in the form of [(key), (config group),...] """ return [(module, config_get_group(module)) for module in config_value('PAYMENT', 'MODULES')]
default="satchmo_ext.newsletter.simple", choices=[('satchmo_ext.newsletter.ignore', _('No newsletter')), ('satchmo_ext.newsletter.simple', _('Simple list')), ('satchmo_ext.newsletter.mailman', _('Mailman'))] )) config_register(StringValue(NEWSLETTER_GROUP, 'NEWSLETTER_NAME', description=_("Name of Newsletter"), help_text=_("""Give the exact name that matches the mailing list set up in Mailman."""), requires=NEWSLETTER_ACTIVE, requiresvalue='satchmo_ext.newsletter.mailman', default="" )) config_register( StringValue(NEWSLETTER_GROUP, 'NEWSLETTER_SLUG', description=_('Newsletter Slug'), help_text=_("The url slug for the newsletter. Requires server restart if changed."), default="newsletter")) # --- Load any extra newsletter modules. --- extra_payment = get_satchmo_setting('CUSTOM_NEWSLETTER_MODULES') for extra in extra_payment: try: load_module("%s.config" % extra) except ImportError: log.warn('Could not load payment module configuration: %s' % extra)
# --- Load default shipping modules. Ignore import errors, user may have deleted them. --- # DO NOT ADD 'tiered' or 'no' to this list. # 'no' is used internally # 'Tiered' is special, since it needs to be added as a module. To enable it, # just add shipping.modules.tiered to your INSTALLED_APPS _default_modules = ("canadapost", "dummy", "fedex_web_services", "flat", "per", "ups", "usps") for module in _default_modules: try: load_module("shipping.modules.%s.config" % module) except ImportError: log.debug("Could not load default shipping module configuration: %s", module) # --- Load any extra shipping modules. --- extra_shipping = get_satchmo_setting("CUSTOM_SHIPPING_MODULES") for extra in extra_shipping: try: load_module("%s.config" % extra) except ImportError: log.warn("Could not load shipping module configuration: %s" % extra) class ShippingModuleNotFound(Exception): def __init__(self, key): self.key = key def shipping_methods(): methods = []
def orderpayment_list(order): return { 'SHOP_BASE' : get_satchmo_setting('SHOP_BASE'), 'order' : order, 'payments' : order.payments.all() }
from django.conf.urls.defaults import patterns, url, include from satchmo_store.shop import get_satchmo_setting pages = r'^' + get_satchmo_setting('PAGE_SLUG') + '/' urlpatterns = patterns('', url(r'^cart/empty/$', 'satchmoutils.views.cart_empty', {}, 'satchmo_cart_empty'), url(r"^test_confirm_ipn/", 'satchmoutils.test_views.test_confirm_ipn', {}, 'test_confirm_ipn'), url(pages + '(?P<slug>[-\w]+)/$', 'satchmoutils.views.get_static_page', {}, 'page_url'), url(r'^contact/$', 'satchmoutils.views.contact_form', {}, 'satchmo_contact'), url(r"^captcha/", include('captcha.urls')))
# DO NOT ADD 'tiered' or 'no' to this list. # 'no' is used internally # 'Tiered' is special, since it needs to be added as a module. To enable it, # just add shipping.modules.tiered to your INSTALLED_APPS _default_modules = ('canadapost', 'dummy', 'fedex_web_services', 'flat', 'per', 'ups', 'usps') for module in _default_modules: try: load_module("shipping.modules.%s.config" % module) except ImportError: log.debug('Could not load default shipping module configuration: %s', module) # --- Load any extra shipping modules. --- extra_shipping = get_satchmo_setting('CUSTOM_SHIPPING_MODULES') for extra in extra_shipping: try: load_module("%s.config" % extra) except ImportError: log.warn('Could not load shipping module configuration: %s' % extra) class ShippingModuleNotFound(Exception): def __init__(self, key): self.key = key def shipping_methods(): methods = []
from django.conf.urls.defaults import patterns, url, include from satchmo_store.shop import get_satchmo_setting pages = r'^' + get_satchmo_setting('PAGE_SLUG') + '/' categories = r'^' + get_satchmo_setting('CATEGORY_SLUG') + '/' urlpatterns = patterns( '', url(r'^ajax_select/ajax_lookup/(?P<channel>[-\w]+)$', 'primifrutti.shop.views.ajax_lookup', name='ajax_lookup'), url(r'^$', 'primifrutti.shop.views.splash', name='satchmo_shop_splash'), url(r'^home/$', 'primifrutti.shop.views.home', name='satchmo_home'), url(r'^checkout/$', 'primifrutti.shop.views.checkout_chek_zones', name='satchmo_checkout-step1'), url(r'^checkout_nozones/$', 'primifrutti.shop.views.checkout_nozones', name='satchmo_checkout-nozones'), url(r'^search/$', 'primifrutti.shop.views.search_view', {}, 'satchmo_search'), url(pages + 'offerte/$', 'primifrutti.shop.views.offers', name='satchmo_offers'), url(categories + '$', 'primifrutti.shop.views.category_index', name='satchmo_category_index'), url(categories + '(?P<parent_slugs>([-\w]+/)*)?(?P<slug>[-\w]+)/$', 'primifrutti.shop.views.category_view', name='satchmo_category'), url(r'^sitemap$', 'primifrutti.shop.views.pf_sitemap', name='pf_sitemap'),
from django.conf.urls.defaults import patterns, url, include from satchmo_store.shop import get_satchmo_setting pages = r'^' + get_satchmo_setting('PAGE_SLUG') + '/' categories = r'^' + get_satchmo_setting('CATEGORY_SLUG') + '/' urlpatterns = patterns( '', url( r'^ajax_select/ajax_lookup/(?P<channel>[-\w]+)$', 'primifrutti.shop.views.ajax_lookup', name='ajax_lookup'), url(r'^$', 'primifrutti.shop.views.splash', name='satchmo_shop_splash'), url(r'^home/$', 'primifrutti.shop.views.home', name='satchmo_home'), url(r'^checkout/$', 'primifrutti.shop.views.checkout_chek_zones', name='satchmo_checkout-step1'), url(r'^checkout_nozones/$', 'primifrutti.shop.views.checkout_nozones', name='satchmo_checkout-nozones'), url(r'^search/$', 'primifrutti.shop.views.search_view', {}, 'satchmo_search'), url(pages + 'offerte/$', 'primifrutti.shop.views.offers', name='satchmo_offers'),
from category import urlpatterns as catpatterns from django.conf.urls.defaults import * from products import urlpatterns as prodpatterns import product from signals_ahoy.signals import collect_urls from satchmo_store.shop import get_satchmo_setting catbase = r'^' + get_satchmo_setting('CATEGORY_SLUG') + '/' prodbase = r'^' + get_satchmo_setting('PRODUCT_SLUG') + '/' urlpatterns = patterns('', (prodbase, include('product.urls.products')), (catbase, include('product.urls.category')), ) collect_urls.send(product, section="__init__", patterns = urlpatterns)
from category import urlpatterns as catpatterns from django.conf.urls import * from products import urlpatterns as prodpatterns import product from signals_ahoy.signals import collect_urls from satchmo_store.shop import get_satchmo_setting catbase = r'^' + get_satchmo_setting('CATEGORY_SLUG') + '/' prodbase = r'^' + get_satchmo_setting('PRODUCT_SLUG') + '/' urlpatterns = patterns('', (prodbase, include('product.urls.products')), (catbase, include('product.urls.category')), ) collect_urls.send(product, section="__init__", patterns = urlpatterns)
from django.conf.urls.defaults import patterns, url, include from satchmo_store.shop import get_satchmo_setting pages = r"^" + get_satchmo_setting("PAGE_SLUG") + "/" urlpatterns = patterns( "", url(r"^cart/empty/$", "satchmoutils.views.cart_empty", {}, "satchmo_cart_empty"), url(r"^test_confirm_ipn/", "satchmoutils.test_views.test_confirm_ipn", {}, "test_confirm_ipn"), url(pages + "(?P<slug>[-\w]+)/$", "satchmoutils.views.get_static_page", {}, "page_url"), url(r"^contact/$", "satchmoutils.views.contact_form", {}, "satchmo_contact"), url(r"^captcha/", include("captcha.urls")), )
# at the top of the file from satchmo_store.urls import basepatterns [ ... your code here, which includes admin.autodiscover() ... ] urlpatterns += basepatterns + patterns('', (r'^store/', include('satchmo_store.shop.urls')), ) """ from base import urlpatterns as basepatterns from default import urlpatterns as defaultpatterns from django.conf.urls.defaults import patterns, include from satchmo_utils import urlhelper from satchmo_store.shop import get_satchmo_setting from satchmo_store.shop.views.sitemaps import sitemaps shop_base = get_satchmo_setting('SHOP_BASE') if shop_base in ('', '/'): from satchmo_store.shop.urls import urlpatterns as shoppatterns else: shopregex = '^' + shop_base[1:] + '/' shoppatterns = patterns('', (shopregex, include('satchmo_store.shop.urls')), ) urlpatterns = basepatterns + shoppatterns + defaultpatterns urlhelper.remove_duplicate_urls(urlpatterns, [])
from django.conf.urls import patterns, include from django.views.generic.base import TemplateView from product.urls import urlpatterns as productpatterns from satchmo_store import shop from satchmo_store.shop.views.sitemaps import sitemaps from satchmo_utils.signals import collect_urls urlpatterns = shop.get_satchmo_setting('SHOP_URLS') urlpatterns += patterns('satchmo_store.shop.views', (r'^$','home.home', {}, 'satchmo_shop_home'), (r'^add/$', 'smart.smart_add', {}, 'satchmo_smart_add'), (r'^cart/$', 'cart.display', {}, 'satchmo_cart'), (r'^cart/accept/$', 'cart.agree_terms', {}, 'satchmo_cart_accept_terms'), (r'^cart/add/$', 'cart.add', {}, 'satchmo_cart_add'), (r'^cart/add/ajax/$', 'cart.add_ajax', {}, 'satchmo_cart_add_ajax'), (r'^cart/qty/$', 'cart.set_quantity', {}, 'satchmo_cart_set_qty'), (r'^cart/qty/ajax/$', 'cart.set_quantity_ajax', {}, 'satchmo_cart_set_qty_ajax'), (r'^cart/remove/$', 'cart.remove', {}, 'satchmo_cart_remove'), (r'^cart/remove/ajax/$', 'cart.remove_ajax', {}, 'satchmo_cart_remove_ajax'), (r'^checkout/', include('payment.urls')), (r'^contact/$', 'contact.form', {}, 'satchmo_contact'), (r'^history/$', 'orders.order_history', {}, 'satchmo_order_history'), (r'^quickorder/$', 'cart.add_multiple', {}, 'satchmo_quick_order'), (r'^tracking/(?P<order_id>\d+)/$', 'orders.order_tracking', {}, 'satchmo_order_tracking'), (r'^search/$', 'search.search_view', {}, 'satchmo_search'), ) # here we add product patterns directly into the root url urlpatterns += productpatterns
def orderpayment_list(order): return { 'SHOP_BASE': get_satchmo_setting('SHOP_BASE'), 'order': order, 'payments': order.payments.all() }
""" Urls for Product Brand module, note that you do not have to add this to your urls file, it will get automatically included by collect_urls. """ from django.conf.urls import * from satchmo_store.shop import get_satchmo_setting import logging log = logging.getLogger('brand.urls') urlpatterns = patterns('satchmo_ext.brand.views', (r'^$', 'brand_list', {}, 'satchmo_brand_list'), (r'^(?P<brandname>.*)/(?P<catname>.*)/$', 'brand_category_page', {}, 'satchmo_brand_category_view'), (r'^(?P<brandname>.*)/$', 'brand_page', {}, 'satchmo_brand_view'), ) brandbase = r'^' + get_satchmo_setting('BRAND_SLUG') + '/' prodbase = r'^' + get_satchmo_setting('PRODUCT_SLUG') + '/' brandpatterns = patterns('', (brandbase, include('satchmo_ext.brand.urls')) ) def add_brand_urls(sender, patterns=(), section="", **kwargs): if section=="__init__": log.debug('adding brand urls at %s', brandbase) patterns += brandpatterns
from product.models import Product from product.modules.downloadable.models import DownloadLink, DownloadableProduct from satchmo_store.contact.models import AddressBook, Contact from satchmo_store.shop.models import Cart, Order from satchmo_store.shop.signals import sendfile_url_for_file from shipping.modules.flat.shipper import Shipper as flat from shipping.modules.per.shipper import Shipper as per from satchmo_store.shop import get_satchmo_setting from decimal import Decimal import keyedcache import os from shutil import rmtree from tempfile import mkdtemp, mkstemp prefix = get_satchmo_setting('SHOP_BASE') if prefix == '/': prefix = '' class DownloadableShippingTest(TestCase): fixtures = ['l10n-data.yaml','test_shop.yaml'] def setUp(self): self.site = Site.objects.get_current() self.product1 = Product.objects.create(slug='p1', name='p1', site=self.site) self.cart1 = Cart.objects.create(site=self.site) self.cartitem1 = self.cart1.add_item(self.product1, 3) def tearDown(self): keyedcache.cache_delete()
help_text=_("Default measurement system to use for products."), choices=[('metric',_('Metric')), ('imperial',_('Imperial'))], default="imperial" ), BooleanValue(PRODUCT_GROUP, 'NO_STOCK_CHECKOUT', description=_("Allow checkout with 0 inventory?"), help_text=_("If yes, then customers can buy even if your inventory is 0 for a product."), default=True ), BooleanValue(PRODUCT_GROUP, 'RANDOM_FEATURED', description= _("Random Display"), help_text= _("Enable random display of featured products on home page"), default=False ), ) # --- Load any extra product modules. --- extra_product = get_satchmo_setting('CUSTOM_PRODUCT_MODULES') for extra in extra_product: try: load_module("%s.config" % extra) except ImportError: log.warn('Could not load product module configuration: %s' % extra)