Пример #1
0
 def load_app_configurations(self):
     for modulename in settings.INSTALLED_APPS:
         try:
             load_module(modulename + '.config')
             log.debug('Loaded configuration for %s', modulename)
         except ImportError:
             pass
Пример #2
0
 def load_app_configurations(self):
     for modulename in settings.INSTALLED_APPS:
         try:
             load_module(modulename + '.config')
             log.debug('Loaded configuration for %s', modulename)
         except ImportError:
             pass
Пример #3
0
 def to_python(self, value):
     if value == NOTSET:
         v = {}
     else:
         v = load_module(value)
     #log.debug("Returning module [%s]: %s", value, str(v))
     return v
Пример #4
0
 def load_module(self, module):
     """Load a child module"""
     value = self._value()
     if value == NOTSET:
         raise SettingNotSet("%s.%s", self.group.key, self.key)
     else:
         return load_module("%s.%s" % (value, module))
Пример #5
0
def _get_shipping_choices(paymentmodule, cart, contact):
    """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 = {}

    for module in config_value('SHIPPING', 'MODULES'):
        #Create the list of information the user will see
        shipping_module = load_module(module)
        shipping_instance = shipping_module.Calc(cart, contact)
        if shipping_instance.valid():
            template = lookup_template(paymentmodule, 'shipping_options.html')
            t = loader.get_template(template)
            shipcost = shipping_instance.cost()
            c = Context({
                'amount':
                shipcost,
                'description':
                shipping_instance.description(),
                'method':
                shipping_instance.method(),
                'expected_delivery':
                shipping_instance.expectedDelivery()
            })
            shipping_options.append((shipping_instance.id, t.render(c)))
            shipping_dict[shipping_instance.id] = shipcost

    return shipping_options, shipping_dict
Пример #6
0
def _get_shipping_choices(paymentmodule, cart, contact):
    """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 = {}
    
    for module in config_value('SHIPPING','MODULES'):
        #Create the list of information the user will see
        shipping_module = load_module(module)
        shipping_instance = shipping_module.Calc(cart, contact)
        if shipping_instance.valid():
            template = lookup_template(paymentmodule, 'shipping_options.html')
            t = loader.get_template(template)
            shipcost = shipping_instance.cost()
            c = Context({
                'amount': shipcost,
                'description' : shipping_instance.description(),
                'method' : shipping_instance.method(),
                'expected_delivery' : shipping_instance.expectedDelivery() })
            shipping_options.append((shipping_instance.id, t.render(c)))
            shipping_dict[shipping_instance.id] = shipcost
    
    return shipping_options, shipping_dict
Пример #7
0
def get_newsletter_module():
    try:
        modulename = config_value('NEWSLETTER', 'MODULE')
    except AttributeError:
        modulename = 'satchmo.newsletter.ignore'

    return load_module(modulename)
Пример #8
0
 def to_python(self, value):
     if value == NOTSET:
         v = {}            
     else:
         v = load_module(value)
     #log.debug("Returning module [%s]: %s", value, str(v))
     return v
Пример #9
0
 def load_module(self, module):
     """Load a child module"""
     value = self._value()
     if value == NOTSET:
         raise SettingNotSet("%s.%s", self.group.key, self.key)
     else:
         return load_module("%s.%s" % (value, module))
Пример #10
0
def get_newsletter_module():
    try:
        modulename = config_value('NEWSLETTER', 'MODULE')
    except AttributeError:
        modulename = 'satchmo.newsletter.ignore'
        
    return load_module(modulename)
