From 9e501af1ac72d3641f6bbc5c5a342a85f7522cbd Mon Sep 17 00:00:00 2001
From: badbl0cks <4161747+badbl0cks@users.noreply.github.com>
Date: Sun, 13 Apr 2025 00:31:24 -0700
Subject: [PATCH] fix card_badges to always be links to card detail page
---
cards/templatetags/card_badge.py | 5 +++
theme/templates/cards/_card_list.html | 8 ++---
theme/templates/home/_card_list.html | 5 +--
theme/templatetags/card_badge.html | 46 ++++++++++++------------
theme/templatetags/card_multiselect.html | 4 +--
theme/templatetags/trade_offer.html | 8 ++---
6 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/cards/templatetags/card_badge.py b/cards/templatetags/card_badge.py
index 03584de..b69bdb7 100644
--- a/cards/templatetags/card_badge.py
+++ b/cards/templatetags/card_badge.py
@@ -1,11 +1,13 @@
from django import template
from django.template.loader import render_to_string
from django.utils.safestring import mark_safe
+from django.urls import reverse
register = template.Library()
@register.inclusion_tag("templatetags/card_badge.html")
def card_badge(card, quantity=None, expanded=False):
+ url = reverse('cards:card_detail', args=[card.pk])
return {
'quantity': quantity,
'style': card.style,
@@ -13,6 +15,7 @@ def card_badge(card, quantity=None, expanded=False):
'rarity': card.rarity_icon,
'cardset': card.cardset,
'expanded': expanded,
+ 'url': url,
}
@register.filter
@@ -20,6 +23,7 @@ def card_badge_inline(card, quantity=None):
"""
Renders an inline card badge.
"""
+ url = reverse('cards:card_detail', args=[card.pk])
html = render_to_string("templatetags/card_badge.html", {
'quantity': quantity,
'style': card.style,
@@ -27,6 +31,7 @@ def card_badge_inline(card, quantity=None):
'rarity': card.rarity_icon,
'cardset': card.cardset,
'expanded': True,
+ 'url': url,
})
return mark_safe(html)
diff --git a/theme/templates/cards/_card_list.html b/theme/templates/cards/_card_list.html
index 759b29a..62d2184 100644
--- a/theme/templates/cards/_card_list.html
+++ b/theme/templates/cards/_card_list.html
@@ -5,18 +5,14 @@
{{ group.group }}
{% endfor %}
{% else %}
{% endif %}
diff --git a/theme/templates/home/_card_list.html b/theme/templates/home/_card_list.html
index 95a9025..2669cca 100644
--- a/theme/templates/home/_card_list.html
+++ b/theme/templates/home/_card_list.html
@@ -2,10 +2,7 @@
{% if cards %}
{% else %}
diff --git a/theme/templatetags/card_badge.html b/theme/templatetags/card_badge.html
index 5dfa30f..f5ae207 100644
--- a/theme/templatetags/card_badge.html
+++ b/theme/templatetags/card_badge.html
@@ -1,26 +1,26 @@
-{% if not expanded %}
-
-
-
-
{{ cardset }}
- {% if quantity != None %}
-
-{% else %}
-
-
-
{{ name }}
- {% if quantity != None %}
-
- {% endif %}
-
{{ rarity }}
-
{{ cardset }}
-
-
-{% endif %}
\ No newline at end of file
+
\ No newline at end of file
diff --git a/theme/templatetags/card_multiselect.html b/theme/templatetags/card_multiselect.html
index 6e30aea..e3034ae 100644
--- a/theme/templatetags/card_multiselect.html
+++ b/theme/templatetags/card_multiselect.html
@@ -11,7 +11,7 @@
data-card-id="{{ card.pk }}"
data-quantity="{{ card.selected_quantity }}"
{% if card.selected %}selected{% endif %}
- data-html-content='{{ card|card_badge_inline:"__QUANTITY__" }}'
+ data-html-content='
{{ card|card_badge_inline:"__QUANTITY__" }}
'
data-name="{{ card.name }}"
data-rarity="{{ card.rarity_icon }}"
data-cardset="{{ card.cardset }}">
@@ -39,7 +39,7 @@ if (!window.updateGlobalCardFilters) {
}
});
if (selectedValues.length > 0 && globalRarity === null) {
- const option = select.querySelector(`option[value="${selectedValues[0]}"]`);
+ const option = select.querySelector('option[value="${selectedValues[0]}"]');
if (option) {
globalRarity = option.getAttribute('data-rarity');
}
diff --git a/theme/templatetags/trade_offer.html b/theme/templatetags/trade_offer.html
index c20457d..794ea37 100644
--- a/theme/templatetags/trade_offer.html
+++ b/theme/templatetags/trade_offer.html
@@ -25,14 +25,14 @@
{% if num_cards_available > 0 %}
-
+
{% for card in have_cards_available %}
-
{% card_badge card.card card.quantity %}
+ {% card_badge card.card card.quantity %}
{% endfor %}
-
+
{% for card in want_cards_available %}
-
{% card_badge card.card card.quantity %}
+ {% card_badge card.card card.quantity %}
{% endfor %}
{% else %}