예제 #1
0
파일: views.py 프로젝트: b-dev/plata
from django import forms
from django.contrib import messages
from django.core.exceptions import ValidationError
from django.db.models import ObjectDoesNotExist
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import ugettext as _
from django.views import generic

from plata.contact.models import Contact
from plata.discount.models import Discount
from plata.shop.views import Shop
from plata.shop.models import Order

from simple.models import Product

shop = Shop(Contact, Order, Discount)

product_list = generic.ListView.as_view(
    queryset=Product.objects.filter(is_active=True),
    template_name="product/product_list.html",
)


class OrderItemForm(forms.Form):
    quantity = forms.IntegerField(label=_("quantity"),
                                  initial=1,
                                  min_value=1,
                                  max_value=100)


def product_detail(request, object_id):
예제 #2
0
파일: urls.py 프로젝트: b-dev/plata
from django.conf.urls import include, url
from django.contrib import admin
from django.shortcuts import redirect

from plata.contact.models import Contact
from plata.discount.models import Discount
from plata.shop.models import Order
from plata.shop.views import Shop
from testapp import views

admin.autodiscover()

shop = Shop(contact_model=Contact, order_model=Order, discount_model=Discount)

urlpatterns = [
    url(r"^$",
        lambda request: redirect("plata_product_list"),
        name="plata_home"),
    url(r"", include(shop.urls)),
    url(r"^products/$", views.product_list, name="plata_product_list"),
    url(r"^products/(\d+)/$",
        views.product_detail,
        name="plata_product_detail"),
    url(r"^admin/", admin.site.urls),
    url(r"^reporting/", include("plata.reporting.urls")),
]