mirror of https://gitlab.crans.org/bde/nk20
Clean up note app
This commit is contained in:
parent
a17c11cd70
commit
58d5b5a9ff
|
@ -0,0 +1,5 @@
|
||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
default_app_config = 'note.apps.NoteConfig'
|
|
@ -2,6 +2,7 @@ from django.contrib import admin
|
||||||
|
|
||||||
from .models import NoteClub, NoteSpec, NoteUser
|
from .models import NoteClub, NoteSpec, NoteUser
|
||||||
from .models import Alias
|
from .models import Alias
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
admin.site.register(NoteClub)
|
admin.site.register(NoteClub)
|
||||||
admin.site.register(NoteSpec)
|
admin.site.register(NoteSpec)
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class NoteConfig(AppConfig):
|
class NoteConfig(AppConfig):
|
||||||
name = 'note'
|
name = 'note'
|
||||||
|
verbose_name = _('note')
|
||||||
|
|
|
@ -21,42 +21,48 @@ class Alias(models.Model):
|
||||||
blank=False,
|
blank=False,
|
||||||
null=False,
|
null=False,
|
||||||
)
|
)
|
||||||
limit = models.Q(app_label="note", model="NoteUser") | models.Q(app_label="note",model="NoteClub")
|
|
||||||
|
|
||||||
|
# Owner can be linked to an user note or a club note
|
||||||
|
limit = models.Q(app_label="note", model="NoteUser") | models.Q(app_label="note", model="NoteClub")
|
||||||
owner_id = models.PositiveIntegerField()
|
owner_id = models.PositiveIntegerField()
|
||||||
owner_type = models.ForeignKey(ContentType,
|
owner_type = models.ForeignKey(
|
||||||
|
ContentType,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
limit_choices_to=limit)
|
limit_choices_to=limit
|
||||||
|
)
|
||||||
owner = GenericForeignKey('owner_type', 'owner_id')
|
owner = GenericForeignKey('owner_type', 'owner_id')
|
||||||
|
|
||||||
|
|
||||||
class Note(models.Model):
|
class Note(models.Model):
|
||||||
"""
|
"""
|
||||||
An abstract model, use to add transactions capabilities to a user
|
An abstract model, use to add transactions capabilities to a user
|
||||||
"""
|
"""
|
||||||
|
balance = models.DecimalField(
|
||||||
solde = models.IntegerField(
|
verbose_name=_('account balance'),
|
||||||
verbose_name=_('solde du compte'),
|
help_text=_("money credited for this instance"),
|
||||||
help_text=_("en centime, l' argent crédité pour cette instance")
|
decimal_places=2, # Limit to centimes
|
||||||
)
|
)
|
||||||
active = models.BooleanField(
|
is_active = models.BooleanField(
|
||||||
default=True,
|
default=True,
|
||||||
verbose_name=_('etat du compte')
|
verbose_name=_('is active')
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
class NoteUser(Note):
|
class NoteUser(Note):
|
||||||
"""
|
"""
|
||||||
A Note associated to a User
|
A Note associated to an User
|
||||||
"""
|
"""
|
||||||
user = models.OneToOneField(
|
user = models.OneToOneField(
|
||||||
settings.AUTH_USER_MODEL,
|
settings.AUTH_USER_MODEL,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("One's Note")
|
verbose_name = _("one's note")
|
||||||
verbose_name_plural = _("Users Note")
|
verbose_name_plural = _("users note")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.user.get_username()
|
return self.user.get_username()
|
||||||
|
@ -73,15 +79,17 @@ class NoteSpec(Note):
|
||||||
"""
|
"""
|
||||||
account_type = models.CharField(
|
account_type = models.CharField(
|
||||||
max_length=2,
|
max_length=2,
|
||||||
choices = (("CH","chèques"),
|
choices=(
|
||||||
|
("CH", "chèques"),
|
||||||
("CB", "Carte Bancaire"),
|
("CB", "Carte Bancaire"),
|
||||||
("VB", "Virement Bancaire"),
|
("VB", "Virement Bancaire"),
|
||||||
("CA", "Cash"),
|
("CA", "Cash"),
|
||||||
("RB", "Remboursement")
|
("RB", "Remboursement")
|
||||||
),
|
),
|
||||||
unique = True
|
unique=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class NoteClub(Note):
|
class NoteClub(Note):
|
||||||
# to be added
|
# to be added
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
Loading…
Reference in New Issue