mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 01:48:21 +02:00
Remove note activities
This commit is contained in:
@ -6,7 +6,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from polymorphic.admin import PolymorphicChildModelAdmin, \
|
||||
PolymorphicChildModelFilter, PolymorphicParentModelAdmin
|
||||
|
||||
from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser, NoteActivity
|
||||
from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser
|
||||
from .models.transactions import Transaction, TemplateCategory, TransactionTemplate, \
|
||||
RecurrentTransaction, MembershipTransaction
|
||||
|
||||
@ -24,7 +24,7 @@ class NoteAdmin(PolymorphicParentModelAdmin):
|
||||
"""
|
||||
Parent regrouping all note types as children
|
||||
"""
|
||||
child_models = (NoteClub, NoteSpecial, NoteUser, NoteActivity)
|
||||
child_models = (NoteClub, NoteSpecial, NoteUser)
|
||||
list_filter = (
|
||||
PolymorphicChildModelFilter,
|
||||
'is_active',
|
||||
@ -74,14 +74,6 @@ class NoteSpecialAdmin(PolymorphicChildModelAdmin):
|
||||
readonly_fields = ('balance',)
|
||||
|
||||
|
||||
@admin.register(NoteActivity)
|
||||
class NoteActivityAdmin(PolymorphicChildModelAdmin):
|
||||
"""
|
||||
Child for a special note, see NoteAdmin
|
||||
"""
|
||||
readonly_fields = ('balance',)
|
||||
|
||||
|
||||
@admin.register(NoteUser)
|
||||
class NoteUserAdmin(PolymorphicChildModelAdmin):
|
||||
"""
|
||||
|
@ -4,7 +4,7 @@
|
||||
from rest_framework import serializers
|
||||
from rest_polymorphic.serializers import PolymorphicSerializer
|
||||
|
||||
from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias, NoteActivity
|
||||
from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
|
||||
from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction, TemplateCategory, \
|
||||
RecurrentTransaction, SpecialTransaction
|
||||
|
||||
@ -69,22 +69,6 @@ class NoteUserSerializer(serializers.ModelSerializer):
|
||||
return str(obj)
|
||||
|
||||
|
||||
class NoteActivitySerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
REST API Serializer for User's notes.
|
||||
The djangorestframework plugin will analyse the model `NoteActivity` and parse all fields in the API.
|
||||
"""
|
||||
name = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = NoteActivity
|
||||
fields = '__all__'
|
||||
read_only_fields = ('note', 'user', )
|
||||
|
||||
def get_name(self, obj):
|
||||
return str(obj)
|
||||
|
||||
|
||||
class AliasSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
REST API Serializer for Aliases.
|
||||
@ -107,7 +91,6 @@ class NotePolymorphicSerializer(PolymorphicSerializer):
|
||||
NoteUser: NoteUserSerializer,
|
||||
NoteClub: NoteClubSerializer,
|
||||
NoteSpecial: NoteSpecialSerializer,
|
||||
NoteActivity: NoteActivitySerializer,
|
||||
}
|
||||
|
||||
class Meta:
|
||||
|
@ -1,13 +1,13 @@
|
||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from .notes import Alias, Note, NoteClub, NoteSpecial, NoteUser, NoteActivity
|
||||
from .notes import Alias, Note, NoteClub, NoteSpecial, NoteUser
|
||||
from .transactions import MembershipTransaction, Transaction, \
|
||||
TemplateCategory, TransactionTemplate, RecurrentTransaction, SpecialTransaction
|
||||
|
||||
__all__ = [
|
||||
# Notes
|
||||
'Alias', 'Note', 'NoteClub', 'NoteSpecial', 'NoteUser', 'NoteActivity',
|
||||
'Alias', 'Note', 'NoteClub', 'NoteSpecial', 'NoteUser',
|
||||
# Transactions
|
||||
'MembershipTransaction', 'Transaction', 'TemplateCategory', 'TransactionTemplate',
|
||||
'RecurrentTransaction', 'SpecialTransaction',
|
||||
|
@ -4,13 +4,11 @@
|
||||
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
|
||||
@ -176,40 +174,6 @@ 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 = _("activity note")
|
||||
verbose_name_plural = _("activity notes")
|
||||
|
||||
def __str__(self):
|
||||
return self.note_name
|
||||
|
||||
|
||||
class Alias(models.Model):
|
||||
"""
|
||||
points toward a :model:`note.NoteUser` or :model;`note.NoteClub` instance.
|
||||
|
@ -9,7 +9,7 @@ from django.utils.html import format_html
|
||||
from django_tables2.utils import A
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .models.notes import Alias, NoteActivity
|
||||
from .models.notes import Alias
|
||||
from .models.transactions import Transaction, TransactionTemplate
|
||||
from .templatetags.pretty_money import pretty_money
|
||||
|
||||
@ -121,24 +121,6 @@ class AliasTable(tables.Table):
|
||||
attrs={'td': {'class': 'col-sm-1'}})
|
||||
|
||||
|
||||
class NoteActivityTable(tables.Table):
|
||||
note_name = tables.LinkColumn(
|
||||
"member:club_linked_note_detail",
|
||||
args=[A("club.pk"), A("pk")],
|
||||
)
|
||||
|
||||
def render_balance(self, value):
|
||||
return pretty_money(value)
|
||||
|
||||
class Meta:
|
||||
attrs = {
|
||||
'class': 'table table-condensed table-striped table-hover'
|
||||
}
|
||||
model = NoteActivity
|
||||
fields = ('note_name', 'balance',)
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
|
||||
|
||||
class ButtonTable(tables.Table):
|
||||
class Meta:
|
||||
attrs = {
|
||||
|
Reference in New Issue
Block a user