diff --git a/charter_members/admin.py b/charter_members/admin.py index 9a5b56d..4b8d015 100644 --- a/charter_members/admin.py +++ b/charter_members/admin.py @@ -1,15 +1,16 @@ from django.contrib import admin -from .models import Position, Attorney +from .models import Chapter, Position, Attorney +admin.site.register(Chapter) admin.site.register(Position) @admin.register(Attorney) class MemberAdmin(admin.ModelAdmin): - list_display = ('name', 'position', 'phone_formatted', 'email', 'front_page', 'joined', 'thumbnail') - list_filter = ['position', 'front_page', 'joined'] - search_fields = ('email', 'joined', 'name', 'position', 'website', 'phone', 'phone_formatted') - fields = ('image_preview', 'image', 'name', 'position', 'biography', 'phone', 'email', 'website', 'front_page', 'joined') + list_display = ('name', 'position', 'chapter', 'phone_formatted', 'email', 'front_page', 'joined', 'thumbnail') + list_filter = ['chapter', 'position', 'front_page', 'joined'] + search_fields = ('email', 'joined', 'name', 'chapter', 'position', 'website', 'phone', 'phone_formatted') + fields = ('image_preview', 'image', 'name', 'position', 'chapter', 'biography', 'phone', 'email', 'website', 'front_page', 'joined') readonly_fields = ('image_preview',) diff --git a/charter_members/models.py b/charter_members/models.py index 4505393..a599d33 100644 --- a/charter_members/models.py +++ b/charter_members/models.py @@ -4,6 +4,13 @@ from django.db import models from tinymce import HTMLField +class Chapter(models.Model): + name = models.CharField(max_length=50) + + def __str__(self): + return self.name + + class Position(models.Model): position_name = models.CharField(max_length=50) @@ -13,6 +20,7 @@ class Position(models.Model): class Attorney(models.Model): biography = HTMLField(blank=True, null=True) + chapter = models.ForeignKey(Chapter, blank=True, null=True) email = models.CharField(max_length=255, blank=True, null=True) front_page = models.BooleanField(default=False) image = models.ImageField(upload_to='portraits', default='portraits/silhouette.png')