Esempio n. 1
0
 def EditPurchaseForm(self): # NOQA
     return import_string(
         get_setting(
             'EDIT_PURCHASE_FORM',
             default='%s.internal.forms.EditPurchaseForm' % __name__
         )
     )
Esempio n. 2
0
 def UserChangeForm(self):
     return import_string(
         get_setting(
             'USER_CHANGE_FORM',
             default='%s.internal.forms.UserChangeForm' % __name__
         )
     )
Esempio n. 3
0
 def AddToCartForm(self): # NOQA
     return import_string(
         get_setting(
             'ADD_TO_CART_FORM',
             default='%s.internal.forms.AddToCartForm' % __name__
         )
     )
Esempio n. 4
0
 def PaymentMethodForm(self):
     return import_string(
         get_setting(
             'PAYMENT_METHOD_FORM',
             default='%s.internal.forms.PaymentMethodForm' % __name__
         )
     )
Esempio n. 5
0
 def AuthenticationForm(self):
     return import_string(
         get_setting(
             'AUTHENTICATION_FORM',
             default='django.contrib.auth.forms.AuthenticationForm'
         )
     )
Esempio n. 6
0
 def UserCreationForm(self):
     return import_string(
         get_setting(
             'USER_CREATION_FORM',
             default='%s.internal.forms.UserCreationForm' % __name__
         )
     )
Esempio n. 7
0
 def PasswordResetForm(self):
     return import_string(
         get_setting(
             'PASSWORD_RESET_FORM',
             default='django.contrib.auth.forms.PasswordResetForm'
         )
     )
Esempio n. 8
0
 def IDealIssuerForm(self):
     return import_string(
         get_setting(
             'MOLLIE_IDEAL_ISSUER_FORM',
             default='%s.internal.forms.IDealIssuerForm' % __name__
         )
     )
Esempio n. 9
0
 def InvoiceReportWriter(self):
     return import_string(
         get_setting(
             'INVOICE_REPORT_WRITER',
             default='%s.internal.writers.InvoiceReportWriter' % __name__
         )
     )
Esempio n. 10
0
 def ShippingNotificationMailWriter(self):
     return import_string(
         get_setting(
             'SHIPPING_NOTIFICATION_MAIL_WRITER',
             default='%s.internal.writers.ShippingNotificationMailWriter' %
             __name__
         )
     )
Esempio n. 11
0
 def OrderNotificationMailWriter(self):
     return import_string(
         get_setting(
             'INVOICE_MAIL_WRITER',
             default='%s.internal.writers.OrderNotificationMailWriter' %
             __name__
         )
     )
Esempio n. 12
0
 def OrderConfirmationReportWriter(self):
     return import_string(
         get_setting(
             'ORDER_CONFIRMATION_REPORT_WRITER',
             default='%s.internal.writers.OrderConfirmationReportWriter' %
             __name__
         )
     )
Esempio n. 13
0
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
Esempio n. 14
0
#
# 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}")
Esempio n. 15
0
#
# 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')
Esempio n. 16
0
            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", "
)
Esempio n. 17
0
 def OrderConfirmationMailWriter(self):
     return import_string(
         get_setting(
             'ORDER_CONFIRMATION_MAIL_WRITER',
             default='%s.internal.writers.OrderConfirmationMailWriter' %
             __name__))
Esempio n. 18
0


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(
Esempio n. 19
0
# 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'
Esempio n. 20
0
# 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'
    )
)
Esempio n. 21
0
 def ShippingNotificationMailWriter(self):
     return import_string(
         get_setting(
             'SHIPPING_NOTIFICATION_MAIL_WRITER',
             default='%s.internal.writers.ShippingNotificationMailWriter' %
             __name__))
Esempio n. 22
0
# 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)
Esempio n. 23
0
# 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()):
Esempio n. 24
0
# 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'
Esempio n. 25
0
 def RegistrationProcess(self):
     return import_string(get_setting('REGISTRATION_PROCESS'))
Esempio n. 26
0
# 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)
Esempio n. 27
0
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):
Esempio n. 28
0
# 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()))
Esempio n. 29
0
# 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)
Esempio n. 30
0
#
# 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)
Esempio n. 31
0
#
# 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])
Esempio n. 32
0
# 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)
Esempio n. 33
0
        """
        (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'
    )
)
Esempio n. 34
0
# 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")),
    ]
)
Esempio n. 35
0
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']
Esempio n. 36
0
 def OrderNotificationMailWriter(self):
     return import_string(
         get_setting(
             'INVOICE_MAIL_WRITER',
             default='%s.internal.writers.OrderNotificationMailWriter' %
             __name__))
Esempio n. 37
0
        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=[]))
Esempio n. 38
0
    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",
        ],
    )
)
Esempio n. 39
0
# 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')
Esempio n. 40
0
# 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()):
Esempio n. 41
0

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=[]))
Esempio n. 42
0
# 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')
Esempio n. 43
0
#
# 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)