mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
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'
|
@ -1,7 +1,8 @@
|
|||||||
from django.contrib import admin
|
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')
|
||||||
|
@ -17,46 +17,52 @@ class Alias(models.Model):
|
|||||||
"""
|
"""
|
||||||
alias = models.TextField(
|
alias = models.TextField(
|
||||||
"alias",
|
"alias",
|
||||||
unique = True,
|
unique=True,
|
||||||
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(
|
||||||
on_delete=models.CASCADE,
|
ContentType,
|
||||||
limit_choices_to=limit)
|
on_delete=models.CASCADE,
|
||||||
owner = GenericForeignKey('owner_type','owner_id')
|
limit_choices_to=limit
|
||||||
|
)
|
||||||
|
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()
|
||||||
@ -72,16 +78,18 @@ class NoteSpec(Note):
|
|||||||
- Refund
|
- Refund
|
||||||
"""
|
"""
|
||||||
account_type = models.CharField(
|
account_type = models.CharField(
|
||||||
max_length = 2,
|
max_length=2,
|
||||||
choices = (("CH","chèques"),
|
choices=(
|
||||||
("CB","Carte Bancaire"),
|
("CH", "chèques"),
|
||||||
("VB","Virement Bancaire"),
|
("CB", "Carte Bancaire"),
|
||||||
("CA","Cash"),
|
("VB", "Virement Bancaire"),
|
||||||
("RB","Remboursement")
|
("CA", "Cash"),
|
||||||
|
("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.
|
|
0
note/tests/__init__.py
Normal file
0
note/tests/__init__.py
Normal file
@ -1,3 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
Loading…
Reference in New Issue
Block a user