Earthman deck: delete stray Pentacles courts; fix tarot_fan suit order
- Migration 0041: delete Maid/Jack/Queen/King of Pentacles (suit=PENTACLES, arcana=MINOR, numbers 11-14) from Earthman deck — duplicates of the correct CROWNS courts that already exist; escaped migration 0024's rename sweep - tarot_fan view: _suit_order now uses Earthman suit names (BRANDS/GRAILS/BLADES/CROWNS) in correct display order; old Fiorentine names kept as fallback Code architected by Disco DeDisco <discodedisco@outlook.com> Git commit message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
Data migration: delete 4 stray Earthman court cards that were never cleaned up.
|
||||
|
||||
Maid/Jack/Queen/King of Pentacles (suit=PENTACLES, arcana=MINOR, numbers 11-14)
|
||||
are duplicates of the correct Maid/Jack/Queen/King of Crowns (suit=CROWNS,
|
||||
arcana=MIDDLE) that already exist. The PENTACLES rows appeared before migration
|
||||
0024 could catch them and were never removed.
|
||||
"""
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def delete_stray_pentacles(apps, schema_editor):
|
||||
TarotCard = apps.get_model("epic", "TarotCard")
|
||||
DeckVariant = apps.get_model("epic", "DeckVariant")
|
||||
earthman = DeckVariant.objects.filter(slug="earthman").first()
|
||||
if not earthman:
|
||||
return
|
||||
TarotCard.objects.filter(
|
||||
deck_variant=earthman, suit="PENTACLES", number__in=[11, 12, 13, 14],
|
||||
).delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("epic", "0040_rename_jovent_to_intent"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(delete_stray_pentacles, migrations.RunPython.noop),
|
||||
]
|
||||
@@ -152,7 +152,8 @@ def tarot_fan(request, deck_id):
|
||||
deck = get_object_or_404(DeckVariant, pk=deck_id)
|
||||
if not request.user.unlocked_decks.filter(pk=deck_id).exists():
|
||||
return HttpResponse(status=403)
|
||||
_suit_order = {"WANDS": 0, "CUPS": 1, "SWORDS": 2, "PENTACLES": 3, "CROWNS": 3, "COINS": 4}
|
||||
_suit_order = {"BRANDS": 0, "GRAILS": 1, "BLADES": 2, "CROWNS": 3,
|
||||
"WANDS": 0, "CUPS": 1, "SWORDS": 2, "PENTACLES": 3}
|
||||
cards = sorted(
|
||||
TarotCard.objects.filter(deck_variant=deck),
|
||||
key=lambda c: (0 if c.arcana == "MAJOR" else 1, _suit_order.get(c.suit or "", 9), c.number),
|
||||
|
||||
Reference in New Issue
Block a user