1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-27 11:58:54 +02:00

Use model polymorphism

This commit is contained in:
Alexandre Iooss
2019-07-17 11:17:50 +02:00
parent 14282427af
commit 5110d6a16b
5 changed files with 20 additions and 13 deletions

View File

@ -7,17 +7,16 @@ from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.translation import gettext_lazy as _
from polymorphic.models import PolymorphicModel
"""
Defines each note types
"""
class Note(models.Model):
class Note(PolymorphicModel):
"""
An model, use to add transactions capabilities
We do not use an abstract model to simplify the transfer between two notes.
"""
balance = models.IntegerField(
verbose_name=_('account balance'),
@ -57,6 +56,9 @@ class NoteUser(Note):
verbose_name = _("one's note")
verbose_name_plural = _("users note")
def __str__(self):
return _("%(user)s's note") % {'user': str(self.user)}
class NoteClub(Note):
"""

View File

@ -26,6 +26,7 @@ class TransactionTemplate(models.Model):
)
amount = models.PositiveIntegerField(
verbose_name=_('amount'),
help_text=_('in centimes'),
)
template_type = models.CharField(
verbose_name=_('type'),