From 70298fdd1ed103a7bcf1d113d2e22a6ac33ca92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Helle=C5=9Ben?= Date: Tue, 17 Mar 2026 05:50:01 +0100 Subject: [PATCH] More core templates to core template dir --- core/views.py | 8 +-- .../{twitch => core}/dataset_backups.html | 0 templates/{twitch => core}/debug.html | 0 templates/{twitch => core}/docs_rss.html | 70 ++++++++++--------- .../{twitch => core}/search_results.html | 0 twitch/tests/test_views.py | 27 +++++-- 6 files changed, 61 insertions(+), 44 deletions(-) rename templates/{twitch => core}/dataset_backups.html (100%) rename templates/{twitch => core}/debug.html (100%) rename templates/{twitch => core}/docs_rss.html (79%) rename templates/{twitch => core}/search_results.html (100%) diff --git a/core/views.py b/core/views.py index f59c9ca..2b97f8f 100644 --- a/core/views.py +++ b/core/views.py @@ -285,7 +285,7 @@ def docs_rss_view(request: HttpRequest) -> HttpResponse: return render( request, - "twitch/docs_rss.html", + "core/docs_rss.html", { "game": sample_game, **seo_context, @@ -432,7 +432,7 @@ def debug_view(request: HttpRequest) -> HttpResponse: ) context.update(seo_context) - return render(request, "twitch/debug.html", context) + return render(request, "core/debug.html", context) # MARK: /datasets/ @@ -543,7 +543,7 @@ def dataset_backups_view(request: HttpRequest) -> HttpResponse: "dataset_count": len(datasets), **seo_context, } - return render(request, "twitch/dataset_backups.html", context) + return render(request, "core/dataset_backups.html", context) def dataset_backup_download_view( @@ -682,7 +682,7 @@ def search_view(request: HttpRequest) -> HttpResponse: ) return render( request, - "twitch/search_results.html", + "core/search_results.html", {"query": query, "results": results, **seo_context}, ) diff --git a/templates/twitch/dataset_backups.html b/templates/core/dataset_backups.html similarity index 100% rename from templates/twitch/dataset_backups.html rename to templates/core/dataset_backups.html diff --git a/templates/twitch/debug.html b/templates/core/debug.html similarity index 100% rename from templates/twitch/debug.html rename to templates/core/debug.html diff --git a/templates/twitch/docs_rss.html b/templates/core/docs_rss.html similarity index 79% rename from templates/twitch/docs_rss.html rename to templates/core/docs_rss.html index cec2dd7..41011a1 100644 --- a/templates/twitch/docs_rss.html +++ b/templates/core/docs_rss.html @@ -115,39 +115,41 @@ -
-

Filtered RSS Feeds

-

You can subscribe to RSS feeds scoped to a specific game.

- - - - - - - - - - - - - - - - - -
GameRSSAtomDiscord
{{ game.display_name }} - - https://ttvdrops.lovinator.space/rss/games/{{ game.twitch_id }}/ - - - - https://ttvdrops.lovinator.space/atom/games/{{ game.twitch_id }}/ - - - - https://ttvdrops.lovinator.space/discord/games/{{ game.twitch_id }}/ - -
-
+ {% if game %} +
+

Filtered RSS Feeds

+

You can subscribe to RSS feeds scoped to a specific game.

+ + + + + + + + + + + + + + + + + +
GameRSSAtomDiscord
{{ game.display_name }} + + https://ttvdrops.lovinator.space/rss/games/{{ game.twitch_id }}/ + + + + https://ttvdrops.lovinator.space/atom/games/{{ game.twitch_id }}/ + + + + https://ttvdrops.lovinator.space/discord/games/{{ game.twitch_id }}/ + +
+
+ {% endif %} {% endblock content %} diff --git a/templates/twitch/search_results.html b/templates/core/search_results.html similarity index 100% rename from templates/twitch/search_results.html rename to templates/core/search_results.html diff --git a/twitch/tests/test_views.py b/twitch/tests/test_views.py index 7586914..5a9bec4 100644 --- a/twitch/tests/test_views.py +++ b/twitch/tests/test_views.py @@ -1006,14 +1006,29 @@ class TestChannelListView: @pytest.mark.django_db def test_docs_rss_view(self, client: Client) -> None: - """Test docs RSS view returns 200 and has feeds in context.""" + """Test docs RSS view returns 200.""" response: _MonkeyPatchedWSGIResponse = client.get(reverse("core:docs_rss")) assert response.status_code == 200 - assert "feeds" in response.context - assert "filtered_feeds" in response.context - assert response.context["feeds"][0]["example_xml"] - html: str = response.content.decode() - assert '' in html + + # Add Game with running campaign to ensure it's included in the RSS feed + game: Game = Game.objects.create( + twitch_id="g-rss", + name="Game RSS", + display_name="Game RSS", + ) + + DropCampaign.objects.create( + twitch_id="c-rss", + name="Campaign RSS", + game=game, + start_at=timezone.now() - timedelta(days=1), + end_at=timezone.now() + timedelta(days=1), + operation_names=["DropCampaignDetails"], + ) + + response = client.get(reverse("core:docs_rss")) + assert response.status_code == 200 + assert "g-rss" in response.content.decode("utf-8") @pytest.mark.django_db