fix button words

This commit is contained in:
mohamad
2026-05-31 12:45:05 +03:30
parent 7726b0b6ec
commit de2789bd99
14 changed files with 271 additions and 36 deletions
+16 -2
View File
@@ -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: