|
1 | 1 | from django.contrib import admin |
2 | 2 |
|
3 | | -# Register your models here. |
| 3 | +from app.speakers.models import Speaker, SpeakerPresentation, SpeakerSchedule, SpeakerSocial |
| 4 | + |
| 5 | + |
| 6 | +class SpeakerSocialInline(admin.TabularInline): |
| 7 | + model = SpeakerSocial |
| 8 | + extra = 1 |
| 9 | + fields = ("platform", "username", "url") |
| 10 | + |
| 11 | + |
| 12 | +class SpeakerPresentationInline(admin.TabularInline): |
| 13 | + model = SpeakerPresentation |
| 14 | + extra = 1 |
| 15 | + fields = ("title", "presentation_type", "description", "abstract") |
| 16 | + |
| 17 | + |
| 18 | +@admin.register(Speaker) |
| 19 | +class SpeakerAdmin(admin.ModelAdmin): |
| 20 | + list_display = ("full_name", "title", "email", "is_featured", "created_at") |
| 21 | + list_filter = ("is_featured", "created_at", "updated_at") |
| 22 | + search_fields = ("first_name", "last_name", "email", "title") |
| 23 | + list_editable = ("is_featured",) |
| 24 | + readonly_fields = ("created_at", "updated_at") |
| 25 | + |
| 26 | + fieldsets = ( |
| 27 | + ("Personal Information", {"fields": ("first_name", "last_name", "middle_name", "title")}), |
| 28 | + ("Contact & Media", {"fields": ("email", "photo_url")}), |
| 29 | + ("Content", {"fields": ("introduction", "bio")}), |
| 30 | + ("Settings", {"fields": ("is_featured",)}), |
| 31 | + ("Timestamps", {"fields": ("created_at", "updated_at"), "classes": ("collapse",)}), |
| 32 | + ) |
| 33 | + |
| 34 | + inlines = [SpeakerSocialInline, SpeakerPresentationInline] |
| 35 | + |
| 36 | + |
| 37 | +@admin.register(SpeakerSocial) |
| 38 | +class SpeakerSocialAdmin(admin.ModelAdmin): |
| 39 | + list_display = ("speaker", "platform", "username", "url") |
| 40 | + list_filter = ("platform", "created_at") |
| 41 | + search_fields = ("speaker__first_name", "speaker__last_name", "platform", "username") |
| 42 | + readonly_fields = ("created_at", "updated_at") |
| 43 | + |
| 44 | + |
| 45 | +@admin.register(SpeakerPresentation) |
| 46 | +class SpeakerPresentationAdmin(admin.ModelAdmin): |
| 47 | + list_display = ("title", "speaker", "presentation_type", "created_at") |
| 48 | + list_filter = ("presentation_type", "created_at", "updated_at") |
| 49 | + search_fields = ("title", "speaker__first_name", "speaker__last_name", "description") |
| 50 | + readonly_fields = ("created_at", "updated_at") |
| 51 | + |
| 52 | + fieldsets = ( |
| 53 | + ("Presentation Details", {"fields": ("title", "speaker", "presentation_type")}), |
| 54 | + ("Content", {"fields": ("description", "abstract")}), |
| 55 | + ("Timestamps", {"fields": ("created_at", "updated_at"), "classes": ("collapse",)}), |
| 56 | + ) |
| 57 | + |
| 58 | + |
| 59 | +@admin.register(SpeakerSchedule) |
| 60 | +class SpeakerScheduleAdmin(admin.ModelAdmin): |
| 61 | + list_display = ("presentation", "speaker", "day", "track", "time_start", "time_end", "location") |
| 62 | + list_filter = ("day", "track", "time_start", "created_at") |
| 63 | + search_fields = ("presentation__title", "speaker__first_name", "speaker__last_name", "location") |
| 64 | + readonly_fields = ("created_at", "updated_at") |
| 65 | + |
| 66 | + fieldsets = ( |
| 67 | + ("Schedule Details", {"fields": ("presentation", "speaker", "day", "track")}), |
| 68 | + ("Timing & Location", {"fields": ("time_start", "time_end", "location")}), |
| 69 | + ("Additional Information", {"fields": ("description",)}), |
| 70 | + ("Timestamps", {"fields": ("created_at", "updated_at"), "classes": ("collapse",)}), |
| 71 | + ) |
0 commit comments