fix button words
This commit is contained in:
+2
-2
@@ -63,10 +63,10 @@ class HomepageSectionAdmin(admin.ModelAdmin):
|
||||
)
|
||||
|
||||
|
||||
class AboutSectionItemInline(admin.StackedInline):
|
||||
class AboutSectionItemInline(admin.TabularInline):
|
||||
model = AboutSectionItem
|
||||
extra = 1
|
||||
fields = ("badge", "title", "content", "url", "image", "image_alt", "is_featured", "order")
|
||||
fields = ("icon", "title", "content", "url", "image", "image_alt", "badge", "is_featured", "order")
|
||||
ordering = ("order",)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("pages", "0011_custompagesectionitem_page_aboutsectionitem_url"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="aboutsectionitem",
|
||||
name="icon",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
help_text="Emoji or short symbol (e.g. ⚗️).",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
]
|
||||
+10
-2
@@ -98,6 +98,7 @@ class AboutSection(models.Model):
|
||||
TYPE_GRID = "grid"
|
||||
TYPE_HISTORY = "history"
|
||||
TYPE_CUSTOM = "custom"
|
||||
TYPE_SUPPORTERS = "supporters"
|
||||
|
||||
TYPE_CHOICES = [
|
||||
(TYPE_HERO, "Hero"),
|
||||
@@ -105,6 +106,7 @@ class AboutSection(models.Model):
|
||||
(TYPE_GRID, "Grid Cards"),
|
||||
(TYPE_HISTORY, "History Block"),
|
||||
(TYPE_CUSTOM, "Custom Content"),
|
||||
(TYPE_SUPPORTERS, "Supporters"),
|
||||
]
|
||||
|
||||
section_type = models.CharField(max_length=30, choices=TYPE_CHOICES, default=TYPE_CUSTOM)
|
||||
@@ -134,11 +136,17 @@ class AboutSection(models.Model):
|
||||
|
||||
class AboutSectionItem(models.Model):
|
||||
section = models.ForeignKey(AboutSection, on_delete=models.CASCADE, related_name="items")
|
||||
icon = models.CharField(max_length=20, blank=True, help_text="Emoji or short symbol (e.g. ⚗️).")
|
||||
badge = models.CharField(max_length=100, blank=True)
|
||||
title = models.CharField(max_length=300, blank=True)
|
||||
content = models.TextField(blank=True, help_text="Description text or link label for History links.")
|
||||
url = models.CharField(max_length=300, blank=True, help_text="Optional link; makes this item clickable.")
|
||||
image = models.ImageField(upload_to="about/", blank=True, null=True)
|
||||
image = models.ImageField(
|
||||
upload_to="about/items/",
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text="Logo or image (used for Supporters cards).",
|
||||
)
|
||||
image_alt = models.CharField(max_length=200, blank=True)
|
||||
is_featured = models.BooleanField(default=False, help_text="Mark as featured item (e.g. large screenshot).")
|
||||
order = models.PositiveIntegerField(default=0)
|
||||
@@ -149,7 +157,7 @@ class AboutSectionItem(models.Model):
|
||||
verbose_name_plural = "About Section Items"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.section} › {self.title or self.badge or '(item)'}"
|
||||
return f"{self.section} › {self.title or self.icon or self.badge or '(item)'}"
|
||||
|
||||
|
||||
class ContactSubmission(models.Model):
|
||||
|
||||
+27
-2
@@ -83,7 +83,19 @@ class MainProductAdmin(admin.ModelAdmin):
|
||||
list_editable = ("order", "is_active", "show_on_homepage", "homepage_order")
|
||||
inlines = [MainProductArticleInline, MainProductVersionInline, SubProductInline]
|
||||
fieldsets = (
|
||||
(None, {"fields": ("name", "slug", "short_description", "distribution")}),
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": (
|
||||
"name",
|
||||
"slug",
|
||||
"short_description",
|
||||
"distribution",
|
||||
"package_resource_button_text",
|
||||
"package_source_button_text",
|
||||
)
|
||||
},
|
||||
),
|
||||
("Description", {"fields": ("description_format", "description")}),
|
||||
("Media", {"fields": ("image",)}),
|
||||
("Homepage", {"fields": ("show_on_homepage", "homepage_order")}),
|
||||
@@ -110,7 +122,20 @@ class SubProductAdmin(admin.ModelAdmin):
|
||||
raw_id_fields = ("main_product",)
|
||||
inlines = [SubProductArticleInline, SubProductVersionInline]
|
||||
fieldsets = (
|
||||
(None, {"fields": ("main_product", "name", "slug", "distribution", "short_description")}),
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": (
|
||||
"main_product",
|
||||
"name",
|
||||
"slug",
|
||||
"distribution",
|
||||
"short_description",
|
||||
"package_resource_button_text",
|
||||
"package_source_button_text",
|
||||
)
|
||||
},
|
||||
),
|
||||
("Description", {"fields": ("description_format", "description")}),
|
||||
("Media", {"fields": ("image", "logo")}),
|
||||
("Homepage", {"fields": ("show_on_homepage", "homepage_order")}),
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 5.0.2 on 2026-05-31 09:10
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('products', '0012_migrate_homepage_visibility_to_mainproduct'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='mainproduct',
|
||||
name='package_resource_button_text',
|
||||
field=models.CharField(default='PyPI', help_text='Label for the package resource button on package releases.', max_length=100),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mainproduct',
|
||||
name='package_source_button_text',
|
||||
field=models.CharField(default='Source', help_text='Label for the source code button on package releases.', max_length=100),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='subproduct',
|
||||
name='package_resource_button_text',
|
||||
field=models.CharField(default='PyPI', help_text='Label for the package resource button on package releases.', max_length=100),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='subproduct',
|
||||
name='package_source_button_text',
|
||||
field=models.CharField(default='Source', help_text='Label for the source code button on package releases.', max_length=100),
|
||||
),
|
||||
]
|
||||
@@ -36,6 +36,16 @@ class MainProduct(models.Model):
|
||||
default=DISTRIBUTION_INSTALLABLE,
|
||||
help_text="Only affects how releases appear on the public site.",
|
||||
)
|
||||
package_resource_button_text = models.CharField(
|
||||
max_length=100,
|
||||
default="PyPI",
|
||||
help_text="Label for the package resource button on package releases.",
|
||||
)
|
||||
package_source_button_text = models.CharField(
|
||||
max_length=100,
|
||||
default="Source",
|
||||
help_text="Label for the source code button on package releases.",
|
||||
)
|
||||
order = models.PositiveIntegerField(default=0)
|
||||
is_active = models.BooleanField(default=True)
|
||||
show_on_homepage = models.BooleanField(default=False, help_text="Display this product in the homepage Products section.")
|
||||
@@ -99,6 +109,16 @@ class SubProduct(models.Model):
|
||||
default=DISTRIBUTION_INSTALLABLE,
|
||||
help_text="Only affects how releases appear on the public site.",
|
||||
)
|
||||
package_resource_button_text = models.CharField(
|
||||
max_length=100,
|
||||
default="PyPI",
|
||||
help_text="Label for the package resource button on package releases.",
|
||||
)
|
||||
package_source_button_text = models.CharField(
|
||||
max_length=100,
|
||||
default="Source",
|
||||
help_text="Label for the source code button on package releases.",
|
||||
)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
from .models import DISTRIBUTION_INSTALLABLE, DISTRIBUTION_PACKAGE, INSTALLABLE_PLATFORM_SPECS
|
||||
|
||||
DEFAULT_PACKAGE_RESOURCE_BUTTON_TEXT = "PyPI"
|
||||
DEFAULT_PACKAGE_SOURCE_BUTTON_TEXT = "Source"
|
||||
|
||||
|
||||
def package_button_labels(product):
|
||||
resource = (getattr(product, "package_resource_button_text", "") or "").strip()
|
||||
source = (getattr(product, "package_source_button_text", "") or "").strip()
|
||||
return {
|
||||
"package_resource_button_text": resource or DEFAULT_PACKAGE_RESOURCE_BUTTON_TEXT,
|
||||
"package_source_button_text": source or DEFAULT_PACKAGE_SOURCE_BUTTON_TEXT,
|
||||
}
|
||||
|
||||
|
||||
def featured_version(qs):
|
||||
ordered = qs.order_by("order", "pk")
|
||||
@@ -16,7 +28,7 @@ def install_specs_from_versions(version_list):
|
||||
return tuple(s for s in INSTALLABLE_PLATFORM_SPECS if s[0] in present)
|
||||
|
||||
|
||||
def build_release_context(distribution, active_versions):
|
||||
def build_release_context(distribution, active_versions, product):
|
||||
context = {
|
||||
"distribution_installable": distribution == DISTRIBUTION_INSTALLABLE,
|
||||
"distribution_package": distribution == DISTRIBUTION_PACKAGE,
|
||||
@@ -25,6 +37,7 @@ def build_release_context(distribution, active_versions):
|
||||
"featured_install_cells": [],
|
||||
"show_older_versions_link": False,
|
||||
"package_versions": [],
|
||||
**package_button_labels(product),
|
||||
}
|
||||
|
||||
if distribution == DISTRIBUTION_INSTALLABLE:
|
||||
@@ -62,7 +75,7 @@ def build_release_context(distribution, active_versions):
|
||||
return context
|
||||
|
||||
|
||||
def build_archive_context(distribution, active_versions):
|
||||
def build_archive_context(distribution, active_versions, product):
|
||||
featured = featured_version(active_versions)
|
||||
archive = list(
|
||||
active_versions.exclude(pk=featured.pk).order_by("order", "pk")
|
||||
@@ -72,6 +85,7 @@ def build_archive_context(distribution, active_versions):
|
||||
context = {
|
||||
"featured_version": featured,
|
||||
"archive_versions": archive,
|
||||
**package_button_labels(product),
|
||||
}
|
||||
|
||||
if distribution == DISTRIBUTION_INSTALLABLE:
|
||||
|
||||
@@ -31,6 +31,7 @@ class MainProductDetailView(DetailView):
|
||||
release_context = build_release_context(
|
||||
self.object.distribution,
|
||||
self.object.versions.filter(is_active=True),
|
||||
self.object,
|
||||
)
|
||||
release_context["versions_archive_url"] = self.object.get_versions_archive_url()
|
||||
context.update(release_context)
|
||||
@@ -52,7 +53,9 @@ class MainProductOlderVersionsView(TemplateView):
|
||||
context["sub_product"] = None
|
||||
context["product_detail_url"] = main_product.get_absolute_url()
|
||||
context.update(
|
||||
build_archive_context(main_product.distribution, active_versions)
|
||||
build_archive_context(
|
||||
main_product.distribution, active_versions, main_product
|
||||
)
|
||||
)
|
||||
return context
|
||||
|
||||
@@ -85,7 +88,7 @@ class SubProductDetailView(TemplateView):
|
||||
)
|
||||
active_versions = sub_product.versions.filter(is_active=True)
|
||||
release_context = build_release_context(
|
||||
sub_product.distribution, active_versions
|
||||
sub_product.distribution, active_versions, sub_product
|
||||
)
|
||||
release_context["versions_archive_url"] = sub_product.get_versions_archive_url()
|
||||
context.update(release_context)
|
||||
@@ -113,6 +116,8 @@ class SubProductOlderVersionsView(TemplateView):
|
||||
context["sub_product"] = sub_product
|
||||
context["product_detail_url"] = sub_product.get_absolute_url()
|
||||
context.update(
|
||||
build_archive_context(sub_product.distribution, active_versions)
|
||||
build_archive_context(
|
||||
sub_product.distribution, active_versions, sub_product
|
||||
)
|
||||
)
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user