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