コード例 #1
0
ファイル: tests.py プロジェクト: jimmcgaw/levicci
    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'])
コード例 #2
0
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
コード例 #3
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
    }
コード例 #4
0
ファイル: tests.py プロジェクト: jimmcgaw/levicci
    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'])
コード例 #5
0
ファイル: sitemaps.py プロジェクト: jimmcgaw/levicci
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
コード例 #6
0
ファイル: urls_base.py プロジェクト: jimmcgaw/levicci
"""Base urls used by Satchmo.

Split out from urls.py to allow much easier overriding and integration with larger apps.
"""
from django.conf import settings
from django.conf.urls.defaults import *
from satchmo.shop 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'^admin/print/(?P<doc>[-\w]+)/(?P<id>\d+)', 
        'satchmo.shipping.views.displayDoc', {}, 
        'satchmo_print_shipping'),
    (r'^admin/product/configurableproduct/(?P<id>\d+)/getoptions/', 
        'satchmo.product.views.get_configurable_product_options', {}, 
        'satchmo_admin_configurableproduct'),
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    (r'^accounts/', include('satchmo.accounts.urls')),
    (shopregex, include('satchmo.shop.urls')),
    (r'sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', 
        {'sitemaps': sitemaps}, 
        'satchmo_sitemap_xml'),
    (r'settings/', include('satchmo.configuration.urls')),
    (r'cache/', include('satchmo.caching.urls')),
)
コード例 #7
0
ファイル: config.py プロジェクト: jimmcgaw/levicci
config_register(
    StringValue(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:
        log.warn('Could not load product module configuration: %s' % extra)
コード例 #8
0
ファイル: config.py プロジェクト: jimmcgaw/levicci
NEWSLETTER_GROUP = ConfigurationGroup('NEWSLETTER', _('Newsletter Settings'))

NEWSLETTER_ACTIVE = config_register(StringValue(NEWSLETTER_GROUP,
    'MODULE',
    description=_("Active newsletter module"),
    help_text=_("Select a newsletter, save and reload to set any module-specific newsletter settings."),
    default="satchmo.newsletter.simple",
    choices=[('satchmo.newsletter.ignore', _('No newsletter')),
            ('satchmo.newsletter.simple', _('Simple list')),
             ('satchmo.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.newsletter.mailman',
    default=""
    ))

# --- Load any extra payment 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)
コード例 #9
0
ファイル: tests.py プロジェクト: sankroh/satchmo
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 import get_satchmo_setting, CartAddProhibited
from satchmo.shop.models import *
from satchmo.shop.templatetags import get_filter_args

from satchmo.shop import signals

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,
コード例 #10
0
ファイル: tests.py プロジェクト: jimmcgaw/levicci
from django.conf import settings
from django.core import urlresolvers
from django.test import TestCase
from satchmo import caching
from satchmo.shop 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.yaml','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)
コード例 #11
0
ファイル: config.py プロジェクト: jimmcgaw/levicci
        description=_("Minimum Order"),
        help_text=_("""The minimum cart total before checkout is allowed."""),
        default="0.00")
)

# --- Load default payment modules.  Ignore import errors, user may have deleted them. ---
_default_modules = ('authorizenet','dummy','google','paypal', 'trustcommerce', 'cybersource', 'autosuccess', 'cod', 'protx')

for module in _default_modules:
    try:
        load_module("satchmo.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 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:
コード例 #12
0
ファイル: config.py プロジェクト: jimmcgaw/levicci
# --- 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')

for module in _default_modules:
    try:
    	load_module("satchmo.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__(key):
        self.key = key

def shipping_methods():
    methods = []
    modules = config_value('SHIPPING', 'MODULES')
    log.debug('Getting shipping methods: %s', modules)
コード例 #13
0
ファイル: views.py プロジェクト: jimmcgaw/levicci
def shop_logout(request):
    logout(request)
    if CUSTOMER_ID in request.session:
        del request.session[CUSTOMER_ID]
    return http.HttpResponseRedirect('%s/' % (get_satchmo_setting('SHOP_BASE')))    
コード例 #14
0
def orderpayment_list(order):
    return {
        'SHOP_BASE' : get_satchmo_setting('SHOP_BASE'),
        'order' : order,
        'payments' : order.payments.all()
        }
コード例 #15
0
ファイル: urls.py プロジェクト: jimmcgaw/levicci
from django.conf import settings
from django.conf.urls.defaults import *
from satchmo.configuration import config_value
from satchmo.product.urls import urlpatterns as productpatterns
from satchmo.shop 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'^contact/$', 'contact.form', {}, 'satchmo_contact'),
    (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'),

    # Override comments with our redirecting view. You can remove the next two
    # URLs if you aren't using ratings.
    #(r'^comments/post/$', 'comments.post_rating', {'maxcomments': 1 }, 'satchmo_rating_post'),
    (r'^comments/', include('django.contrib.comments.urls')),
    
コード例 #16
0
ファイル: config.py プロジェクト: jimmcgaw/levicci
    '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)