Normalized card types

This commit is contained in:
Correl Roush 2010-09-16 14:11:55 -04:00
parent 3f25213bd3
commit 4c9e0ca626
2 changed files with 9 additions and 3 deletions

View file

@ -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)

View file

@ -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)