From 4c9e0ca6262b9b142da1aac5e94e3fda92754459 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Thu, 16 Sep 2010 14:11:55 -0400 Subject: [PATCH] Normalized card types --- analyzer/admin.py | 3 ++- analyzer/models.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/analyzer/admin.py b/analyzer/admin.py index 14f7653..0d8b339 100644 --- a/analyzer/admin.py +++ b/analyzer/admin.py @@ -1,4 +1,4 @@ -from mtgweb.analyzer.models import Deck, Card +from mtgweb.analyzer.models import Deck, Card, CardType from django.contrib import admin class CardAdmin(admin.ModelAdmin): @@ -7,3 +7,4 @@ class CardAdmin(admin.ModelAdmin): admin.site.register(Card, CardAdmin) admin.site.register(Deck) +admin.site.register(CardType) diff --git a/analyzer/models.py b/analyzer/models.py index 8349098..36178a4 100755 --- a/analyzer/models.py +++ b/analyzer/models.py @@ -1,13 +1,18 @@ from django.db import models +from mtgweb.lib.mtg import mtg # Create your models here. +class CardType(models.Model): + name = models.CharField(max_length=200, unique=True, db_index=True) + def __unicode__(self): + return self.name class Attribute(models.Model): name = models.CharField(max_length=200, unique=True, db_index=True) def __unicode__(self): return self.name -class Card(models.Model): +class Card(models.Model, mtg.Card): name = models.CharField(max_length=200, unique=True) - type = models.CharField(max_length=200) + type = models.ForeignKey(CardType) attributes = models.ManyToManyField(Attribute) cost = models.CharField(max_length=80) converted_cost = models.IntegerField(default=0)