summaryrefslogtreecommitdiff
path: root/app/src/admin.py
blob: 558528d4ff9a80f5d054c7024246ce4f79d37f0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from django.contrib import admin
from .models import Topic, Entry, Book
from jrnl.admin import BlogEntryForm

class TopicAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ('name',), "pluralized_name":('name',)}

class BookAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ('title',),}

class EntryAdmin(admin.ModelAdmin):
    form = BlogEntryForm
    list_display = ('title', 'pub_date', 'enable_comments', 'status')
    list_filter = ('pub_date', 'enable_comments', 'status')
    prepopulated_fields = {"slug": ('title',)}
    fieldsets = (
        ('Entry', {
            'fields': (
                'title',
                'body_markdown',
                ('pub_date', 'status'),
                'topics',
                'meta_description',
                ('slug', 'enable_comments', 'has_code', 'template_name'),
            ),
            'classes': (
                'show',
                'extrapretty',
                'wide'
            )
        }
        ),
    )

admin.site.register(Book, BookAdmin)
admin.site.register(Topic, TopicAdmin)
admin.site.register(Entry, EntryAdmin)