def EditPurchaseForm(self): # NOQA return import_string( get_setting( 'EDIT_PURCHASE_FORM', default='%s.internal.forms.EditPurchaseForm' % __name__ ) )
def UserChangeForm(self): return import_string( get_setting( 'USER_CHANGE_FORM', default='%s.internal.forms.UserChangeForm' % __name__ ) )
def AddToCartForm(self): # NOQA return import_string( get_setting( 'ADD_TO_CART_FORM', default='%s.internal.forms.AddToCartForm' % __name__ ) )
def PaymentMethodForm(self): return import_string( get_setting( 'PAYMENT_METHOD_FORM', default='%s.internal.forms.PaymentMethodForm' % __name__ ) )
def AuthenticationForm(self): return import_string( get_setting( 'AUTHENTICATION_FORM', default='django.contrib.auth.forms.AuthenticationForm' ) )
def UserCreationForm(self): return import_string( get_setting( 'USER_CREATION_FORM', default='%s.internal.forms.UserCreationForm' % __name__ ) )
def PasswordResetForm(self): return import_string( get_setting( 'PASSWORD_RESET_FORM', default='django.contrib.auth.forms.PasswordResetForm' ) )
def IDealIssuerForm(self): return import_string( get_setting( 'MOLLIE_IDEAL_ISSUER_FORM', default='%s.internal.forms.IDealIssuerForm' % __name__ ) )
def InvoiceReportWriter(self): return import_string( get_setting( 'INVOICE_REPORT_WRITER', default='%s.internal.writers.InvoiceReportWriter' % __name__ ) )
def ShippingNotificationMailWriter(self): return import_string( get_setting( 'SHIPPING_NOTIFICATION_MAIL_WRITER', default='%s.internal.writers.ShippingNotificationMailWriter' % __name__ ) )
def OrderNotificationMailWriter(self): return import_string( get_setting( 'INVOICE_MAIL_WRITER', default='%s.internal.writers.OrderNotificationMailWriter' % __name__ ) )
def OrderConfirmationReportWriter(self): return import_string( get_setting( 'ORDER_CONFIRMATION_REPORT_WRITER', default='%s.internal.writers.OrderConfirmationReportWriter' % __name__ ) )
def load_model(): if MAX_TIER_ATTRIBUTES == 0: return tiered_attribute_types = _attribute_types( get_setting( 'TIERED_ATTRIBUTE_TYPES', default=[ 'sellmo.contrib.attribute.types.IntegerAttributeType', 'sellmo.contrib.attribute.types.FloatAttributeType', ] ) ) class SiteSettings(_settings.models.SiteSettings): def clean(self): errors = {} for i in range(MAX_TIER_ATTRIBUTES): attr = 'shipping_tier_attribute{0}'.format(i + 1) attribute = getattr(self, attr, None) if attribute is None: continue attribute_type = type(attribute.get_type()) if ( not any( [ issubclass(attribute_type, typ) for typ in tiered_attribute_types ] ) ): errors[attr] = [ _("Invalid attribute type, must be numeric.") ] if errors: raise ValidationError(errors) class Meta(_settings.models.SiteSettings.Meta): abstract = True _settings.models.SiteSettings = SiteSettings
# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from sellmo.conf import get_setting VALUE_FORMAT = get_setting('VALUE_FORMAT', default=u"{value}")
# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from sellmo.conf import get_setting DEFAULT_REPORT_FORMAT = get_setting('DEFAULT_REPORT_FORMAT', default='pdf')
return ( u"{values} +{price_adjustment}".format( values=values, price_adjustment=price_adjustment ) ) else: return ( u"{values} -{price_adjustment}".format( values=values, price_adjustment=-price_adjustment ) ) return u"{values}".format(values=values) VARIATION_CHOICE_FORMAT = get_setting( 'VARIATION_CHOICE_FORMAT', default=_choice_format ) VARIATION_DESCRIPTION_FORMAT = get_setting( 'VARIATION_DESCRIPTION_FORMAT', default=u"{prefix} ({values})" ) VARIATION_VALUE_SEPERATOR = get_setting( 'VARIATION_VALUE_SEPERATOR', default=u", " )
def OrderConfirmationMailWriter(self): return import_string( get_setting( 'ORDER_CONFIRMATION_MAIL_WRITER', default='%s.internal.writers.OrderConfirmationMailWriter' % __name__))
def _currencies(value): currencies = {} for args in value: currency = Currency(*args) currencies[currency.code] = currency return currencies CURRENCIES = _currencies( get_setting( 'CURRENCIES', required=True, default=[ ('eur', _(u"euro"), _(u"\u20ac {amount:\u00a0>{align}.2f}")), ] ) ) def _default_currency(value): if value not in CURRENCIES: raise ImproperlyConfigured( "Default currency %s is not in currencies" % value ) return CURRENCIES[value] DEFAULT_CURRENCY = _default_currency(
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import re from sellmo.conf import get_setting INDEX_LOCK_TIMEOUT = get_setting('INDEX_LOCK_TIMEOUT', default=30) ORDER_PATTERN = re.compile(r'\?|[-+]?[.\w]+$') DEFAULT_FILTER_OPERATOR = 'exact' FILTER_OPERATORS = set([ 'contains', 'exact', 'gt', 'gte', 'lt', 'lte', 'in', 'startswith', 'range', 'isnull' ]) FILTER_SEPARATOR = '__' SELLMO_VERSION_PICKLE_KEY = '_sellmo_version'
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import abc from django.utils.module_loading import import_string from sellmo.conf import get_setting class AbstractMailHandler(object): __metaclass__ = abc.ABCMeta def __init__(self, writer): self.writer = writer @abc.abstractmethod def handle_mail(self, message_type, message_reference, context): pass DefaultMailHandler = import_string( get_setting( 'DEFAULT_MAIL_HANDLER', default='sellmo.contrib.mailing.handlers.default.DefaultMailHandler' ) )
def ShippingNotificationMailWriter(self): return import_string( get_setting( 'SHIPPING_NOTIFICATION_MAIL_WRITER', default='%s.internal.writers.ShippingNotificationMailWriter' % __name__))
# 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from sellmo.conf import get_setting SEND_MAIL_RETRY_ENABLED = get_setting('SEND_MAIL_RETRY_ENABLED', default=True) SEND_MAIL_RETRY_DELAY = get_setting('SEND_MAIL_RETRY_DELAY', default=5 * 60) SEND_MAIL_RETRY_LIMIT = get_setting('SEND_MAIL_RETRY_LIMIT', default=3)
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from django.core.cache import caches from django.utils.module_loading import import_string from sellmo.conf import get_setting from sellmo.caching.constants import DEFAULT_CACHE_ALIAS from .base import BaseCache CACHES = get_setting( "CACHES", default={ "django.core.cache.backends.locmem.LocMemCache": "sellmo.caching.caches.locmem.LocMemCache", "django_redis.cache.RedisCache": "sellmo.caching.caches.redis.RedisCache", }, ) backend_cls = type(caches[DEFAULT_CACHE_ALIAS]) def cache_factory(): dotted_path = "%s.%s" % (backend_cls.__module__, backend_cls.__name__) if dotted_path in CACHES: return import_string(CACHES[dotted_path]) return BaseCache class Cache(cache_factory()):
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import re from sellmo.conf import get_setting INDEX_LOCK_TIMEOUT = get_setting('INDEX_LOCK_TIMEOUT', default=30) ORDER_PATTERN = re.compile(r'\?|[-+]?[.\w]+$') DEFAULT_FILTER_OPERATOR = 'exact' FILTER_OPERATORS = set( [ 'contains', 'exact', 'gt', 'gte', 'lt', 'lte', 'in', 'startswith', 'range', 'isnull' ] ) FILTER_SEPARATOR = '__' SELLMO_VERSION_PICKLE_KEY = '_sellmo_version'
def RegistrationProcess(self): return import_string(get_setting('REGISTRATION_PROCESS'))
# specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from django.conf import settings from sellmo.conf import get_setting enabled = get_setting('CELERY_ENABLED', default=False) app = None def setup(): global app # pylint:disable=import-error from celery import Celery app = Celery() app.config_from_object('django.conf:settings') app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
from .pipe import pipe, PipeError PARAMS = { 'pdf': { 'size': 'A4', 'orientation': 'portrait', 'margin': '1cm', 'zoom': 1.0, }, 'png': { 'viewport': '800x800' } } phantomjs_params = get_setting('PARAMS', default=PARAMS, prefix='PHANTOMJS') phantomjs_executable = get_setting( 'PARAMS', default='phantomjs', prefix='PHANTOMJS' ) class PhantomJSReportGenerator(AbstractReportGenerator): @property def input_formats(self): return ['html'] @property def output_formats(self):
# this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from datetime import timedelta from sellmo.conf import get_setting from django.conf import settings QTY_LIMIT = get_setting('QTY_LIMIT', default=9999) RECALCULATION_TIMEOUT = get_setting( 'RECALCULATION_TIMEOUT', default=(timedelta(minutes=10) if not settings.DEBUG else timedelta()))
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from django.utils.translation import ugettext_lazy as _ from sellmo.conf import get_setting import pycountry COUNTRY_CHOICES = [(country.alpha2, country.name) for country in list(pycountry.countries)] PHONE_NUMBER_ENABLED = get_setting('PHONE_NUMBER_ENABLED', default=True) PHONE_NUMBER_REQUIRED = get_setting('PHONE_NUMBER_REQUIRED', default=False) NAME_PREFIX_ENABLED = get_setting('NAME_PREFIX_ENABLED', default=False) NAME_PREFIX_REQUIRED = get_setting('NAME_PREFIX_REQUIRED', default=True) NAME_PREFIX_CHOICES = get_setting('NAME_PREFIX_CHOICES', default=[ ('sir', _("sir")), ('madame', _("madam")), ]) NAME_SUFFIX_ENABLED = get_setting('NAME_SUFFIX_ENABLED', default=True)
# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from sellmo.conf import get_setting ALLOW_GET_LOGOUT = get_setting("ALLOW_GET_LOGOUT", default=False)
# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from sellmo.conf import get_setting INDEXABLE_QTYS = get_setting('INDEXABLE_QTYS', default=[1])
# 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from sellmo.conf import get_setting ADDRESS_TYPES = get_setting('ADDRESS_TYPES', default=['shipping', 'billing']) EMAIL_REQUIRED = get_setting('EMAIL_REQUIRED', default=True) BUSINESSES_ONLY = get_setting('BUSINESSES_ONLY', default=False) BUSINESSES_ALLOWED = get_setting('BUSINESSES_ALLOWED', default=True)
""" (Re)indexes each document from the given iterable. A document can be either a model or it's pk. """ pass @abc.abstractmethod def fetch_index(self, index, query): """ Searches the index for documents matching the given query. Should return a tuple containing an iterable of document pk's, a values dictionary and a facets dictionary. """ pass @abc.abstractmethod def fetch_index_count(self, index, query): """ Searches the index for documents matching the given query. But only returns the number of matches found. """ pass DefaultIndexAdapter = import_string( get_setting( 'DEFAULT_INDEX_ADAPTER', default='sellmo.core.indexing.adapters.database.DatabaseIndexAdapter' ) )
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from django.utils.translation import ugettext_lazy as _ from sellmo.conf import get_setting import pycountry COUNTRY_CHOICES = [ (country.alpha2, country.name) for country in list(pycountry.countries) ] PHONE_NUMBER_ENABLED = get_setting('PHONE_NUMBER_ENABLED', default=True) PHONE_NUMBER_REQUIRED = get_setting('PHONE_NUMBER_REQUIRED', default=False) NAME_PREFIX_ENABLED = get_setting('NAME_PREFIX_ENABLED', default=False) NAME_PREFIX_REQUIRED = get_setting('NAME_PREFIX_REQUIRED', default=True) NAME_PREFIX_CHOICES = get_setting( 'NAME_PREFIX_CHOICES', default=[ ('sir', _("sir")), ('madame', _("madam")), ] )
from .pipe import pipe, PipeError PARAMS = { 'pdf': { 'size': 'A4', 'orientation': 'portrait', 'margin': '1cm', 'zoom': 1.0, }, 'png': { 'viewport': '800x800' } } phantomjs_params = get_setting('PARAMS', default=PARAMS, prefix='PHANTOMJS') phantomjs_executable = get_setting('PARAMS', default='phantomjs', prefix='PHANTOMJS') class PhantomJSReportGenerator(AbstractReportGenerator): @property def input_formats(self): return ['html'] @property def output_formats(self): return ['pdf', 'png']
def OrderNotificationMailWriter(self): return import_string( get_setting( 'INVOICE_MAIL_WRITER', default='%s.internal.writers.OrderNotificationMailWriter' % __name__))
super(ReportGenerators, self).__init__( [ import_string(generator) for generator in generators ] ) self.input_formats = {} self.output_formats = {} # Map generators for generator in self: if not generator.input_formats or not generator.output_formats: raise ImproperlyConfigured( "Generator needs input and output formats" ) # Map to input formats for frmt in generator.input_formats: if frmt not in self.input_formats: self.input_formats[frmt] = set() self.input_formats[frmt].add(generator) # Map to output formats for frmt in generator.output_formats: if frmt not in self.output_formats: self.output_formats[frmt] = set() self.output_formats[frmt].add(generator) generators = ReportGenerators(get_setting('REPORT_GENERATORS', default=[]))
def get_model(self): pass def get_index_field(self, attribute): return indexing.ModelField, [self.get_model()], {} def get_formfield(self, label, required, choices=None): return forms.ModelChoiceField, [self.get_model().objects.all()], {"label": label, "required": required} def _attribute_types(value): types = {} for typ in value: if isinstance(typ, basestring): typ = import_string(typ)() types[typ.key] = typ return types types = _attribute_types( get_setting( "ATTRIBUTE_TYPES", default=[ "sellmo.contrib.attribute.types.StringAttributeType", "sellmo.contrib.attribute.types.IntegerAttributeType", "sellmo.contrib.attribute.types.FloatAttributeType", "sellmo.contrib.attribute.types.BooleanAttributeType", ], ) )
# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from sellmo.conf import get_setting # days or hours TIME_DEFINED_IN = get_setting('TIME_UNIT', default='days')
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from django.core.cache import caches from django.utils.module_loading import import_string from sellmo.conf import get_setting from sellmo.caching.constants import DEFAULT_CACHE_ALIAS from .base import BaseCache CACHES = get_setting('CACHES', default={ 'django.core.cache.backends.locmem.LocMemCache': 'sellmo.caching.caches.locmem.LocMemCache', 'django_redis.cache.RedisCache': 'sellmo.caching.caches.redis.RedisCache', }) backend_cls = type(caches[DEFAULT_CACHE_ALIAS]) def cache_factory(): dotted_path = '%s.%s' % (backend_cls.__module__, backend_cls.__name__) if dotted_path in CACHES: return import_string(CACHES[dotted_path]) return BaseCache class Cache(cache_factory()):
class ReportGenerators(list): def __init__(self, generators): super(ReportGenerators, self).__init__( [import_string(generator) for generator in generators]) self.input_formats = {} self.output_formats = {} # Map generators for generator in self: if not generator.input_formats or not generator.output_formats: raise ImproperlyConfigured( "Generator needs input and output formats") # Map to input formats for frmt in generator.input_formats: if frmt not in self.input_formats: self.input_formats[frmt] = set() self.input_formats[frmt].add(generator) # Map to output formats for frmt in generator.output_formats: if frmt not in self.output_formats: self.output_formats[frmt] = set() self.output_formats[frmt].add(generator) generators = ReportGenerators(get_setting('REPORT_GENERATORS', default=[]))
# modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from sellmo.conf import get_setting SEARCH_FIELDS = get_setting('SEARCH_FIELDS', default=[]) SEARCH_URL_PARAM = get_setting('SEARCH_URL_PARAM', default='search')
# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from sellmo.conf import get_setting MAX_TIER_ATTRIBUTES = get_setting('MAX_TIER_ATTRIBUTES', default=3)