Move aliases to inline admin

This commit is contained in:
Alexandre Iooss 2019-07-16 14:38:52 +02:00
parent 8a44f81d2c
commit 5172f74845
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
4 changed files with 58 additions and 6 deletions

View File

@ -2,8 +2,42 @@ from django.contrib import admin
from .models.notes import Alias, NoteClub, NoteSpecial, NoteUser
class AliasInlines(admin.TabularInline):
"""
Define user and club aliases when editing their note
"""
extra = 0
model = Alias
class NoteClubAdmin(admin.ModelAdmin):
"""
Admin customisation for NoteClub
"""
inlines = (AliasInlines,)
list_display = ('club', 'balance', 'is_active')
class NoteSpecialAdmin(admin.ModelAdmin):
"""
Admin customisation for NoteSpecial
"""
list_display = ('special_type', 'balance', 'is_active')
class NoteUserAdmin(admin.ModelAdmin):
"""
Admin customisation for NoteUser
"""
inlines = (AliasInlines,)
list_display = ('user', 'balance', 'is_active')
# Organize note by registration date
date_hierarchy = 'user__date_joined'
# Register your models here.
admin.site.register(Alias)
admin.site.register(NoteClub)
admin.site.register(NoteSpecial)
admin.site.register(NoteUser)
admin.site.register(NoteClub, NoteClubAdmin)
admin.site.register(NoteSpecial, NoteSpecialAdmin)
admin.site.register(NoteUser, NoteUserAdmin)

View File

@ -71,7 +71,7 @@ msgstr "note spéciale"
#: models/notes.py:85
msgid "special notes"
msgstr "notes spéciale"
msgstr "notes spéciales"
#: models/notes.py:93 models/transactions.py:18
msgid "name"

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.3 on 2019-07-16 12:06
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('note', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='noteclub',
old_name='user',
new_name='club',
),
]

View File

@ -54,7 +54,7 @@ class NoteClub(Note):
"""
A Note associated to a Club
"""
user = models.OneToOneField(
club = models.OneToOneField(
'member.Club',
on_delete=models.PROTECT,
related_name='note',