From fb9f2f58481f675798630aa06eab1382857af6ad Mon Sep 17 00:00:00 2001 From: badbl0cks <4161747+badbl0cks@users.noreply.github.com> Date: Mon, 17 Mar 2025 15:38:20 -0700 Subject: [PATCH] Fix card_multiselect and trade create view using old db fields --- theme/templates/base.html | 13 +++++++------ theme/templatetags/card_multiselect.html | 6 +++--- trades/forms.py | 4 ++-- trades/views.py | 4 +--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/theme/templates/base.html b/theme/templates/base.html index fa35e05..8a003ea 100644 --- a/theme/templates/base.html +++ b/theme/templates/base.html @@ -104,12 +104,13 @@ tabindex="0" class="menu menu-sm dropdown-content bg-base-100 rounded-box z-1 mt-3 w-32 p-2 shadow">
  • - - Profile - - - - + +
    Profile
    +
    + + + +
  • diff --git a/theme/templatetags/card_multiselect.html b/theme/templatetags/card_multiselect.html index b2be0d0..b945f70 100644 --- a/theme/templatetags/card_multiselect.html +++ b/theme/templatetags/card_multiselect.html @@ -13,9 +13,9 @@ {% if card.selected %}selected{% endif %} data-html-content='{{ card|card_badge_inline:"__QUANTITY__" }}' data-name="{{ card.name }}" - data-rarity="{{ card.rarity.icons }}" - data-cardset="{{ card.cardset.name }}"> - {{ card.name }} {{ card.rarity.icons }} {{ card.cardset.name }} + data-rarity="{{ card.rarity_icon }}" + data-cardset="{{ card.cardset }}"> + {{ card.name }} {{ card.rarity_icon }} {{ card.cardset }} {% endfor %} {% endcache %} diff --git a/trades/forms.py b/trades/forms.py index f6ddb8f..98b5e8e 100644 --- a/trades/forms.py +++ b/trades/forms.py @@ -120,8 +120,8 @@ class TradeOfferCreateForm(ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - # Populate choices from Card model - cards = Card.objects.order_by("name", "rarity__pk") + # Populate choices from Card model using the new field 'rarity_level' instead of the removed relation. + cards = Card.objects.order_by("name", "rarity_level") choices = [(str(card.pk), card.name) for card in cards] self.fields["have_cards"].choices = choices self.fields["want_cards"].choices = choices diff --git a/trades/views.py b/trades/views.py index 606f077..1c95d89 100644 --- a/trades/views.py +++ b/trades/views.py @@ -42,9 +42,7 @@ class TradeOfferCreateView(LoginRequiredMixin, CreateView): context = super().get_context_data(**kwargs) from cards.models import Card # Ensure available_cards is a proper QuerySet - context["cards"] = Card.objects.all().order_by("name", "rarity_level") \ - .select_related("rarity", "cardset") \ - .prefetch_related("decks") + context["cards"] = Card.objects.all().order_by("name", "rarity_level") friend_codes = self.request.user.friend_codes.all() if "initiated_by" in self.request.GET: try: