Lengow/orders/views.py

54 lines
1.9 KiB
Python
Raw Normal View History

2016-02-14 20:40:28 +00:00
from django.core.urlresolvers import reverse_lazy
from django.views.generic import ListView, DetailView, DeleteView, UpdateView, CreateView
2016-02-14 16:51:54 +00:00
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
2016-02-14 16:51:54 +00:00
2016-02-14 20:40:28 +00:00
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']
2016-02-14 16:51:54 +00:00
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