Fix card_multiselect and trade create view using old db fields
This commit is contained in:
parent
c77e32a82d
commit
fb9f2f5848
4 changed files with 13 additions and 14 deletions
|
|
@ -104,12 +104,13 @@
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
class="menu menu-sm dropdown-content bg-base-100 rounded-box z-1 mt-3 w-32 p-2 shadow">
|
class="menu menu-sm dropdown-content bg-base-100 rounded-box z-1 mt-3 w-32 p-2 shadow">
|
||||||
<li>
|
<li>
|
||||||
<a class="justify-between" href="https://www.gravatar.com/profile/" target="_blank" rel="noopener noreferrer">
|
<a class="flex items-center justify-between" href="https://www.gravatar.com/profile/" target="_blank" rel="noopener noreferrer">
|
||||||
Profile
|
<div>Profile</div>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
<div>
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" />
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
||||||
</svg>
|
<path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@
|
||||||
{% if card.selected %}selected{% endif %}
|
{% 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-name="{{ card.name }}"
|
||||||
data-rarity="{{ card.rarity.icons }}"
|
data-rarity="{{ card.rarity_icon }}"
|
||||||
data-cardset="{{ card.cardset.name }}">
|
data-cardset="{{ card.cardset }}">
|
||||||
{{ card.name }} {{ card.rarity.icons }} {{ card.cardset.name }}
|
{{ card.name }} {{ card.rarity_icon }} {{ card.cardset }}
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endcache %}
|
{% endcache %}
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,8 @@ class TradeOfferCreateForm(ModelForm):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
# Populate choices from Card model
|
# Populate choices from Card model using the new field 'rarity_level' instead of the removed relation.
|
||||||
cards = Card.objects.order_by("name", "rarity__pk")
|
cards = Card.objects.order_by("name", "rarity_level")
|
||||||
choices = [(str(card.pk), card.name) for card in cards]
|
choices = [(str(card.pk), card.name) for card in cards]
|
||||||
self.fields["have_cards"].choices = choices
|
self.fields["have_cards"].choices = choices
|
||||||
self.fields["want_cards"].choices = choices
|
self.fields["want_cards"].choices = choices
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,7 @@ class TradeOfferCreateView(LoginRequiredMixin, CreateView):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
from cards.models import Card
|
from cards.models import Card
|
||||||
# Ensure available_cards is a proper QuerySet
|
# Ensure available_cards is a proper QuerySet
|
||||||
context["cards"] = Card.objects.all().order_by("name", "rarity_level") \
|
context["cards"] = Card.objects.all().order_by("name", "rarity_level")
|
||||||
.select_related("rarity", "cardset") \
|
|
||||||
.prefetch_related("decks")
|
|
||||||
friend_codes = self.request.user.friend_codes.all()
|
friend_codes = self.request.user.friend_codes.all()
|
||||||
if "initiated_by" in self.request.GET:
|
if "initiated_by" in self.request.GET:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue