From df1cd648514f2f04ce9d594c277c349ff4cc0582 Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Mon, 9 Feb 2026 12:54:03 -0500 Subject: [PATCH] Make /random redirect to any public product or content page Removed media-only filter and popout_player_enabled gate. Now picks from all public items and redirects to the correct /p/ or /c/ URL. --- make_post_sell/views/player.py | 39 +++++++--------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/make_post_sell/views/player.py b/make_post_sell/views/player.py index 131c4ed..5d5fb20 100644 --- a/make_post_sell/views/player.py +++ b/make_post_sell/views/player.py @@ -234,42 +234,19 @@ def player_json(request): @view_config(route_name="random") -def random_media(request): - """Redirect to a random public media item.""" - - # Check if feature is enabled - if not request.popout_player_enabled: - return HTTPNotFound() - - # Get current shop +def random_product(request): + """Redirect to a random public product or content page.""" shop = request.shop if not shop: return HTTPNotFound() - # Query all public products from the shop - shop_products = get_products_from_a_shop(shop, visibility=1) + products = list(get_products_from_a_shop(shop, visibility=1)) + if not products: + return HTTPNotFound("No public items available") - # Filter to only media items - media_products = [] - for p in shop_products: - # Check for preview or product file with media type - if "preview" in p.extensions: - ext = p.extensions.get("preview") - if get_media_type(ext): - media_products.append(p) - elif "product" in p.extensions: - ext = p.extensions.get("product") - if get_media_type(ext): - media_products.append(p) - - if not media_products: - return HTTPNotFound("No media available") - - # Pick a random product - random_product = random.choice(media_products) - - # Redirect to player - return HTTPFound(location=f"/player/{random_product.id}") + chosen = random.choice(products) + p_or_c = "p" if chosen.is_sellable else "c" + return HTTPFound(location=f"/{p_or_c}/{chosen.id}/{chosen.slug}") @view_config(route_name="tv", renderer="tv.j2")