def customproduct_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}
Beispiel #2
0
    def test_text_export(self):
        """
        Test the content type of an exported text file.
        """
        url = "%s/product/inventory/export/" % get_satchmo_setting("SHOP_BASE")
        form_data = {"format": "yaml", "include_images": False}

        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("text/yaml", response["Content-Type"])

        form_data["format"] = "json"
        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("text/json", response["Content-Type"])

        form_data["format"] = "xml"
        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("text/xml", response["Content-Type"])

        form_data["format"] = "python"
        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("text/python", response["Content-Type"])
def settings(request):
    shop_config = Config.objects.get_current()
    cart = Cart.objects.from_request(request)

    all_categories = Category.objects.by_site()
    site = shop_config.site
    if site:
        domain = site.domain
    else:
        domain = None
    return {
        "shop_base": get_satchmo_setting("SHOP_BASE"),
        "shop": shop_config,
        "shop_name": shop_config.store_name,
        "shop_domain": domain,
        "shop_description": shop_config.store_description,
        "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,
    }
Beispiel #4
0
    def test_text_export(self):
        """
        Test the content type of an exported text file.
        """
        url = '%s/product/inventory/export/' % get_satchmo_setting('SHOP_BASE')
        form_data = {
            'format': 'yaml',
            'include_images': False,
        }

        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header('Content-Type'))
        self.assertEqual('text/yaml', response['Content-Type'])

        form_data['format'] = 'json'
        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header('Content-Type'))
        self.assertEqual('text/json', response['Content-Type'])

        form_data['format'] = 'xml'
        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header('Content-Type'))
        self.assertEqual('text/xml', response['Content-Type'])

        form_data['format'] = 'python'
        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header('Content-Type'))
        self.assertEqual('text/python', response['Content-Type'])
Beispiel #5
0
def settings(request):
    shop_config = Config.objects.get_current()
    cart = Cart.objects.from_request(request)

    all_categories = Category.objects.by_site()
    site = shop_config.site
    if site:
        domain = site.domain
    else:
        domain = None
    return {
        'shop_base': get_satchmo_setting('SHOP_BASE'),
        'shop': shop_config,
        'shop_name': shop_config.store_name,
        'shop_domain': domain,
        'shop_description': shop_config.store_description,
        '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,
    }
def settings(request):
    shop_config = Config.objects.get_current()
    cart = Cart.objects.from_request(request)

    all_categories = Category.objects.all()
    site = shop_config.site
    if site:
        domain = site.domain
    else:
        domain = None
    return {
        "shop_base": get_satchmo_setting("SHOP_BASE"),
        "shop": shop_config,
        "shop_name": shop_config.store_name,
        "shop_domain": domain,
        "shop_description": shop_config.store_description,
        "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,
    }
Beispiel #7
0
    def test_text_export(self):
        """
        Test the content type of an exported text file.
        """
        url = "%s/product/inventory/export/" % get_satchmo_setting("SHOP_BASE")
        form_data = {"format": "yaml", "include_images": False}

        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("text/yaml", response["Content-Type"])

        form_data["format"] = "json"
        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("text/json", response["Content-Type"])

        form_data["format"] = "xml"
        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("text/xml", response["Content-Type"])

        form_data["format"] = "python"
        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("text/python", response["Content-Type"])
Beispiel #8
0
def satchmo_main():
    base = get_satchmo_setting("SHOP_BASE")
    urls = ((base + "/", 1.0, "hourly"), (reverse("satchmo_cart"), 0.5,
                                          "monthly"))
    sitemap = MainSitemap()
    for url in urls:
        sitemap.add_url(*url)
    return sitemap
Beispiel #9
0
    def test_zip_export_content_type(self):
        """
        Test the content type of an exported zip file.
        """
        url = "%s/product/inventory/export/" % get_satchmo_setting("SHOP_BASE")
        form_data = {"format": "yaml", "include_images": True}

        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("application/zip", response["Content-Type"])
Beispiel #10
0
def customproduct_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
    }