Пример #11
0
def pay_ship_save(new_order, cart, contact, shipping, discount):
    # Set a default for when no shipping module is used
    new_order.shipping_cost = Decimal("0.00")

    # Save the shipping info
    for module in config_value("SHIPPING", "MODULES"):
        shipping_module = load_module(module)
        shipping_instance = shipping_module.Calc(cart, contact)
        if shipping_instance.id == shipping:
            new_order.shipping_description = shipping_instance.description().encode()
            new_order.shipping_method = shipping_instance.method()
            new_order.shipping_cost = shipping_instance.cost()
            new_order.shipping_model = shipping

    # Temp setting of the tax and total so we can save it
    new_order.total = Decimal("0.00")
    new_order.tax = Decimal("0.00")
    new_order.sub_total = cart.total

    new_order.method = "Online"

    if discount:
        new_order.discount_code = discount

    # save so that we can add orderitems
    new_order.save()

    # Add all the items in the cart to the order
    for item in cart.cartitem_set.all():
        new_order_item = OrderItem(
            order=new_order,
            product=item.product,
            quantity=item.quantity,
            unit_price=item.unit_price,
            line_item_price=item.line_total,
        )
        new_order_item.save()

    new_order.recalculate_total()
Пример #12
0
def pay_ship_save(new_order, cart, contact, shipping, discount):
    # Set a default for when no shipping module is used
    new_order.shipping_cost = Decimal("0.00")

    # Save the shipping info
    for module in config_value('SHIPPING', 'MODULES'):
        shipping_module = load_module(module)
        shipping_instance = shipping_module.Calc(cart, contact)
        if shipping_instance.id == shipping:
            new_order.shipping_description = shipping_instance.description(
            ).encode()
            new_order.shipping_method = shipping_instance.method()
            new_order.shipping_cost = shipping_instance.cost()
            new_order.shipping_model = shipping

    # Temp setting of the tax and total so we can save it
    new_order.total = Decimal('0.00')
    new_order.tax = Decimal('0.00')
    new_order.sub_total = cart.total

    new_order.method = 'Online'

    if discount:
        new_order.discount_code = discount

    # save so that we can add orderitems
    new_order.save()

    # Add all the items in the cart to the order
    for item in cart.cartitem_set.all():
        new_order_item = OrderItem(order=new_order,
                                   product=item.product,
                                   quantity=item.quantity,
                                   unit_price=item.unit_price,
                                   line_item_price=item.line_total)
        new_order_item.save()

    new_order.recalculate_total()
Пример #13
0
        'SSL',
        description=_("Enable SSL"),
        help_text=
        _("""This enables for generic pages like contact information capturing.  
It does not set SSL for individual modules. 
You must enable SSL for each payment module individually."""),
        default=False)
])

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

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 = getattr(settings, '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 ---
Пример #14
0
        TAX_GROUP,
        '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.percent', _('Percent Tax')),
                 ('satchmo.tax.modules.no', _('No Tax'))]))

config_register([
    DecimalValue(TAX_GROUP,
                 'PERCENT',
                 description=_("Percent tax"),
                 requires=TAX_MODULE,
                 requiresvalue='satchmo.tax.modules.percent'),
    BooleanValue(TAX_GROUP,
                 'TAX_SHIPPING',
                 description=_("Tax Shipping?"),
                 default=False)
])

# --- Load any extra tax modules. ---
extra_tax = getattr(settings, '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)
Пример #15
0
BooleanValue(PAYMENT_GROUP,
    'SSL',
    description=_("Enable SSL"),
    help_text=_("""This enables for generic pages like contact information capturing.  
It does not set SSL for individual modules. 
You must enable SSL for each payment module individually."""),
    default=False)

])

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

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 = getattr(settings, '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):
Пример #16
0
def get_processor(order):
    modulename = config_value('TAX', 'MODULE')
    mod = load_module(modulename + u'.tax')
    return mod.Processor(order)
Пример #17
0
    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"),
    
BooleanValue(PRODUCT_GROUP,
    'RENAME_IMAGES',
    description=_("Rename product images?"),
    help_text=_("Automatically rename product images on upload?"),
    default=True),
    
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"),
    
])
    
# --- Load any extra payment modules. ---
extra_product = getattr(settings, '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)
Пример #18
0
def get_processor(order):
    modulename = config_value('TAX','MODULE')
    mod = load_module(modulename + u'.tax')
    return mod.Processor(order)