Skip to content

Commit 1fda39c

Browse files
authored
Show watched status for episode history (#792)
* Show watched status for episode history - Reuse the completed status chip for watched episode activity cards.\n- Cover episode card rendering without changing release history.\n\nFixes #573 * Make history status chips accessible - Share one status path for explicit and watched-episode states - Expose status text to screen readers and keep release history unchanged
1 parent c264da6 commit 1fda39c

2 files changed

Lines changed: 46 additions & 35 deletions

File tree

src/app/tests/test_templatetags.py

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ def test_history_card_uses_canonical_music_album_url(self):
607607
content,
608608
)
609609

610-
def test_history_card_episode_edit_uses_track_modal(self):
611-
"""Episode history cards should open the track modal so ratings can be edited."""
610+
def test_history_card_episode_shows_watched_status_and_uses_track_modal(self):
611+
"""Episode history cards show watched status and open the track modal."""
612612
item = Item.objects.create(
613613
media_id="episode-history-1",
614614
source=Sources.TMDB.value,
@@ -621,34 +621,33 @@ def test_history_card_episode_edit_uses_track_modal(self):
621621
request = self.request_factory.get("/history")
622622
request.user = self.user
623623

624+
context = {
625+
"entry": SimpleNamespace(
626+
media_type=MediaTypes.EPISODE.value,
627+
album=None,
628+
item=item,
629+
poster=item.image,
630+
status=None,
631+
runtime_display=None,
632+
display_title=item.title,
633+
title=item.title,
634+
played_at_local=timezone.now(),
635+
time_range_display="6:00 PM",
636+
play_count=1,
637+
progress_display=None,
638+
episode_label="S1E2",
639+
episode_code="S1E2",
640+
show=None,
641+
score=8,
642+
entry_key="episode-entry-1",
643+
instance_id=7,
644+
),
645+
"card_class": "search-result-card",
646+
"history_mode": "activity",
647+
"user": self.user,
648+
}
624649
content = render_to_string(
625-
"app/components/history_card.html",
626-
{
627-
"entry": SimpleNamespace(
628-
media_type=MediaTypes.EPISODE.value,
629-
album=None,
630-
item=item,
631-
poster=item.image,
632-
status=None,
633-
runtime_display=None,
634-
display_title=item.title,
635-
title=item.title,
636-
played_at_local=timezone.now(),
637-
time_range_display="6:00 PM",
638-
play_count=1,
639-
progress_display=None,
640-
episode_label="S1E2",
641-
episode_code="S1E2",
642-
show=None,
643-
score=8,
644-
entry_key="episode-entry-1",
645-
instance_id=7,
646-
),
647-
"card_class": "search-result-card",
648-
"history_mode": "activity",
649-
"user": self.user,
650-
},
651-
request=request,
650+
"app/components/history_card.html", context, request=request
652651
)
653652

654653
expected_track_url = reverse(
@@ -664,6 +663,17 @@ def test_history_card_episode_edit_uses_track_modal(self):
664663
self.assertIn('"instance_id": "7"', content)
665664
self.assertIn('"standard_modal": "1"', content)
666665
self.assertNotIn('hx-get="/history_modal/', content)
666+
self.assertIn("media-status-chip", content)
667+
self.assertIn("Status: Completed", content)
668+
self.assertIn('aria-hidden="true"', content)
669+
670+
release_content = render_to_string(
671+
"app/components/history_card.html",
672+
{**context, "history_mode": "release"},
673+
request=request,
674+
)
675+
self.assertNotIn("media-status-chip", release_content)
676+
self.assertNotIn("Status: Completed", release_content)
667677

668678
def test_history_card_teleports_alt_title_tooltip(self):
669679
"""History cards should teleport alternate-title tooltips outside the clipped shell."""

src/templates/app/components/history_card.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
{% endwith %}
2020

2121
{# Status chip (top-left) #}
22-
{% if entry.status %}
23-
<div class="media-status-chip absolute top-2 left-2 bg-gray-900/90 text-white text-xs px-2 py-1 rounded-md flex items-center gap-1.5 shadow-md">
24-
{% with status_value=entry.status %}
25-
<div class="w-4 h-4 {{ status_value|status_color }}">
22+
{% if entry.status or entry.media_type == MediaTypes.EPISODE.value and history_mode != "release" %}
23+
{% with status_value=entry.status|default:"Completed" %}
24+
<div class="media-status-chip absolute top-2 left-2 bg-gray-900/90 text-white text-xs px-2 py-1 rounded-md flex items-center gap-1.5 shadow-md">
25+
<span class="sr-only">Status: {{ status_value }}</span>
26+
<div class="w-4 h-4 {{ status_value|status_color }}" aria-hidden="true">
2627
{% if status_value == "Completed" %}
2728
{% include "app/icons/states/completed.svg" with classes="w-full h-full" %}
2829
{% elif status_value == "In progress" %}
@@ -35,8 +36,8 @@
3536
{% include "app/icons/states/dropped.svg" with classes="w-full h-full" %}
3637
{% endif %}
3738
</div>
38-
{% endwith %}
39-
</div>
39+
</div>
40+
{% endwith %}
4041
{% endif %}
4142

4243
{# Runtime chip (top-right) #}

0 commit comments

Comments
 (0)