Beispiel #11
0
    def test_zip_export_content_type(self):
        """
        Test the content type of an exported zip file.
        """
        url = "%s/product/inventory/export/" % get_satchmo_setting("SHOP_BASE")
        form_data = {"format": "yaml", "include_images": True}

        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header("Content-Type"))
        self.assertEqual("application/zip", response["Content-Type"])
Beispiel #12
0
def customproduct_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
    }
Beispiel #13
0
    def test_zip_export_content_type(self):
        """
        Test the content type of an exported zip file.
        """
        url = '%s/product/inventory/export/' % get_satchmo_setting('SHOP_BASE')
        form_data = {
            'format': 'yaml',
            'include_images': True,
        }

        response = self.client.post(url, form_data)
        self.assertTrue(response.has_header('Content-Type'))
        self.assertEqual('application/zip', response['Content-Type'])
Beispiel #14
0
def satchmo_main():
    base = get_satchmo_setting('SHOP_BASE')
    rv = urlresolvers.reverse
    urls = (
        (base + '/', 1.0, 'hourly'),
        (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
Beispiel #15
0
def satchmo_main():
    base = get_satchmo_setting('SHOP_BASE')
    rv = urlresolvers.reverse
    urls = (
        (base + '/', 1.0, 'hourly'),
        (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
Beispiel #16
0
from django.urls import include, path
from satchmo.product.urls import urlpatterns as productpatterns
from satchmo.shop.satchmo_settings import get_satchmo_setting

from satchmo.shop.views import home, smart, cart, orders, search, download


urlpatterns = get_satchmo_setting("SHOP_URLS")

urlpatterns += [
    path("", home.home, {}, "satchmo_shop_home"),
    path("add/", smart.smart_add, {}, "satchmo_smart_add"),
    path("cart/", cart.display, {}, "satchmo_cart"),
    path("cart/accept/", cart.agree_terms, {}, "satchmo_cart_accept_terms"),
    path("cart/add/", cart.add, {}, "satchmo_cart_add"),
    path("cart/add/ajax/", cart.add_ajax, {}, "satchmo_cart_add_ajax"),
    path("cart/qty/", cart.set_quantity, {}, "satchmo_cart_set_qty"),
    path("cart/qty/ajax/", cart.set_quantity_ajax, {}, "satchmo_cart_set_qty_ajax"),
    path("cart/remove/", cart.remove, {}, "satchmo_cart_remove"),
    path("cart/remove/ajax/", cart.remove_ajax, {}, "satchmo_cart_remove_ajax"),
    path("checkout/", include("satchmo.payment.urls")),
    path("history/", orders.order_history, {}, "satchmo_order_history"),
    path(
        "tracking/<int:order_id>/", orders.order_tracking, {}, "satchmo_order_tracking"
    ),
    path("search/", search.search_view, {}, "satchmo_search"),
    # Used for downloadable products.
    path(
        "download/process/<slug:download_key>/",
        download.process,
        {},
Beispiel #17
0
from django.urls import include, path
from satchmo.product.urls import urlpatterns as productpatterns
from satchmo.shop.satchmo_settings import get_satchmo_setting

from satchmo.shop.views import home, smart, cart, orders, search, download

urlpatterns = get_satchmo_setting("SHOP_URLS")

urlpatterns += [
    path("", home.home, {}, "satchmo_shop_home"),
    path("add/", smart.smart_add, {}, "satchmo_smart_add"),
    path("cart/", cart.display, {}, "satchmo_cart"),
    path("cart/accept/", cart.agree_terms, {}, "satchmo_cart_accept_terms"),
    path("cart/add/", cart.add, {}, "satchmo_cart_add"),
    path("cart/add/ajax/", cart.add_ajax, {}, "satchmo_cart_add_ajax"),
    path("cart/qty/", cart.set_quantity, {}, "satchmo_cart_set_qty"),
    path("cart/qty/ajax/", cart.set_quantity_ajax, {},
         "satchmo_cart_set_qty_ajax"),
    path("cart/remove/", cart.remove, {}, "satchmo_cart_remove"),
    path("cart/remove/ajax/", cart.remove_ajax, {},
         "satchmo_cart_remove_ajax"),
    path("checkout/", include("satchmo.payment.urls")),
    path("history/", orders.order_history, {}, "satchmo_order_history"),
    path("tracking/<int:order_id>/", orders.order_tracking, {},
         "satchmo_order_tracking"),
    path("search/", search.search_view, {}, "satchmo_search"),
    # Used for downloadable products.
    path(
        "download/process/<slug:download_key>/",
        download.process,
        {},
Beispiel #18
0
        default="satchmo.tax.modules.no",
        choices=[("satchmo.tax.modules.no", _("No Tax"))],
    ))
DEFAULT_VIEW_TAX = config_register(
    BooleanValue(
        TAX_GROUP,
        "DEFAULT_VIEW_TAX",
        description=_("Show with tax included"),
        help_text=
        _("If yes, then all products and the cart will display with tax included."
          ),
        default=False,
    ))

# --- Load default tax modules.  Ignore import errors, user may have deleted them. ---
_default_modules = ("percent", "area")
for module in _default_modules:
    try:
        load_module("satchmo.tax.modules.%s.config" % module)
    except ImportError as ie:
        logger.debug("Could not load default tax module configuration: %s\n%s",
                     module, ie)

# --- 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:
        logger.warn("Could not load tax module configuration: %s" % extra)
Beispiel #19
0
from django.conf.urls import include, patterns, url
from satchmo.product.urls import urlpatterns as productpatterns
from satchmo.shop.satchmo_settings import get_satchmo_setting
from satchmo.utils import app_enabled

urlpatterns = get_satchmo_setting('SHOP_URLS')

urlpatterns += patterns(
    'satchmo.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('satchmo.payment.urls')),
    (r'^history/$', 'orders.order_history', {}, 'satchmo_order_history'),
    (r'^tracking/(?P<order_id>\d+)/$', 'orders.order_tracking', {}, 'satchmo_order_tracking'),
    (r'^search/$', 'search.search_view', {}, 'satchmo_search'),

    # Used for downloadable products.
    (r'^download/process/(?P<download_key>\w+)/$', 'download.process', {}, 'satchmo_download_process'),
    (r'^download/send/(?P<download_key>\w+)/$', 'download.send_file', {}, 'satchmo_download_send'),

    (r'^wishlist/', include('satchmo.wishlist.urls')),
    url(r'^fulfilment/', include('satchmo.fulfilment.urls'))
Beispiel #20
0
from satchmo.caching import cache_delete
from satchmo.configuration import config_get, config_value
from satchmo.contact import CUSTOMER_ID
from satchmo.contact.models import Contact, AddressBook
from satchmo.l10n.models import Country
from satchmo.product.models import Product
from satchmo.shop.exceptions import CartAddProhibited
from satchmo.shop.satchmo_settings import get_satchmo_setting
from satchmo.shop.factories import TestOrderFactory
from satchmo.shop.models import *
from satchmo.shop.templatetags import get_filter_args

from satchmo.shop import signals

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,
Beispiel #21
0
from django.test.client import Client

from satchmo import caching
from satchmo.configuration.functions import config_get_group, config_value, config_get
from satchmo.contact.models import *
from satchmo.l10n.models import *
from satchmo.product.models import *
from satchmo.shop.satchmo_settings import get_satchmo_setting
from satchmo.shop.models import *
from satchmo.utils.dynamic import lookup_template, lookup_url
from satchmo.payment.urls import make_urlpatterns

alphabet = "abcdefghijklmnopqrstuvwxyz"

domain = "http://testserver"
prefix = get_satchmo_setting("SHOP_BASE")
if prefix == "/":
    prefix = ""


class TestRecurringBilling(TestCase):
    fixtures = ["l10n_data.xml", "test_shop.yaml", "sub_products", "config"]

    def setUp(self):
        self.customer = Contact.objects.create(first_name="Jane",
                                               last_name="Doe")
        US = Country.objects.get(iso2_code__iexact="US")
        self.customer.addressbook_set.create(
            street1="123 Main St",
            city="New York",
            state="NY",
Beispiel #22
0
    We can handle it any which way."""
        ),
        default="images",
    )
)

config_register(
    StringValue(
        PRODUCT_GROUP,
        "PROTECTED_DIR",
        description=_("Protected dir"),
        help_text=_(
            """This is only used if you use Downloadable Products.
This value will be appended to MEDIA_ROOT.  Do not worry about slashes.
We can handle it any which way."""
        ),
        default="protected",
        requires=PRODUCT_TYPES,
        requiresvalue="product::DownloadableProduct",
    )
)

# --- 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:
        logger.warn("Could not load product module configuration: %s" % extra)
Beispiel #23
0
"""Base urls used by Satchmo.

Split out from urls.py to allow much easier overriding and integration with larger apps.
"""
from django.conf.urls import include, patterns
from satchmo.shop.satchmo_settings import get_satchmo_setting
from satchmo.shop.views.sitemaps import sitemaps

shop_base = get_satchmo_setting('SHOP_BASE')
if shop_base == '':
    shopregex = '^'
else:
    shopregex = '^' + shop_base[1:] + '/'


urlpatterns = patterns(
    '',
    (r"^settings/", include('satchmo.configuration.urls')),
    (shopregex, include('satchmo.shop.urls')),
    (r'sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}, 'satchmo_sitemap_xml'),
    (r'cache/', include('satchmo.caching.urls')),
    (r'product-feed\.xml$', "satchmo.utils.google.product_feed"),
    (r'^accounts/', include('satchmo.accounts.urls')),
)
Beispiel #24
0
# --- 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 satchmo.shipping.modules.tiered to your INSTALLED_APPS, you don't
# need to add it to CUSTOM_SHIPPING_MODULES either.
_default_modules = ("dummy", "fedex", "flat", "per", "ups", "usps", "royalmailcontract")

for module in _default_modules:
    try:
        load_module("satchmo.shipping.modules.%s.config" % module)
    except ImportError:
        logger.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:
        logger.warn("Could not load shipping module configuration: %s" % extra)


class ShippingModuleNotFound(Exception):
    def __init__(self, key):
        self.key = key


def shipping_methods():
    methods = []
Beispiel #25
0
"""Base urls used by Satchmo.

Split out from urls.py to allow much easier overriding and integration with larger apps.
"""
from django.urls import include, path
from django.contrib.sitemaps.views import sitemap
from satchmo.shop.satchmo_settings import get_satchmo_setting
from satchmo.shop.views.sitemaps import sitemaps
from satchmo.configuration import urls as configuration_urls
from satchmo.shop import urls as shop_urls
from satchmo.caching import urls as caching_urls
from satchmo.utils.google import product_feed

shop_base = get_satchmo_setting("SHOP_BASE")

if shop_base == "":
    shop_paths = ""
else:
    shop_paths = "" + shop_base[1:] + "/"

urlpatterns = [
    path("settings/", include(configuration_urls)),
    path(shop_paths, include(shop_urls)),
    path("sitemap.xml", sitemap, {"sitemaps": sitemaps},
         "satchmo_sitemap_xml"),
    path("cache", include(caching_urls)),
    path("product-feed.xml", product_feed),
]
Beispiel #26
0
"""Base urls used by Satchmo.

Split out from urls.py to allow much easier overriding and integration with larger apps.
"""
from django.conf.urls import include, patterns
from satchmo.shop.satchmo_settings import get_satchmo_setting
from satchmo.shop.views.sitemaps import sitemaps

shop_base = get_satchmo_setting('SHOP_BASE')
if shop_base == '':
    shopregex = '^'
else:
    shopregex = '^' + shop_base[1:] + '/'

urlpatterns = patterns(
    '',
    (r"^settings/", include('satchmo.configuration.urls')),
    (shopregex, include('satchmo.shop.urls')),
    (r'sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {
        'sitemaps': sitemaps
    }, 'satchmo_sitemap_xml'),
    (r'cache/', include('satchmo.caching.urls')),
    (r'product-feed\.xml$', "satchmo.utils.google.product_feed"),
    (r'^accounts/', include('satchmo.accounts.urls')),
)
Beispiel #27
0
from django.contrib.auth.models import User
from django.test import TestCase
from django.test.client import Client

from satchmo.caching import cache_delete
from satchmo.contact.models import Contact
from satchmo.product.models import Product
from satchmo.shop.satchmo_settings import get_satchmo_setting
from satchmo.wishlist.models import ProductWish

domain = "http://testserver"
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,
        "ship_street1": "1011 Some Other Street",
        "ship_city": "Springfield",
        "ship_state": "MO",
        "ship_postal_code": "81123",
Beispiel #28
0
    def test_order_payload(self):
        self.maxDiff = None
        order = TestOrderFactory()

        callback_url = external_url(
            "{root}/fulfilment/six/{id}/{hash}/".format(
                root=get_satchmo_setting("SHOP_BASE"),
                id=order.id,
                hash=order.verification_hash,
            )
        )

        self.assertEqual(
            json.loads(order_payload(order)),
            {
                "api_key": "",
                "test": True,
                "allow_preorder": False,
                "update_stock": True,
                "order": {
                    "client_ref": order.id,
                    "po_number": order.id,
                    "date_placed": str(order.time_stamp),
                    "callback_url": callback_url,
                    "postage_speed": 2,
                    "postage_cost": float_price(order.shipping_cost),
                    "total_amount": float_price(order.sub_total),
                    "signed_for": False,
                    "tracked": False,
                    "ShippingContact": {
                        "dear": order.contact.user.first_name,
                        "name": order.ship_addressee,
                        "email": order.contact.user.email,
                        "phone": order.contact.primary_phone or "",
                        "address": order.ship_street1,
                        "address_contd": order.ship_street2,
                        "city": order.ship_city,
                        "county": order.ship_state,
                        "country": str(order.ship_country),
                        "postcode": order.ship_postal_code,
                    },
                    "BillingContact": {
                        "name": order.bill_addressee,
                        "email": order.contact.user.email,
                        "phone": order.contact.primary_phone or "",
                        "address": order.bill_street1,
                        "address_contd": order.bill_street2,
                        "city": order.bill_city,
                        "county": order.bill_state,
                        "country": str(order.bill_country),
                        "postcode": order.bill_postal_code,
                    },
                    "items": [
                        {
                            "client_ref": order.orderitem_set.all()[0].product.slug,
                            "quantity": order.orderitem_set.all()[0].quantity,
                            "price": float_price(
                                order.orderitem_set.all()[0].unit_price
                            ),
                        }
                    ],
                },
            },
        )
Beispiel #29
0
def orderpayment_list(order):
    return {
        'SHOP_BASE' : get_satchmo_setting('SHOP_BASE'),
        'order' : order,
        'payments' : order.payments.all()
        }
Beispiel #30
0
"""Base urls used by Satchmo.

Split out from urls.py to allow much easier overriding and integration with larger apps.
"""
from django.urls import include, path
from django.contrib.sitemaps.views import sitemap
from satchmo.shop.satchmo_settings import get_satchmo_setting
from satchmo.shop.views.sitemaps import sitemaps
from satchmo.configuration import urls as configuration_urls
from satchmo.shop import urls as shop_urls
from satchmo.caching import urls as caching_urls
from satchmo.utils.google import product_feed

shop_base = get_satchmo_setting("SHOP_BASE")

if shop_base == "":
    shop_paths = ""
else:
    shop_paths = "" + shop_base[1:] + "/"


urlpatterns = [
    path("settings/", include(configuration_urls)),
    path(shop_paths, include(shop_urls)),
    path("sitemap.xml", sitemap, {"sitemaps": sitemaps}, "satchmo_sitemap_xml"),
    path("cache", include(caching_urls)),
    path("product-feed.xml", product_feed),
]
Beispiel #31
0
    'MODULE',
    description=_("Active tax module"),
    help_text=_("Select a module, save and reload to set any module-specific settings."),
    default="satchmo.tax.modules.no",
    choices=[('satchmo.tax.modules.no', _('No Tax')),
    ]
))
DEFAULT_VIEW_TAX = config_register(BooleanValue(TAX_GROUP,
    'DEFAULT_VIEW_TAX',
    description=_("Show with tax included"),
    help_text=_("If yes, then all products and the cart will display with tax included."),
    default=False
))

# --- Load default tax modules.  Ignore import errors, user may have deleted them. ---
_default_modules = ('percent','area')
for module in _default_modules:
    try:
        load_module("satchmo.tax.modules.%s.config" % module)
    except ImportError, ie:
        log.debug('Could not load default tax module configuration: %s\n%s', module, ie)

    
# --- 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)
Beispiel #32
0
        default="0.00",
    ),
)

# --- Load default payment modules.  Ignore import errors. ---
_default_modules = ("dummy", "autosuccess", "ingenico", "paypal", "worldpay")

for module in _default_modules:
    try:
        load_module("satchmo.payment.modules.%s.config" % module)
    except ImportError as e:
        log.warning("Could not load default payment module configuration: %s", module)
        log.exception(e)

# --- 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 credit_choices(settings=None, include_module_if_no_choices=False):
    choices = []
    keys = []
    for module in config_value("PAYMENT", "MODULES"):
        vals = config_choice_values(module, "CREDITCHOICES")
        for val in vals:
def orderpayment_list(order):
    return {
        "SHOP_BASE": get_satchmo_setting("SHOP_BASE"),
        "order": order,
        "payments": order.payments.all(),
    }
Beispiel #34
0
from django.conf.urls import include, patterns, url
from satchmo.product.urls import urlpatterns as productpatterns
from satchmo.shop.satchmo_settings import get_satchmo_setting
from satchmo.utils import app_enabled

urlpatterns = get_satchmo_setting('SHOP_URLS')

urlpatterns += patterns(
    'satchmo.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('satchmo.payment.urls')),
    (r'^history/$', 'orders.order_history', {}, 'satchmo_order_history'),
    (r'^tracking/(?P<order_id>\d+)/$', 'orders.order_tracking', {},
     'satchmo_order_tracking'),
    (r'^search/$', 'search.search_view', {}, 'satchmo_search'),

    # Used for downloadable products.
    (r'^download/process/(?P<download_key>\w+)/$', 'download.process', {},
     'satchmo_download_process'),
    (r'^download/send/(?P<download_key>\w+)/$', 'download.send_file', {},
Beispiel #35
0
def orderpayment_list(order):
    return {
        "SHOP_BASE": get_satchmo_setting("SHOP_BASE"),
        "order": order,
        "payments": order.payments.all(),
    }
Beispiel #36
0
from django.conf import settings
from django.core import urlresolvers
from django.test import TestCase
from satchmo import caching
from satchmo.shop.satchmo_settings import get_satchmo_setting

domain = 'http://example.com'
prefix = get_satchmo_setting('SHOP_BASE')
if prefix == '/':
    prefix = ''

class GoogleBaseTest(TestCase):
    """Test Google Base feed."""

    fixtures = ['l10n_data.xml','sample-store-data.yaml', 'products.yaml', 'test-config.yaml']

    def tearDown(self):
        caching.cache_delete

    def test_feed(self):
        url = urlresolvers.reverse('satchmo_atom_feed')
        response = self.client.get(url)
        self.assertContains(response,
            "<title>Robots Attack! (Hard cover)</title>",
            count=1, status_code=200)
        self.assertContains(response,
            "<link href=\"%s%s/product/robot-attack-hard/\" />" % (
            domain, prefix), count=1, status_code=200)
Beispiel #37
0
        PRODUCT_GROUP,
        "IMAGE_DIR",
        description=_("Upload Image Dir"),
        help_text=_("""Directory name for storing uploaded images.
    This value will be appended to MEDIA_ROOT.  Do not worry about slashes.
    We can handle it any which way."""),
        default="images",
    ))

config_register(
    StringValue(
        PRODUCT_GROUP,
        "PROTECTED_DIR",
        description=_("Protected dir"),
        help_text=_("""This is only used if you use Downloadable Products.
This value will be appended to MEDIA_ROOT.  Do not worry about slashes.
We can handle it any which way."""),
        default="protected",
        requires=PRODUCT_TYPES,
        requiresvalue="product::DownloadableProduct",
    ))

# --- 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:
        logger.warn("Could not load product module configuration: %s" % extra)