camp/content/admin.py

69 lines
1.7 KiB
Python
Raw Normal View History

2017-05-20 12:45:26 +00:00
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
2017-07-03 08:14:07 +00:00
from django import forms
2017-05-20 12:45:26 +00:00
from django.contrib import admin
2017-07-03 08:14:07 +00:00
from markdownx.admin import MarkdownxModelAdmin
from markdownx.widgets import AdminMarkdownxWidget
2017-05-20 12:45:26 +00:00
# Register your models here.
from models import *
2017-07-03 08:14:07 +00:00
from photologue.admin import GalleryAdmin as GalleryAdminDefault
from photologue.models import Gallery
2017-06-10 11:07:32 +00:00
class ContentParentsInline(admin.TabularInline):
model = ContentContent
2017-06-10 12:05:37 +00:00
fk_name = 'contentid2'
2017-12-18 12:54:04 +00:00
raw_id_fields = ['contentid1']
2017-12-19 13:34:43 +00:00
extra = 0
2017-06-10 12:05:37 +00:00
class ImagesInline(admin.StackedInline):
2017-12-19 13:34:43 +00:00
extra = 0
2017-06-10 12:05:37 +00:00
model = Image
class FileInline(admin.StackedInline):
2017-12-19 13:34:43 +00:00
extra = 0
2017-06-10 12:05:37 +00:00
model = File
class LinkInline(admin.StackedInline):
2017-12-19 13:34:43 +00:00
extra = 0
2017-06-10 12:05:37 +00:00
model = Link
2017-05-20 12:45:26 +00:00
'''
class SubdomainInline(admin.StackedInline):
model = Subdomain
class DomainAliasInline(admin.StackedInline):
model = DomainAlias
class ServerAdmin(admin.ModelAdmin):
pass
'''
2017-07-03 08:14:07 +00:00
class GalleryAdminForm(forms.ModelForm):
"""Users never need to enter a description on a gallery."""
class Meta:
model = Gallery
exclude = ['description']
class GalleryAdmin(GalleryAdminDefault):
form = GalleryAdminForm
2017-05-20 12:45:26 +00:00
class ContentAdmin(admin.ModelAdmin):
save_on_top = True
2017-12-18 12:54:04 +00:00
list_display = ('__unicode__', 'datestart', 'shortname', 'type')
2017-05-24 11:44:04 +00:00
list_filter = ['datestart', 'type']
2017-12-18 12:54:04 +00:00
search_fields = ['title', 'body', 'header', 'shortname']
2017-12-19 13:34:43 +00:00
inlines = [ContentParentsInline, FileInline, LinkInline]
2017-07-03 08:14:07 +00:00
formfield_overrides = {
models.TextField: {'widget': AdminMarkdownxWidget},
}
2017-05-24 11:44:04 +00:00
2017-05-20 12:45:26 +00:00
admin.site.register(Content, ContentAdmin)
2017-07-03 08:14:07 +00:00
admin.site.unregister(Gallery)
admin.site.register(Gallery, GalleryAdmin)