Fix categoryless campaigns not making template work
All checks were successful
Deploy to Server / deploy (push) Successful in 25s
All checks were successful
Deploy to Server / deploy (push) Successful in 25s
This commit is contained in:
parent
2993dc75b6
commit
51defc11e1
4 changed files with 100 additions and 12 deletions
|
|
@ -679,6 +679,34 @@ class KickDashboardViewTest(TestCase):
|
|||
)
|
||||
assert campaign.name in response.content.decode()
|
||||
|
||||
def test_dashboard_handles_campaign_without_category(self) -> None:
|
||||
"""Dashboard should render active campaigns with no category."""
|
||||
org: KickOrganization = KickOrganization.objects.create(
|
||||
kick_id="org-view-no-category",
|
||||
name="Org No Category",
|
||||
)
|
||||
campaign: KickDropCampaign = KickDropCampaign.objects.create(
|
||||
kick_id="camp-view-no-category",
|
||||
name="Active No Category Campaign",
|
||||
status="active",
|
||||
starts_at=dt(2020, 1, 1, tzinfo=UTC),
|
||||
ends_at=dt(2099, 12, 31, tzinfo=UTC),
|
||||
organization=org,
|
||||
category=None,
|
||||
rule_id=1,
|
||||
rule_name="Watch to redeem",
|
||||
is_fully_imported=True,
|
||||
)
|
||||
|
||||
response: _MonkeyPatchedWSGIResponse = self.client.get(
|
||||
reverse("kick:dashboard"),
|
||||
)
|
||||
|
||||
content: str = response.content.decode()
|
||||
assert response.status_code == 200
|
||||
assert campaign.name in content
|
||||
assert "Unknown game" in content
|
||||
|
||||
def test_dashboard_query_count_stays_flat_with_more_campaigns(self) -> None:
|
||||
"""Dashboard SELECT query count should stay flat as active campaign count grows."""
|
||||
|
||||
|
|
@ -823,6 +851,30 @@ class KickCampaignListViewTest(TestCase):
|
|||
)
|
||||
assert campaign.name in response.content.decode()
|
||||
|
||||
def test_campaign_list_handles_campaign_without_category(self) -> None:
|
||||
"""Campaign list should render campaigns with no category."""
|
||||
campaign: KickDropCampaign = KickDropCampaign.objects.create(
|
||||
kick_id="camp-list-no-category",
|
||||
name="List No Category Campaign",
|
||||
status="active",
|
||||
starts_at=dt(2020, 1, 1, tzinfo=UTC),
|
||||
ends_at=dt(2099, 12, 31, tzinfo=UTC),
|
||||
organization=self.org,
|
||||
category=None,
|
||||
rule_id=1,
|
||||
rule_name="Watch to redeem",
|
||||
is_fully_imported=True,
|
||||
)
|
||||
|
||||
response: _MonkeyPatchedWSGIResponse = self.client.get(
|
||||
reverse("kick:campaign_list"),
|
||||
)
|
||||
|
||||
content: str = response.content.decode()
|
||||
assert response.status_code == 200
|
||||
assert campaign.name in content
|
||||
assert "Unknown game" in content
|
||||
|
||||
def test_campaign_list_status_filter(self) -> None:
|
||||
"""Filtering by status should show only campaigns with that status."""
|
||||
active: KickDropCampaign = self._make_campaign(
|
||||
|
|
@ -886,6 +938,28 @@ class KickCampaignDetailViewTest(TestCase):
|
|||
)
|
||||
assert campaign.name in response.content.decode()
|
||||
|
||||
def test_campaign_detail_handles_campaign_without_category(self) -> None:
|
||||
"""Campaign detail should render campaigns with no category."""
|
||||
org: KickOrganization = KickOrganization.objects.create(
|
||||
kick_id="org-det-no-category",
|
||||
name="Detail Org No Category",
|
||||
)
|
||||
campaign: KickDropCampaign = KickDropCampaign.objects.create(
|
||||
kick_id="camp-det-no-category",
|
||||
name="Detail No Category Campaign",
|
||||
organization=org,
|
||||
category=None,
|
||||
rule_id=1,
|
||||
rule_name="Watch to redeem",
|
||||
)
|
||||
|
||||
response: _MonkeyPatchedWSGIResponse = self.client.get(
|
||||
reverse("kick:campaign_detail", kwargs={"kick_id": campaign.kick_id}),
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert campaign.name in response.content.decode()
|
||||
|
||||
def test_campaign_detail_404_for_unknown(self) -> None:
|
||||
"""Campaign detail view should return HTTP 404 status code for unknown campaign."""
|
||||
response: _MonkeyPatchedWSGIResponse = self.client.get(
|
||||
|
|
|
|||
|
|
@ -136,12 +136,14 @@
|
|||
</p>
|
||||
{% endif %}
|
||||
<div>
|
||||
{% if campaign.category %}
|
||||
<a href="{% url 'kick:game_campaign_feed' campaign.category.kick_id %}"
|
||||
title="RSS feed for {{ campaign.category.name }} campaigns">[rss]</a>
|
||||
<a href="{% url 'kick:game_campaign_feed_atom' campaign.category.kick_id %}"
|
||||
title="Atom feed for {{ campaign.category.name }} campaigns">[atom]</a>
|
||||
<a href="{% url 'kick:game_campaign_feed_discord' campaign.category.kick_id %}"
|
||||
title="Discord feed for {{ campaign.category.name }} campaigns">[discord]</a>
|
||||
{% endif %}
|
||||
<a href="{% url 'core:docs_rss' %}" title="RSS documentation">[explain]</a>
|
||||
{% if campaign.connect_url %}
|
||||
<a href="{{ campaign.connect_url }}"
|
||||
|
|
@ -149,7 +151,9 @@
|
|||
{% endif %}
|
||||
{% if campaign.url %}<a href="{{ campaign.url }}" title="About URL for {{ campaign.name }}">[about]</a>{% endif %}
|
||||
{% if campaign.channels.count == 0 %}
|
||||
{% if campaign.rule_name == "Watch to redeem" %}<a href="{{ campaign.category.kick_url }}">[watch]</a>{% endif %}
|
||||
{% if campaign.category and campaign.rule_name == "Watch to redeem" %}
|
||||
<a href="{{ campaign.category.kick_url }}">[watch]</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -77,7 +77,11 @@
|
|||
<a href="{% url 'kick:campaign_detail' campaign.kick_id %}">{{ campaign.name }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if campaign.category %}
|
||||
<a href="{% url 'kick:game_detail' campaign.category.kick_id %}">{{ campaign.category.name }}</a>
|
||||
{% else %}
|
||||
Unknown game
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{% url 'kick:organization_detail' campaign.organization.kick_id %}">{{ campaign.organization.name }}</a>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,11 @@
|
|||
<article>
|
||||
<header>
|
||||
<h2>
|
||||
{% if campaign.category %}
|
||||
<a href="{% url 'kick:game_detail' campaign.category.kick_id %}">{{ campaign.category.name }}</a>
|
||||
{% else %}
|
||||
Unknown game
|
||||
{% endif %}
|
||||
</h2>
|
||||
<div style="font-size: 0.9rem; color: #666;">
|
||||
{% if campaign.organization %}
|
||||
|
|
@ -138,10 +142,12 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
{% else %}
|
||||
{% if campaign.category %}
|
||||
<p style="margin: 0.25rem 0 0 0;">
|
||||
<a href="{{ campaign.category.kick_url }}">{{ campaign.category.name }}</a> is game wide.
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if campaign.merged_rewards %}
|
||||
<div style="margin-top: 0.75rem;">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue