From aed8adeea48b0589fd7a769bcb36cda3ec54c690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Wed, 11 Feb 2026 18:41:40 +0100 Subject: [PATCH] Refactor campaign list view --- pyproject.toml | 7 +- templates/twitch/campaign_list.html | 128 ++++---------- twitch/tests/test_views.py | 257 ++++++++++++++++++++++++++++ twitch/views.py | 10 +- 4 files changed, 304 insertions(+), 98 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f1c5b48..43d48f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,12 +90,13 @@ line-length = 120 "**/tests/**" = [ "ARG", "FBT", + "PLR0904", "PLR2004", - "S101", - "S311", - "S106", "PLR6301", + "S101", "S105", + "S106", + "S311", "SLF001", ] "**/migrations/**" = ["RUF012"] diff --git a/templates/twitch/campaign_list.html b/templates/twitch/campaign_list.html index 867ab91..30e2d59 100644 --- a/templates/twitch/campaign_list.html +++ b/templates/twitch/campaign_list.html @@ -6,47 +6,25 @@ {% block content %}
-

Drop Campaigns

-

Browse all available drop campaigns

+

Drop Campaigns

-
+
RSS feed for all campaigns -
- -
+ title="RSS feed for all campaigns">[rss] 📥 Campaigns (CSV) + title="Export campaigns as CSV">[csv] 📥 Campaigns (JSON) - 📥 Games (CSV) - 📥 Games (JSON) - 📥 Organizations (CSV) - 📥 Organizations (JSON) + title="Export campaigns as JSON">[json]
-
+
- - {% for game in games %}
- -
- + +
-
+
{% if campaigns %} {% regroup campaigns by game as campaigns_by_game %} {% for game_group in campaigns_by_game %} -
+
-
+
{% if game_group.grouper.box_art_best_url %} Box art for {{ game_group.grouper.display_name }} + height="160" /> {% else %}
- {% comment %} Find this header section in your template {% endcomment %}

- {{ game_group.grouper.display_name|default:game_group.grouper.name|default:game_group.grouper.slug|default:game_group.grouper.twitch_id }}

- {% comment %} Check if the owner exists and has a valid ID before creating the link {% endcomment %} {% if game_group.grouper.owner and game_group.grouper.owner.twitch_id %}

- {{ game_group.grouper.owner.name }}

{% endif %} @@ -119,40 +89,22 @@
{% for campaign in game_group.list %} -
- {% if campaign.image_best_url or campaign.image_url %} - Campaign artwork for {{ campaign.name }} - {% else %} -
- 📦 -
- No Image -
{% endif %} -

{{ campaign.clean_name }}

+

{{ campaign.clean_name }}

@@ -190,7 +137,6 @@ {% endfor %} {% else %}
-
📦

No Campaigns Found

No campaigns match your current filters. @@ -201,39 +147,39 @@ {% endif %} {% if is_paginated %} -