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:
@ -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):
|
||||
"""
|
||||
|
@ -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'),
|
||||
|
Reference in New Issue
Block a user