fix card_multiselect filtering and quantity controls
This commit is contained in:
parent
6e4c6040bd
commit
b97ddde71c
52 changed files with 1689 additions and 2268 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 5.1.2 on 2025-03-09 05:08
|
||||
# Generated by Django 5.1.2 on 2025-03-13 01:46
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
|
@ -89,4 +89,15 @@ class Migration(migrations.Migration):
|
|||
name='rarity',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cards', to='cards.rarity'),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='RarityNameTranslation',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('name', models.CharField(max_length=64)),
|
||||
('language', models.CharField(max_length=64)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('rarity', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='name_translations', to='cards.rarity')),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -22,6 +22,17 @@ class CardNameTranslation(models.Model):
|
|||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class RarityNameTranslation(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=64)
|
||||
rarity = models.ForeignKey("Rarity", on_delete=models.PROTECT, related_name='name_translations')
|
||||
language = models.CharField(max_length=64)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class CardSet(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=64)
|
||||
|
|
|
|||
|
|
@ -48,20 +48,13 @@ def card_multiselect(field_name, label, placeholder, card_filter=None, selected_
|
|||
.prefetch_related("decks")
|
||||
)
|
||||
|
||||
# Loop through available cards and set styling, plus attach pre‑selected quantity
|
||||
# Loop through available cards and attach pre‑selected quantity
|
||||
for card in available_cards:
|
||||
# decks = list(card.decks.all())
|
||||
# deck_count = len(decks)
|
||||
# if deck_count == 1:
|
||||
# card.style = f"background-color: {decks[0].hex_color}; color: white;"
|
||||
# elif deck_count == 2:
|
||||
# card.style = f"background: linear-gradient(to right, {decks[0].hex_color}, {decks[1].hex_color}); color: white;"
|
||||
# elif deck_count >= 3:
|
||||
# card.style = f"background: linear-gradient(to right, {decks[0].hex_color}, {decks[1].hex_color}, {decks[2].hex_color}); color: white;"
|
||||
|
||||
pk_str = str(card.pk)
|
||||
if pk_str in selected_cards:
|
||||
card.selected_quantity = selected_cards[pk_str]
|
||||
else:
|
||||
card.selected_quantity = 1
|
||||
|
||||
return {
|
||||
'field_name': field_name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue