phantasma/app/text/admin.py

33 lines
798 B
Python
Raw Normal View History

2021-09-28 15:10:22 +02:00
from django.contrib import admin
from django.db.models import JSONField
2021-09-28 15:10:22 +02:00
2021-10-10 16:06:43 +01:00
from . import models
from ..widgets import PrettyJSONWidget
2021-10-10 16:06:43 +01:00
@admin.decorators.register(models.Text)
class TextAdmin(admin.ModelAdmin):
formfield_overrides = {
JSONField: {'widget': PrettyJSONWidget}
}
2021-10-11 13:55:45 +01:00
list_display = (
'__str__',
2021-10-26 13:16:43 +01:00
'item',
'edit',
'language',
2021-10-11 13:55:45 +01:00
'slug',
'public',
2021-10-26 13:16:43 +01:00
'position',
2021-10-11 13:55:45 +01:00
)
list_editable = ['public', 'language', 'position']
list_filter = ['language', 'public']
2021-10-28 20:39:04 +05:30
search_fields = ['slug', 'title', 'byline']
2021-10-26 13:16:43 +01:00
def item(self, obj):
return obj.data.get('item')
def edit(self, obj):
return obj.data.get('edit')
2021-10-22 17:35:07 +01:00
#@admin.decorators.register(models.Page)
#class PageAdmin(admin.ModelAdmin):
# pass