1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 01:48:21 +02:00

Implement a new type of note (see #45)

This commit is contained in:
Yohann D'ANELLO
2020-03-31 01:03:30 +02:00
parent c8854cf45d
commit c384ee02eb
14 changed files with 326 additions and 21 deletions

View File

@ -4,11 +4,13 @@
import unicodedata
from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.db import models
from django.utils.translation import gettext_lazy as _
from polymorphic.models import PolymorphicModel
from member.models import Club
"""
Defines each note types
@ -174,6 +176,40 @@ class NoteSpecial(Note):
return self.special_type
class NoteActivity(Note):
"""
A :model:`note.Note` for accounts that are not attached to a user neither to a club,
that only need to store and transfer money (notes for activities, departments, ...)
"""
note_name = models.CharField(
verbose_name=_('name'),
max_length=255,
unique=True,
)
club = models.ForeignKey(
Club,
on_delete=models.PROTECT,
related_name="linked_notes",
verbose_name=_("club"),
)
controller = models.ForeignKey(
User,
on_delete=models.PROTECT,
related_name="+",
verbose_name=_("controller"),
)
class Meta:
verbose_name = _("common note")
verbose_name_plural = _("common notes")
def __str__(self):
return self.note_name
class Alias(models.Model):
"""
points toward a :model:`note.NoteUser` or :model;`note.NoteClub` instance.