Replace WYSIWYG editor with Markdown editor across all relevant models and admin fields. Add utilities for rendering and stripping markdown. Adjust serializers, views, and templates to support markdown content. Introduce `PastedImage` model and upload endpoint for handling inline image uploads in markdown. This change simplifies content formatting while enhancing flexibility with markdown support.
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
from django.contrib.admin import register
|
|
from django.db.models import TextField
|
|
from unfold.admin import ModelAdmin
|
|
from unfold_markdown import MarkdownWidget
|
|
|
|
from engine.blog.models import Post, PostTag
|
|
from engine.core.admin import ActivationActionsMixin, FieldsetsMixin
|
|
|
|
|
|
@register(Post)
|
|
class PostAdmin(FieldsetsMixin, ActivationActionsMixin, ModelAdmin):
|
|
list_display = ("title", "author", "slug", "created", "modified")
|
|
list_filter = ("author", "tags", "created", "modified")
|
|
search_fields = ("title", "content", "slug")
|
|
filter_horizontal = ("tags",)
|
|
date_hierarchy = "created"
|
|
autocomplete_fields = ("tags",)
|
|
formfield_overrides = {TextField: {"widget": MarkdownWidget}}
|
|
readonly_fields = (
|
|
"uuid",
|
|
"slug",
|
|
"modified",
|
|
"created",
|
|
)
|
|
|
|
general_fields = [
|
|
"title",
|
|
"content",
|
|
"file",
|
|
]
|
|
relation_fields = [
|
|
"author",
|
|
"tags",
|
|
]
|
|
|
|
|
|
@register(PostTag)
|
|
class PostTagAdmin(ModelAdmin):
|
|
list_display = ("tag_name", "name")
|
|
search_fields = ("tag_name", "name")
|
|
ordering = ("tag_name",)
|