Lengow/orders/views.py
2016-02-14 21:40:28 +01:00

54 lines
1.9 KiB
Python

from django.core.urlresolvers import reverse_lazy
from django.views.generic import ListView, DetailView, DeleteView, UpdateView, CreateView
from rest_framework import serializers, viewsets
from orders.models import Order
class OrderIndexView(ListView):
template_name = 'orders/order/index.html'
model = Order
class OrderDetailView(DetailView):
template_name = 'orders/order/detail.html'
model = Order
class OrderDeleteView(DeleteView):
template_name = 'orders/order/delete.html'
model = Order
success_url = reverse_lazy('index')
class OrderUpdateView(UpdateView):
template_name = 'orders/order/update.html'
model = Order
success_url = reverse_lazy('index')
fields = ['marketplace', 'idFlux', 'order_mrid', 'order_refid', 'order_external_id',
'order_purchase', 'order_amount', 'order_tax', 'order_shipping', 'order_commission',
'order_processing_fee', 'order_comments', 'customer_id', 'order_ip', 'order_items']
class OrderCreateView(CreateView):
template_name = 'orders/order/create.html'
model = Order
success_url = reverse_lazy('index')
fields = ['marketplace', 'idFlux', 'order_mrid', 'order_refid', 'order_external_id',
'order_purchase', 'order_amount', 'order_tax', 'order_shipping', 'order_commission',
'order_processing_fee', 'order_comments', 'customer_id', 'order_ip', 'order_items']
class OrderSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Order
fields = ('marketplace', 'idFlux', 'order_id', 'order_mrid', 'order_refid', 'order_external_id',
'order_purchase', 'order_amount', 'order_tax', 'order_shipping', 'order_commission',
'order_processing_fee', 'order_comments', 'customer_id', 'order_ip', 'order_items')
class OrderViewSet(viewsets.ModelViewSet):
queryset = Order.objects.all()
serializer_class = OrderSerializer