Exemple #1
0
    def process_response(self, request, response):

        if not SERVER_CACHE_DIR or not hasattr(request, '_server_cache'):
            return response

        if 'argsfunc' in request._server_cache and request._server_cache['argsfunc']:
            func = request._server_cache['argsfunc']
        elif SERVER_CACHE_ARGS_FUNC:
            func = import_item(SERVER_CACHE_ARGS_FUNC)
        else:
            func = None

        if callable(func):
            strargs = func(request, response)
        else:
            strargs = ''

        if 'set_cookie' in request._server_cache:
            if strargs != '':
                response.set_cookie('scas', strargs, 60 * 60 * 24 * 360)
            else:
                response.delete_cookie('scas')
            return response

        if not self._should_update_cache(request, response):
            return response

        filename = "cache{0}.html".format(strargs)
        dirname = os.path.join(SERVER_CACHE_DIR, request.get_full_path()[1:])

        path_to_file = os.path.join(dirname, filename)

        try:
            os.makedirs(dirname)
        except OSError:
            pass

        f = open(path_to_file, 'w')
        f.write(response.content)
        f.close()
        return response
Exemple #2
0
from django.conf.urls import url

from qshop.qshop_settings import CART_ORDER_VIEW, ENABLE_QSHOP_DELIVERY, ENABLE_PROMO_CODES

from .views import (OrderDetailView, AjaxOrderDetailView, CartDetailView,
                    add_to_cart, cart_order_cancelled, cart_order_error,
                    cart_order_success, remove_from_cart, update_cart)

if CART_ORDER_VIEW:
    from sitemenu import import_item
    qshop_order_view = import_item(CART_ORDER_VIEW)

if ENABLE_PROMO_CODES:
    from .views import ApplyPromoView

urlpatterns = [
    url(r'^$', CartDetailView.as_view(), name='cart'),
    url(r'^add/(?P<product_id>\d+)/$', add_to_cart, name='add_to_cart'),
    url(r'^remove/(?P<item_id>\d+)/$',
        remove_from_cart,
        name='remove_from_cart'),
    url(r'^update/$', update_cart, name='update_cart'),
    url(r'^order/success/$', cart_order_success, name='cart_order_success'),
    url(r'^order/cancelled/$',
        cart_order_cancelled,
        name='cart_order_cancelled'),
    url(r'^order/error/$', cart_order_error, name='cart_order_error'),
    url(r'^order/cancelled/(?P<order_id>\d+)/$',
        cart_order_cancelled,
        name='cart_order_cancelled'),
]
Exemple #3
0
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render, get_object_or_404
from django.views.generic import CreateView, TemplateView, FormView
from qshop import qshop_settings
from .cart import ItemTooMany
from .forms import OrderForm
from ..models import Product
from .models import Order
from qshop.qshop_settings import CART_CLASS

if CART_CLASS:
    from sitemenu import import_item
    Cart = import_item(CART_CLASS)
else:
    from .cart import Cart

def add_to_cart(request, product_id):
    cart = Cart(request)

    quantity = request.GET.get('quantity', 1)
    variation_id = request.GET.get('variation', None)
    variation_quantities = {}

    if not variation_id:
        variation_quantity_re = re.compile('^variation_quantity_(\d+)$')
        for item in request.GET:
            match = variation_quantity_re.match(item)
            if match:
Exemple #4
0
class ProductToParameter(
        import_item(PRODUCT_TO_PARAMETER_CLASS)
        if PRODUCT_TO_PARAMETER_CLASS else ProductToParameterAbstract):
    pass
Exemple #5
0
class Parameter(
        import_item(PARAMETER_CLASS) if PARAMETER_CLASS else ParameterAbstract
):
    pass
Exemple #6
0
class ProductImage(
        import_item(PRODUCT_IMAGE_CLASS)
        if PRODUCT_IMAGE_CLASS else ProductImageAbstract):
    pass
Exemple #7
0
class ProductVariationValue(
        import_item(VARIATION_VALUE_CLASS)
        if VARIATION_VALUE_CLASS else ProductVariationValueAbstract):
    pass
Exemple #8
0
from django.urls import reverse
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
from django.utils.safestring import mark_safe
from easy_thumbnails.fields import ThumbnailerImageField

