feat: dynamic citation text and logo
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
|
||||
from .models import (
|
||||
AboutSection,
|
||||
@@ -6,11 +8,38 @@ from .models import (
|
||||
ContactSubmission,
|
||||
DownloadItem,
|
||||
FAQEntry,
|
||||
HeroSection,
|
||||
HomepageSection,
|
||||
HomepageSectionItem,
|
||||
)
|
||||
|
||||
|
||||
@admin.register(HeroSection)
|
||||
class HeroSectionAdmin(admin.ModelAdmin):
|
||||
fieldsets = (
|
||||
("Badge", {"fields": ("badge",)}),
|
||||
("Title", {"fields": ("title", "title_highlight")}),
|
||||
("Text", {"fields": ("subtitle", "description")}),
|
||||
("Primary Button", {"fields": ("primary_cta_text", "primary_cta_url")}),
|
||||
("Secondary Button", {"fields": ("secondary_cta_text", "secondary_cta_url")}),
|
||||
("Image", {"fields": ("image", "image_alt")}),
|
||||
)
|
||||
|
||||
def has_add_permission(self, request):
|
||||
return not HeroSection.objects.exists()
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
return False
|
||||
|
||||
def changelist_view(self, request, extra_context=None):
|
||||
hero = HeroSection.objects.first()
|
||||
if hero:
|
||||
return HttpResponseRedirect(
|
||||
reverse("admin:pages_herosection_change", args=[hero.pk])
|
||||
)
|
||||
return super().changelist_view(request, extra_context)
|
||||
|
||||
|
||||
class HomepageSectionItemInline(admin.TabularInline):
|
||||
model = HomepageSectionItem
|
||||
extra = 1
|
||||
|
||||
Reference in New Issue
Block a user