hackens-orga/hackens_orga/backend/models.py
2023-01-16 18:50:12 +01:00

33 lines
1 KiB
Python

from datetime import date
from django.contrib.auth.models import User
from django.db import models
class BudgetLine(models.Model):
amount = models.DecimalField(max_digits=12, decimal_places=2)
author = models.ForeignKey("Agent", on_delete=models.PROTECT)
comment = models.TextField(blank=True)
date = models.DateField(default=date.today)
facture = models.FileField(upload_to="factures/", null=True, blank=True)
group = models.ForeignKey("BudgetGroup", on_delete=models.CASCADE)
title = models.CharField(max_length=255)
def __str__(self):
return f"BudgetLine_{self.title}_{self.amount}"
class Agent(models.Model):
name = models.CharField(max_length=255)
user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
def __str__(self):
return f"Agent_{self.name}"
class BudgetGroup(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True)
def __str__(self):
return f"BudgetGroup_{self.name}"