from sitemenu.sitemenu_settings import MENUCLASS
from sitemenu import import_item
from sitemenu.helpers import upload_to_slugify
from .qshop_settings import (PRODUCT_CLASS, VARIATION_CLASS,
                             VARIATION_VALUE_CLASS, PRODUCT_IMAGE_CLASS,
                             PARAMETERS_SET_CLASS, PARAMETER_CLASS,
                             PARAMETER_VALUE_CLASS, PRODUCT_TO_PARAMETER_CLASS,
                             CURRENCY_CLASS, LOAD_ADDITIONAL_MODELS)

Menu = import_item(MENUCLASS)


class PricingModel(object):
    def _get_price(self):
        return self.price

    def _get_discount_price(self):
        return self.discount_price

    def has_discount(self):
        if self._get_discount_price():
            return True
        else:
            return False
Exemple #9
0
from django.template.loader import render_to_string
import datetime
#from overloadable_functions import count_delivery_price

from django.conf import settings

import models
from ..models import Currency
from qshop import qshop_settings

from sitemenu import import_item
count_delivery_price = import_item(qshop_settings.CART_DELIVERY_FUNCTION)

CART_ID = '%s-cart' % settings.ROOT_URLCONF


if not hasattr(settings, 'SITE_URL'):
    raise Exception('No SITE_URL defined in settings! (SITE_URL="http://example.com")')


class ItemAlreadyExists(Exception):
    pass


class ItemDoesNotExist(Exception):
    pass


class ItemTooMany(Exception):
    pass
Exemple #10
0
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.urls import reverse
from django.utils.safestring import mark_safe
from django.http import HttpResponseRedirect

from sitemenu import import_item
from ..models import Currency
from ..models import Product, ProductVariation

from qshop import qshop_settings

PAYMENT_CLASSES = {}
if qshop_settings.ENABLE_PAYMENTS:
    for item in qshop_settings.PAYMENT_METHODS_ENABLED:
        PAYMENT_CLASSES[item] = import_item(qshop_settings.PAYMENT_METHODS_CLASSES_PATHS[item])
# Menu = import_item(MENUCLASS)


class Cart(models.Model):
    date_added = models.DateTimeField(_('creation date'), auto_now_add=True)
    date_modified = models.DateTimeField(_('modification date'), auto_now=True)
    checked_out = models.BooleanField(default=False, verbose_name=_('checked out'))
    discount = models.PositiveSmallIntegerField(_('discount'), default=0)

    class Meta:
        verbose_name = _('cart')
        verbose_name_plural = _('carts')
        ordering = ('-date_modified',)

    def __str__(self):
Exemple #11
0
class Item(
        import_item(qshop_settings.ITEM_CLASS)
        if qshop_settings.ITEM_CLASS else ItemAbstract):
    pass
Exemple #12
0
from django import template
from django.utils.safestring import mark_safe
#from ..forms import FeedbackFormForm
from sitemenu.sitemenu_settings import PLUGIN_FEEDBACK_FORM
from sitemenu import import_item
FeedbackFormForm = import_item(PLUGIN_FEEDBACK_FORM)

#from django.contrib import messages
#from django.utils.translation import ugettext_lazy as _
from django.template.loader import render_to_string
register = template.Library()



@register.simple_tag(takes_context=True)
def render_feedback_form(context):
    request = context['request']
    #user = request.user

    form = FeedbackFormForm(request)
    return mark_safe("<div class='j_feedback_form_container'>" + render_to_string('sitemenu/plugins/feedback_form/feedback_form.html', {'form': form}, request=request) + "</div>")
Exemple #13
0
from qshop.qshop_settings import CART_ORDER_FORM

if CART_ORDER_FORM:
    from sitemenu import import_item
    OrderForm = import_item(CART_ORDER_FORM)
else:
    from django import forms
    from .models import Order
    from ..mails import sendMail
    from django.utils.translation import ugettext as _

    class OrderForm(forms.ModelForm):
        class Meta:
            model = Order
            exclude = ('date_added', 'status', 'manager_comments', 'cart',
                       'cart_text')

        def save(self, cart, *args, **kwargs):
            kwargs['commit'] = False
            order = super(OrderForm, self).save(*args, **kwargs)

            order.cart = cart.cart
            order.cart_text = cart.as_table(standalone=True)

            order.save()

            if hasattr(order, 'email'):
                sendMail('order_sended',
                         variables={
                             'order': order,
                         },
Exemple #14
0
from qshop.qshop_settings import CART_ORDER_FORM, ENABLE_QSHOP_DELIVERY, DELIVERY_REQUIRED, ENABLE_PAYMENTS, ENABLE_PROMO_CODES, PROMO_CODE_FORM
from django import forms

if CART_ORDER_FORM:
    from sitemenu import import_item
    OrderForm = import_item(CART_ORDER_FORM)

elif not ENABLE_QSHOP_DELIVERY:
    from .forms_simple import OrderBaseForm

    class OrderForm(OrderBaseForm):
        pass
else:
    from .forms_extended import OrderExtendedForm

    class OrderForm(OrderExtendedForm):
        pass


if ENABLE_PROMO_CODES:
    if PROMO_CODE_FORM:
        from sitemenu import import_item
        ApplyPromoForm = import_item(PROMO_CODE_FORM)
    else:
        from .forms_simple import ApplyPromoFormBase

        class ApplyPromoForm(ApplyPromoFormBase):
            pass
Exemple #15
0
from qshop.qshop_settings import CART_ORDER_FORM

if CART_ORDER_FORM:
    from sitemenu import import_item
    OrderForm = import_item(CART_ORDER_FORM)
else:
    from django import forms
    from .models import Order
    from ..mails import sendMail
    from django.utils.translation import ugettext as _

    class OrderForm(forms.ModelForm):

        class Meta:
            model = Order
            exclude = ('date_added', 'status', 'manager_comments', 'cart', 'cart_text')

        def save(self, cart, *args, **kwargs):
            kwargs['commit'] = False
            order = super(OrderForm, self).save(*args, **kwargs)

            order.cart = cart.cart
            order.cart_text = cart.as_table(standalone=True)

            order.save()

            if hasattr(order, 'email'):
                sendMail(
                    'order_sended',
                    variables={
                        'order': order,
Exemple #16
0
class FeedbackForm(
        import_item(PLUGIN_FEEDBACK_MODEL)
        if PLUGIN_FEEDBACK_MODEL else FeedbackFormBase):
    pass
Exemple #17
0
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render, get_object_or_404

from .cart import Cart, ItemTooMany
from ..models import Product
from .forms import OrderForm
from .models import Order

from qshop.qshop_settings import CART_ORDER_VIEW

if CART_ORDER_VIEW:
    from sitemenu import import_item
    qshop_order_view = import_item(CART_ORDER_VIEW)


def add_to_cart(request, product_id):
    cart = Cart(request)

    quantity = request.GET.get('quantity', 1)
    variation_id = request.GET.get('variation', None)
    variation_quantities = {}

    if not variation_id:
        variation_quantity_re = re.compile('^variation_quantity_(\d+)$')
        for item in request.GET:
            match = variation_quantity_re.match(item)
            if match:
                try:
Exemple #18
0
class Product(
        import_item(PRODUCT_CLASS) if PRODUCT_CLASS else ProductAbstract):
    pass
Exemple #19
0
from decimal import Decimal
from django.db import models
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from qshop.mails import sendMail
from qshop import qshop_settings
from sitemenu import import_item

from ..models import Currency, Product, ProductVariation

PAYMENT_CLASSES = {}
if qshop_settings.ENABLE_PAYMENTS:
    for item in qshop_settings.PAYMENT_METHODS_ENABLED:
        PAYMENT_CLASSES[item] = import_item(
            qshop_settings.PAYMENT_METHODS_CLASSES_PATHS[item])
# Menu = import_item(MENUCLASS)

if qshop_settings.ENABLE_PROMO_CODES:
    from qshop.models import PromoCode


class Cart(models.Model):
    date_added = models.DateTimeField(_('creation date'), auto_now_add=True)
    date_modified = models.DateTimeField(_('modification date'), auto_now=True)
    checked_out = models.BooleanField(default=False,
                                      verbose_name=_('checked out'))
    discount = models.DecimalField(_('discount'),
                                   max_digits=9,
                                   decimal_places=2,
                                   default=0)
Exemple #20
0
class ProductVariation(
        import_item(VARIATION_CLASS)
        if VARIATION_CLASS else ProductVariationAbstract):
    pass
Exemple #21
0
 class DeliveryCountry(import_item(qshop_settings.DELIVERY_COUNTRY_CLASS)):
     pass
Exemple #22
0
class ParametersSet(
        import_item(PARAMETERS_SET_CLASS)
        if PARAMETERS_SET_CLASS else ParametersSetAbstract):
    pass
Exemple #23
0
 class DeliveryType(
         import_item(qshop_settings.DELIVERY_TYPE_CLASS)
         if qshop_settings.DELIVERY_TYPE_CLASS else DeliveryTypeAbstract):
     pass
Exemple #24
0
class ParameterValue(
        import_item(PARAMETER_VALUE_CLASS)
        if PARAMETER_VALUE_CLASS else ParameterValueAbstract):
    pass
Exemple #25
0
 class DeliveryCalculation(
         import_item(qshop_settings.DELIVERY_CALCULATION_CLASS)
         if qshop_settings.DELIVERY_CALCULATION_CLASS else
         DeliveryCalculationAbstract):
     pass
Exemple #26
0
class Currency(
        import_item(CURRENCY_CLASS) if CURRENCY_CLASS else CurrencyAbstract):
    pass
Exemple #27
0
 class PickupPoint(
         import_item(qshop_settings.PICKUP_POINT_CLASS)
         if qshop_settings.PICKUP_POINT_CLASS else PickupPointAbstract):
     pass
Exemple #28
0
from .admin_forms import ProductToParameterFormset, CategoryForm, PriceForm, ProductAdminForm, ProductToParameterForm
from .admin_filters import ProductCategoryListFilter

from django.conf import settings
from django.shortcuts import render
from django.contrib.admin import helpers
from django.http import HttpResponseRedirect
from sitemenu import import_item
from sitemenu.sitemenu_settings import MENUCLASS
from decimal import Decimal
from django.utils.translation import ugettext_lazy as _

from qshop.qshop_settings import ENABLE_PROMO_CODES

Menu = import_item(MENUCLASS)

parent_classes = {
    'ModelAdmin': admin.ModelAdmin,
    'TabularInline': admin.TabularInline,
    'StackedInline': admin.StackedInline,
}
if 'modeltranslation' in settings.INSTALLED_APPS:
    from modeltranslation.admin import TranslationAdmin, TranslationTabularInline, TranslationStackedInline
    USE_TRANSLATION = True
    parent_classes_translation = {
        'ModelAdmin': TranslationAdmin,
        'TabularInline': TranslationTabularInline,
        'StackedInline': TranslationStackedInline,
    }
else:
Exemple #29
0
class Order(
        import_item(qshop_settings.CART_ORDER_CLASS)
        if qshop_settings.CART_ORDER_CLASS else OrderAbstractDefault):
    pass
Exemple #30
0
from django.contrib.sitemaps import Sitemap
from sitemenu.sitemenu_settings import MENUCLASS
from sitemenu import import_item

Menu = import_item(MENUCLASS)


class SiteMenuSitemap(Sitemap):
    def items(self):
        return Menu.objects.filter(enabled=True)

    def lastmod(self, obj):
        if obj.page_type == 'indx':
            return None
        return obj.date_modified

    def location(self, obj):
        return obj.get_absolute_url()
Exemple #31
0
from decimal import Decimal

from django.conf import settings
from django.template.loader import render_to_string

from . import models
from ..models import Currency
from qshop import qshop_settings

from sitemenu import import_item
count_delivery_price = import_item(qshop_settings.CART_DELIVERY_FUNCTION)

CART_ID = '%s-cart' % settings.ROOT_URLCONF

if not hasattr(settings, 'SITE_URL'):
    raise Exception(
        'No SITE_URL defined in settings! (SITE_URL="http://example.com")')


class ItemAlreadyExists(Exception):
    pass


class ItemDoesNotExist(Exception):
    pass


class ItemTooMany(Exception):
    pass

Exemple #32
0
from django.conf import settings
from django.urls import reverse
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
from django.utils.safestring import mark_safe
from easy_thumbnails.fields import ThumbnailerImageField

from sitemenu.sitemenu_settings import MENUCLASS
from sitemenu import import_item
from sitemenu.helpers import upload_to_slugify
from .qshop_settings import (
    PRODUCT_CLASS, VARIATION_CLASS, VARIATION_VALUE_CLASS, PRODUCT_IMAGE_CLASS, PARAMETERS_SET_CLASS,
    PARAMETER_CLASS, PARAMETER_VALUE_CLASS, PRODUCT_TO_PARAMETER_CLASS, CURRENCY_CLASS, LOAD_ADDITIONAL_MODELS
)

Menu = import_item(MENUCLASS)


class PricingModel(object):
    def _get_price(self):
        return self.price

    def _get_discount_price(self):
        return self.discount_price

    def has_discount(self):
        if self._get_discount_price():
            return True
        else:
            return False
Exemple #33
0
class PromoCode(
        import_item(PROMO_CODE_CLASS)
        if PROMO_CODE_CLASS else PromoCodeAbstract):
    pass