55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
from django.contrib import admin
|
|
from django.contrib.auth.admin import UserAdmin,GroupAdmin
|
|
from django.contrib.auth.models import User, Group
|
|
from unfold.admin import ModelAdmin, TabularInline
|
|
|
|
from .models import Site, Page, Url, Variable, File, Post, Feedback
|
|
from unfold.contrib.forms.widgets import WysiwygWidget
|
|
from django.db import models
|
|
admin.site.unregister(Group)
|
|
admin.site.unregister(User)
|
|
|
|
@admin.register(User)
|
|
class UserAdmin(UserAdmin, ModelAdmin): pass
|
|
|
|
@admin.register(Group)
|
|
class GroupAdmin(GroupAdmin, ModelAdmin): pass
|
|
|
|
class UrlInline(TabularInline):
|
|
model = Url
|
|
extra = 0
|
|
|
|
@admin.register(Post)
|
|
class PostAdmin(ModelAdmin):
|
|
formfield_overrides = {
|
|
models.TextField: {
|
|
"widget": WysiwygWidget
|
|
}
|
|
}
|
|
def save_model(self,request,obj,form,change):
|
|
obj.author = request.user
|
|
obj.save()
|
|
|
|
@admin.register(Site)
|
|
class SiteAdmin(ModelAdmin):
|
|
list_display = ["domain","base_page"]
|
|
list_editable = ["base_page"]
|
|
inlines = [UrlInline]
|
|
|
|
@admin.register(Page)
|
|
class PageAdmin(ModelAdmin): pass
|
|
|
|
|
|
@admin.register(Variable)
|
|
class VariableAdmin(ModelAdmin):
|
|
list_display = ["name","value"]
|
|
list_editable = ["value"]
|
|
|
|
@admin.register(File)
|
|
class FileAdmin(ModelAdmin): pass
|
|
|
|
|
|
@admin.register(Feedback)
|
|
class FeedbackAdmin(ModelAdmin):
|
|
list_display = ["name","email"]
|
|
list_display_links = ["name","email"]
|