Format files required by Jenkins lint

This commit is contained in:
2026-04-10 18:15:50 +02:00
parent ea011b2993
commit 034a804e02
9 changed files with 82 additions and 42 deletions

View File

@@ -115,9 +115,7 @@ def _update_homepage_stream(page) -> bool:
return False
page.body = StreamValue(page.body.stream_block, stream_data, is_lazy=True)
page.search_description = (
"Idea marketplace with premium plans. Preview each strategy and unlock full implementation after purchase."
)
page.search_description = "Idea marketplace with premium plans. Preview each strategy and unlock full implementation after purchase."
page.save()
return True
@@ -131,7 +129,9 @@ def _purge_demo_pages() -> int:
| Q(search_description__icontains=marker)
)
candidate_ids = set(
Page.objects.exclude(depth__lte=2).filter(marker_filter).values_list("id", flat=True)
Page.objects.exclude(depth__lte=2)
.filter(marker_filter)
.values_list("id", flat=True)
)
candidate_ids.update(
Page.objects.exclude(depth__lte=2)

View File

@@ -73,7 +73,9 @@ class Command(BaseCommand):
top_level_products = Product.objects.filter(parent__isnull=True)
if keep_only_ideas:
products_to_delete = top_level_products.exclude(title__in=IDEA_PRODUCT_TITLES)
products_to_delete = top_level_products.exclude(
title__in=IDEA_PRODUCT_TITLES
)
else:
products_to_delete = top_level_products.filter(product_filter).exclude(
title__in=IDEA_PRODUCT_TITLES
@@ -83,13 +85,17 @@ class Command(BaseCommand):
Page.objects.live()
.public()
.filter(depth__gt=2)
.filter(Q(slug__in=DEMO_PAGE_SLUGS) | _build_demo_text_filter(("title", "slug")))
.filter(
Q(slug__in=DEMO_PAGE_SLUGS) | _build_demo_text_filter(("title", "slug"))
)
)
product_preview = list(products_to_delete.values_list("id", "title")[:30])
page_preview = list(pages_to_delete.values_list("id", "slug", "title")[:30])
self.stdout.write(f"Products matched for deletion: {products_to_delete.count()}")
self.stdout.write(
f"Products matched for deletion: {products_to_delete.count()}"
)
for item in product_preview:
self.stdout.write(f" - product#{item[0]}: {item[1]}")
if products_to_delete.count() > len(product_preview):
@@ -102,7 +108,9 @@ class Command(BaseCommand):
self.stdout.write(" - ...")
if dry_run:
self.stdout.write(self.style.WARNING("Dry run completed. No data was deleted."))
self.stdout.write(
self.style.WARNING("Dry run completed. No data was deleted.")
)
return
deleted_products = products_to_delete.count()

View File

@@ -47,8 +47,13 @@ class Command(BaseCommand):
if config_path.exists():
with config_path.open("r", encoding="utf-8") as handle:
config_payload = json.load(handle)
config_plugins = [str(plugin) for plugin in config_payload.get("ocyan_plugins", [])]
if any("demodata" in "".join(ch for ch in str(plugin).lower() if ch.isalnum()) for plugin in config_plugins):
config_plugins = [
str(plugin) for plugin in config_payload.get("ocyan_plugins", [])
]
if any(
"demodata" in "".join(ch for ch in str(plugin).lower() if ch.isalnum())
for plugin in config_plugins
):
raise CommandError(
"Demo data plugin detected in ocyan.json. Remove it before launch."
)
@@ -70,7 +75,9 @@ class Command(BaseCommand):
if currency != "EUR":
raise CommandError(f"OSCAR_DEFAULT_CURRENCY must be EUR, got '{currency}'.")
product_class = ProductClass.objects.filter(name=IDEA_PRODUCT_CLASS_NAME).first()
product_class = ProductClass.objects.filter(
name=IDEA_PRODUCT_CLASS_NAME
).first()
if product_class is None:
raise CommandError(f"Missing ProductClass '{IDEA_PRODUCT_CLASS_NAME}'.")
if product_class.requires_shipping:
@@ -93,12 +100,14 @@ class Command(BaseCommand):
found_titles = set(found_products.values_list("title", flat=True))
missing_titles = sorted(expected_titles - found_titles)
if missing_titles:
raise CommandError(f"Missing seeded idea products: {', '.join(missing_titles)}.")
raise CommandError(
f"Missing seeded idea products: {', '.join(missing_titles)}."
)
non_public_idea_titles = list(
found_products.filter(title__in=expected_titles, is_public=False).values_list(
"title", flat=True
)
found_products.filter(
title__in=expected_titles, is_public=False
).values_list("title", flat=True)
)
if non_public_idea_titles:
raise CommandError(
@@ -122,9 +131,7 @@ class Command(BaseCommand):
missing_stockrecords: list[str] = []
for product in found_products.filter(title__in=expected_titles):
stockrecord = (
StockRecord.objects.filter(product=product)
.order_by("id")
.first()
StockRecord.objects.filter(product=product).order_by("id").first()
)
if stockrecord is None:
missing_stockrecords.append(product.title)
@@ -187,7 +194,9 @@ class Command(BaseCommand):
.values_list("title", "slug")[:10]
)
if live_demo_pages:
formatted = ", ".join(f"{title} ({slug})" for title, slug in live_demo_pages)
formatted = ", ".join(
f"{title} ({slug})" for title, slug in live_demo_pages
)
raise CommandError(
"Demo-like pages are still live/public. Purge them before launch. "
f"Examples: {formatted}"