From 740b468547f097b5a42bc8855e5470a75cda23ae Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 16 Jul 2019 15:42:31 +0200 Subject: [PATCH] More admin --- activity/admin.py | 30 ++++++++++++++++++++++++++++++ activity/models.py | 3 +++ member/admin.py | 2 +- note/admin.py | 17 +++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/activity/admin.py b/activity/admin.py index 6ac23376..1efe272c 100644 --- a/activity/admin.py +++ b/activity/admin.py @@ -1,3 +1,33 @@ # -*- mode: python; coding: utf-8 -*- # Copyright (C) 2018-2019 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later + +from django.contrib import admin + +from .models import Activity, ActivityType, Guest + + +class ActivityAdmin(admin.ModelAdmin): + """ + Admin customisation for Activity + """ + list_display = ('name', 'activity_type', 'organizer') + list_filter = ('activity_type',) + search_fields = ['name', 'organizer__name'] + + # Organize activities by start date + date_hierarchy = 'date_start' + ordering = ['-date_start'] + + +class ActivityTypeAdmin(admin.ModelAdmin): + """ + Admin customisation for ActivityType + """ + list_display = ('name', 'can_invite', 'guest_entry_fee') + + +# Register your models here. +admin.site.register(Activity, ActivityAdmin) +admin.site.register(ActivityType, ActivityTypeAdmin) +admin.site.register(Guest) diff --git a/activity/models.py b/activity/models.py index ee411d76..2cc81732 100644 --- a/activity/models.py +++ b/activity/models.py @@ -23,6 +23,9 @@ class ActivityType(models.Model): verbose_name = _("activity type") verbose_name_plural = _("activity types") + def __str__(self): + return self.name + class Activity(models.Model): name = models.CharField( diff --git a/member/admin.py b/member/admin.py index 4ac79ec0..d055d268 100644 --- a/member/admin.py +++ b/member/admin.py @@ -7,7 +7,7 @@ from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from .forms import CustomUserChangeForm -from .models import Profile, Club +from .models import Club, Profile class ProfileInline(admin.StackedInline): diff --git a/note/admin.py b/note/admin.py index 9ec51a77..78936da9 100644 --- a/note/admin.py +++ b/note/admin.py @@ -1,6 +1,12 @@ +# -*- mode: python; coding: utf-8 -*- +# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + from django.contrib import admin from .models.notes import Alias, NoteClub, NoteSpecial, NoteUser +from .models.transactions import MembershipTransaction, Transaction, \ + TransactionTemplate class AliasInlines(admin.TabularInline): @@ -42,7 +48,18 @@ class NoteUserAdmin(admin.ModelAdmin): ordering = ['-user__date_joined'] +class TransactionTemplateAdmin(admin.ModelAdmin): + """ + Admin customisation for TransactionTemplate + """ + list_display = ('name', 'destination', 'amount', 'template_type') + list_filter = ('destination', 'template_type',) + + # Register your models here. admin.site.register(NoteClub, NoteClubAdmin) admin.site.register(NoteSpecial, NoteSpecialAdmin) admin.site.register(NoteUser, NoteUserAdmin) +admin.site.register(MembershipTransaction) +admin.site.register(Transaction) +admin.site.register(TransactionTemplate, TransactionTemplateAdmin)