Dates on sales
This commit is contained in:
parent
db349745be
commit
60009517c3
4 changed files with 32 additions and 1 deletions
24
comet/account/migrations/0004_auto_20181214_1844.py
Normal file
24
comet/account/migrations/0004_auto_20181214_1844.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 2.1.4 on 2018-12-14 18:44
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('account', '0003_auto_20181213_2248'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='sale',
|
||||
name='date',
|
||||
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='Date'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='sale',
|
||||
name='price',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=4, verbose_name='Prix (€)'),
|
||||
),
|
||||
]
|
|
@ -1,5 +1,7 @@
|
|||
from django.db import models
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
class Account(models.Model):
|
||||
"""Account for a member."""
|
||||
balance = models.DecimalField(
|
||||
|
@ -27,6 +29,7 @@ class Sale(models.Model):
|
|||
)
|
||||
account = models.ForeignKey(Account, on_delete=models.SET_NULL, null=True)
|
||||
title = models.CharField(max_length=255, verbose_name="Intitulé")
|
||||
date = models.DateTimeField(verbose_name="Date", default=timezone.now)
|
||||
|
||||
class Article(models.Model):
|
||||
"""An article which can be sold."""
|
||||
|
|
|
@ -5,14 +5,17 @@
|
|||
<a class="button" href="{% url 'reset' account.pk %}">Remettre le solde à 0</a>
|
||||
<a class="button" href="{% url 'refill' account.pk %}">Recharger le compte</a>
|
||||
<br/>
|
||||
<br/>
|
||||
<h3>Ventes</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Titre</th>
|
||||
<th>Prix</th>
|
||||
</tr>
|
||||
{% for sale in account.sale_set.all %}
|
||||
{% for sale in sales %}
|
||||
<tr>
|
||||
<td>{{sale.date|date:'d/m/Y'}}</td>
|
||||
<td>{{sale.title}}</td>
|
||||
<td>{{sale.price}}</td>
|
||||
</tr>
|
||||
|
|
|
@ -126,6 +126,7 @@ def search(request):
|
|||
@login_required
|
||||
def account(request, pk):
|
||||
account = get_object_or_404(Account, pk=pk)
|
||||
sales = account.sale_set.order_by('-pk')
|
||||
return render(
|
||||
request,
|
||||
'account/balance.html',
|
||||
|
|
Loading…
Reference in a new issue