Commit cb4df015 authored by Claire Zuliani's avatar Claire Zuliani

Update : display batches

parent 2aa391b6
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-12-06 18:56
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('djangoldp_invoices', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='batch',
name='invoice',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='batches', to='djangoldp_invoices.ClientInvoice'),
),
migrations.AlterField(
model_name='task',
name='batch',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tasks', to='djangoldp_invoices.Batch'),
),
]
......@@ -65,7 +65,7 @@ class ClientInvoice(models.Model):
# Lot =========================================================
class Batch(models.Model):
invoice = models.ForeignKey(ClientInvoice, on_delete=models.CASCADE)
invoice = models.ForeignKey(ClientInvoice, on_delete=models.CASCADE, related_name='batches')
title = models.CharField(max_length=255)
htAmount = models.DecimalField(max_digits=11, decimal_places=2)
creationDate = models.DateField(auto_now_add=True)
......@@ -78,10 +78,10 @@ class Batch(models.Model):
)
def __str__(self):
return '{} ({} € HT)'.format(self.title, self.htAmount)
return '{} - {} ({} € HT)'.format(self.invoice.title, self.title, self.htAmount)
class Task(models.Model):
batch = models.ForeignKey(Batch, on_delete=models.CASCADE)
batch = models.ForeignKey(Batch, on_delete=models.CASCADE, related_name='tasks')
title = models.CharField(max_length=255)
htAmount = models.DecimalField(max_digits=11, decimal_places=2)
creationDate = models.DateField(auto_now_add=True)
......
......@@ -7,8 +7,8 @@ from .models import Batch
from .models import Task
urlpatterns = [
url(r'^client-invoices', LDPViewSet.urls(model=ClientInvoice)),
url(r'^freelance-invoices', LDPViewSet.urls(model=FreelanceInvoice)),
url(r'^batches', LDPViewSet.urls(model=Batch)),
url(r'^tasks', LDPViewSet.urls(model=Task)),
url(r'^freelance-invoices/', LDPViewSet.urls(model=FreelanceInvoice)),
url(r'^client-invoices/', LDPViewSet.urls(model=ClientInvoice, nested_fields=["batches"])),
url(r'^batches/', LDPViewSet.urls(model=Batch, nested_fields=["tasks"])),
url(r'^tasks/', LDPViewSet.urls(model=Task)),
]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment