79 lines
3.3 KiB
Python
79 lines
3.3 KiB
Python
from django.contrib import admin
|
|
from unfold.admin import ModelAdmin, TabularInline
|
|
|
|
from .current import AboutContent, AboutItem, HomeContent, ListingContent, SiteContent
|
|
|
|
|
|
class FixedContentAdmin(ModelAdmin):
|
|
"""The page records are installed by migration; editors only change them."""
|
|
|
|
list_per_page = 20
|
|
|
|
def has_add_permission(self, request):
|
|
return False
|
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
return False
|
|
|
|
|
|
@admin.register(SiteContent)
|
|
class SiteContentAdmin(FixedContentAdmin):
|
|
fieldsets = (
|
|
("Association", {"fields": ("official_name", "short_name", "faculty_subline", "description", "logo", "logo_alt")}),
|
|
("Navigation labels", {"fields": ("nav_home", "nav_about", "nav_events", "nav_blog")}),
|
|
("Contact and footer", {"fields": ("email", "phone", "telegram_url", "instagram_url", "website_url", "address", "footer_copy")}),
|
|
("SEO defaults", {"fields": ("seo_title", "seo_description", "seo_image", "seo_image_alt")}),
|
|
)
|
|
|
|
|
|
@admin.register(HomeContent)
|
|
class HomeContentAdmin(FixedContentAdmin):
|
|
fieldsets = (
|
|
("Page introduction", {"fields": ("title", "intro")}),
|
|
("Hero", {"fields": ("hero_heading", "hero_body", "hero_image", "hero_image_alt", "hero_action_label")}),
|
|
("Featured events", {"fields": ("featured_events_heading", "featured_events_intro", "featured_events_link_label")}),
|
|
("Featured blog posts", {"fields": ("featured_posts_heading", "featured_posts_intro", "featured_posts_link_label")}),
|
|
("Participation", {"fields": ("participation_heading", "participation_body", "participation_image", "participation_image_alt", "participation_action_label")}),
|
|
("SEO", {"fields": ("seo_title", "seo_description", "seo_image", "seo_image_alt")}),
|
|
)
|
|
|
|
|
|
class AboutItemInline(TabularInline):
|
|
model = AboutItem
|
|
extra = 0
|
|
fields = ("kind", "title", "text", "position")
|
|
|
|
def has_add_permission(self, request, obj=None):
|
|
return request.user.has_perm("content.change_aboutcontent")
|
|
|
|
def has_change_permission(self, request, obj=None):
|
|
return request.user.has_perm("content.change_aboutcontent")
|
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
return request.user.has_perm("content.change_aboutcontent")
|
|
|
|
|
|
@admin.register(AboutContent)
|
|
class AboutContentAdmin(FixedContentAdmin):
|
|
inlines = (AboutItemInline,)
|
|
fieldsets = (
|
|
("Page introduction", {"fields": ("title", "intro", "identity_heading", "identity_body")}),
|
|
("Mission", {"fields": ("mission_heading", "mission_body")}),
|
|
("Activities", {"fields": ("activities_heading", "activities_body")}),
|
|
("Values", {"fields": ("values_heading", "values_body")}),
|
|
("Committees", {"fields": ("committees_heading", "committees_body")}),
|
|
("Affiliations", {"fields": ("affiliations_heading", "affiliations_body")}),
|
|
("FAQ and contact", {"fields": ("faq_heading", "contact_heading")}),
|
|
("SEO", {"fields": ("seo_title", "seo_description", "seo_image", "seo_image_alt")}),
|
|
)
|
|
|
|
|
|
@admin.register(ListingContent)
|
|
class ListingContentAdmin(FixedContentAdmin):
|
|
list_display = ("slug", "title")
|
|
readonly_fields = ("slug",)
|
|
fieldsets = (
|
|
("Content", {"fields": ("slug", "title", "intro")}),
|
|
("SEO", {"fields": ("seo_title", "seo_description", "seo_image", "seo_image_alt")}),
|
|
)
|