django-refunds/refunding/models.py

33 lines
911 B
Python

from django.db import models
from django.conf import settings
AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
class Refund(models.Model):
title = models.CharField(max_length=100)
date = models.DateField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
user = models.ForeignKey(
AUTH_USER_MODEL,
on_delete=models.PROTECT
)
class Payment(models.Model):
title = models.CharField(max_length=100)
date = models.DateField()
value = models.IntegerField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
user = models.ForeignKey(
AUTH_USER_MODEL,
on_delete=models.PROTECT
)
refund = models.ForeignKey(
Refund,
on_delete=models.SET_NULL,
null=True,
blank=True
)