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
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 5.0.2 on 2026-05-20 09:43
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pages', '0006_homepagesectionitem_image_supporters'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='HeroSection',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('badge', models.CharField(blank=True, help_text="Small label above the title (e.g. 'Developing since 2021').", max_length=200)),
|
||||
('title', models.CharField(blank=True, help_text="Main title line (e.g. 'Radiuma,').", max_length=300)),
|
||||
('title_highlight', models.CharField(blank=True, help_text="Second title line shown in gradient colour (e.g. 'A Powerful Workflow Generator').", max_length=300)),
|
||||
('subtitle', models.CharField(blank=True, help_text="Short line below the title (e.g. 'for Standardized Radiomics Analysis…').", max_length=500)),
|
||||
('description', models.TextField(blank=True, help_text='Longer paragraph below the subtitle.')),
|
||||
('primary_cta_text', models.CharField(blank=True, help_text='Primary button label.', max_length=100)),
|
||||
('primary_cta_url', models.CharField(blank=True, help_text='Primary button URL (relative or absolute).', max_length=300)),
|
||||
('secondary_cta_text', models.CharField(blank=True, help_text='Secondary (ghost) button label.', max_length=100)),
|
||||
('secondary_cta_url', models.CharField(blank=True, help_text='Secondary (ghost) button URL.', max_length=300)),
|
||||
('image', models.ImageField(blank=True, help_text='App preview screenshot shown on the right.', null=True, upload_to='hero/')),
|
||||
('image_alt', models.CharField(blank=True, help_text='Alt text for the preview image.', max_length=300)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Hero Section',
|
||||
'verbose_name_plural': 'Hero Section',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -3,6 +3,27 @@ from django.db import models
|
||||
from apps.core.utils import CONTENT_FORMAT_CHOICES, FORMAT_MARKDOWN, FORMAT_PLAIN, render_content
|
||||
|
||||
|
||||
class HeroSection(models.Model):
|
||||
badge = models.CharField(max_length=200, blank=True, help_text="Small label above the title (e.g. 'Developing since 2021').")
|
||||
title = models.CharField(max_length=300, blank=True, help_text="Main title line (e.g. 'Radiuma,').")
|
||||
title_highlight = models.CharField(max_length=300, blank=True, help_text="Second title line shown in gradient colour (e.g. 'A Powerful Workflow Generator').")
|
||||
subtitle = models.CharField(max_length=500, blank=True, help_text="Short line below the title (e.g. 'for Standardized Radiomics Analysis…').")
|
||||
description = models.TextField(blank=True, help_text="Longer paragraph below the subtitle.")
|
||||
primary_cta_text = models.CharField(max_length=100, blank=True, help_text="Primary button label.")
|
||||
primary_cta_url = models.CharField(max_length=300, blank=True, help_text="Primary button URL (relative or absolute).")
|
||||
secondary_cta_text = models.CharField(max_length=100, blank=True, help_text="Secondary (ghost) button label.")
|
||||
secondary_cta_url = models.CharField(max_length=300, blank=True, help_text="Secondary (ghost) button URL.")
|
||||
image = models.ImageField(upload_to="hero/", blank=True, null=True, help_text="App preview screenshot shown on the right.")
|
||||
image_alt = models.CharField(max_length=300, blank=True, help_text="Alt text for the preview image.")
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Hero Section"
|
||||
verbose_name_plural = "Hero Section"
|
||||
|
||||
def __str__(self):
|
||||
return "Hero Section"
|
||||
|
||||
|
||||
class HomepageSection(models.Model):
|
||||
TYPE_FEATURES = "features"
|
||||
TYPE_SCREENSHOTS = "screenshots"
|
||||
|
||||
+2
-1
@@ -8,7 +8,7 @@ from django.views.generic import ListView, TemplateView
|
||||
from apps.products.models import SubProduct
|
||||
|
||||
from .forms import ContactForm
|
||||
from .models import AboutSection, ContactSubmission, FAQEntry, HomepageSection
|
||||
from .models import AboutSection, ContactSubmission, FAQEntry, HeroSection, HomepageSection
|
||||
|
||||
|
||||
class HomeView(TemplateView):
|
||||
@@ -16,6 +16,7 @@ class HomeView(TemplateView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx["hero"] = HeroSection.objects.first()
|
||||
ctx["homepage_sections"] = (
|
||||
HomepageSection.objects.filter(is_active=True)
|
||||
.prefetch_related("items")
|
||||
|
||||
Reference in New Issue
Block a user