Commit b6c5f11a authored by frekk's avatar frekk
Browse files

moved custom admin code around a bit

parent 7af56fb6
import csv
from collections import OrderedDict
from functools import wraps
from functools import wraps, singledispatch
from django.db.models import FieldDoesNotExist
from django.contrib import admin
from django.http import HttpResponse
from django.db.models import FieldDoesNotExist
from memberdb.models import Member, IncAssocMember, Membership
from memberdb.actions import download_as_csv
"""
Customise the administrative interface for modifying Member records
"""
class MemberAdmin(admin.ModelAdmin):
list_display = ['first_name', 'last_name', 'display_name', 'username']
list_filter = ['is_guild', 'is_student']
search_fields = list_display
actions = [download_as_csv]
admin.site.register(Member, MemberAdmin)
# Register the other models with default admin site pages
admin.site.register(IncAssocMember)
admin.site.register(Membership)
# Customise the admin site
admin.site.site_header = "Gumby Management System"
admin.site.site_title = "UCC Gumby Management System"
admin.site.index_title = "Membership Database"
from functools import singledispatch # included in Python 3.4+
# see download as CSV stuff below
def prep_field(obj, field):
"""
(for download_as_csv action)
......
from django.urls import path, include
from django.contrib import admin
admin.site.site_header = "Gumby Management System"
admin.site.site_title = "UCC Gumby Management System"
admin.site.index_title = "Membership Database"
urlpatterns = [
path('', include('memberdb.urls')),
path('admin/', admin.site.urls),
......
from django.contrib import admin
from memberdb.models import Member, IncAssocMember, Membership
from memberdb.actions import download_as_csv
admin.site.site_header = "Gumby Management System"
admin.site.site_title = "UCC Gumby Management System"
admin.site.index_title = "Membership Database"
"""
Customise the administrative interface for modifying Member records
"""
class MemberAdmin(admin.ModelAdmin):
list_display = ['first_name', 'last_name', 'display_name', 'username']
list_filter = ['is_guild', 'is_student']
search_fields = list_display
actions = [download_as_csv]
admin.site.register(Member, MemberAdmin)
# Register the other models with default admin site pages
admin.site.register(IncAssocMember)
admin.site.register(Membership)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment