On a fini le requis, allons dans l'optionnel

This commit is contained in:
Michel Roux 2016-02-14 17:27:22 +01:00
parent e8de4fafc2
commit 66cc4cd008
5 changed files with 69 additions and 15 deletions

View File

@ -20,5 +20,6 @@ from orders import views
urlpatterns = [ urlpatterns = [
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
url(r'^$', views.IndexView.as_view(), name='index'), url(r'^$', views.OrderIndexView.as_view(), name='index'),
url(r'^(?P<pk>[-\w]+)/$', views.OrderDetailView.as_view(), name='detail'),
] ]

View File

@ -6,6 +6,8 @@ from django.db import models
class Order(models.Model): class Order(models.Model):
# TODO: Revoir les max_length et null (difficile d'affirmer une limite précise avec le XML) # TODO: Revoir les max_length et null (difficile d'affirmer une limite précise avec le XML)
# TODO: Faire des sous-modèles pour gérer de plus d'informations venant du XML comme les adresses,
# le tracking ou le panier
marketplace = models.CharField(max_length=10) marketplace = models.CharField(max_length=10)
idFlux = models.IntegerField() idFlux = models.IntegerField()
order_id = models.CharField(max_length=20, primary_key=True) order_id = models.CharField(max_length=20, primary_key=True)

View File

@ -1,8 +1,13 @@
from django.views.generic import ListView from django.views.generic import ListView, DetailView
from orders.models import Order from orders.models import Order
class IndexView(ListView): class OrderIndexView(ListView):
template_name = 'orders/order/index.html' template_name = 'orders/order/index.html'
model = Order model = Order
class OrderDetailView(DetailView):
template_name = 'orders/order/detail.html'
model = Order

View File

@ -0,0 +1,34 @@
{% extends 'orders/base.html' %}
{% block title %}Detail for {{ object.order_id }}'s order{% endblock %}
{% block body %}
<div class="container-fluid">
<h2>Order {{ object.order_id }}</h2>
<ul>
<li>Marketplace : {{ object.marketplace }}</li>
<li>Id flux : {{ object.idFlux }}</li>
<li>Mr id : {{ object.order_mrid }}</li>
<li>Reference id : {{ object.order_refid }}</li>
<li>External id : {{ object.order_external_id }}</li>
<li>Purchase date : {{ object.order_purchase }}</li>
<li>Amount : {{ object.order_amount }}</li>
<li>Tax : {{ object.order_tax }}</li>
<li>Shipping : {{ object.order_shipping }}</li>
<li>Commission : {{ object.order_commission }}</li>
<li>Processing fee : {{ object.order_processing_fee }}</li>
<li>Comments : {{ object.order_comments }}</li>
<li>Customer id : {{ object.customer_id }}</li>
<li>Ip : {{ object.order_ip }}</li>
<li>Number of items : {{ object.order_items }}</li>
</ul>
<p>
<a href="/">
<i class="glyphicon glyphicon-chevron-left"></i> Back
</a>
</p>
</div>
{% endblock %}

View File

@ -9,28 +9,32 @@
<table class="table table-bordered table-hover"> <table class="table table-bordered table-hover">
<thead> <thead>
<tr> <tr>
<th></th> <th><i class="glyphicon glyphicon-search"></i></th>
<th>Order Id</th> <th>Order id</th>
<th>Marketplace</th> <th>Marketplace</th>
<th>Id Flux</th> <th>Id flux</th>
<th>Purchase Date</th> <th>Purchase date</th>
<th>Amount</th> <th>Amount</th>
<th>Tax</th> <th>Tax</th>
<th>Shipping</th> <th>Shipping</th>
<th>Commission</th> <th>Commission</th>
<th>Processing Fee</th> <th>Processing fee</th>
<th>Comments</th> <th>Comments</th>
<th>Customer Id</th> <th>Customer id</th>
<th>Ip</th> <th>Ip</th>
<th>Nb Items</th> <th>Nb items</th>
<th>Edit</th> <th><i class="glyphicon glyphicon-pencil"></i></th>
<th>Delete</th> <th><i class="glyphicon glyphicon-trash"></i></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for order in object_list %} {% for order in object_list %}
<tr> <tr>
<td></td> <td>
<a href="/{{ order.order_id }}">
<i class="glyphicon glyphicon-search"></i>
</a>
</td>
<td>{{ order.order_id }}</td> <td>{{ order.order_id }}</td>
<td>{{ order.marketplace }}</td> <td>{{ order.marketplace }}</td>
<td>{{ order.idFlux }}</td> <td>{{ order.idFlux }}</td>
@ -44,8 +48,16 @@
<td>{{ order.customer_id }}</td> <td>{{ order.customer_id }}</td>
<td>{{ order.order_ip }}</td> <td>{{ order.order_ip }}</td>
<td>{{ order.order_items }}</td> <td>{{ order.order_items }}</td>
<td></td> <td>
<td></td> <a href="/{{ order.order_id }}/edit">
<i class="glyphicon glyphicon-pencil"></i>
</a>
</td>
<td>
<a href="/{{ order.order_id }}/delete">
<i class="glyphicon glyphicon-trash"></i>
</a>
</td>
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>