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 from django.contrib import admin
class CardAdmin(admin.ModelAdmin): class CardAdmin(admin.ModelAdmin):
@ -7,3 +7,4 @@ class CardAdmin(admin.ModelAdmin):
admin.site.register(Card, CardAdmin) admin.site.register(Card, CardAdmin)
admin.site.register(Deck) admin.site.register(Deck)
admin.site.register(CardType)

View file

@ -1,13 +1,18 @@
from django.db import models from django.db import models
from mtgweb.lib.mtg import mtg
# Create your models here. # 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): class Attribute(models.Model):
name = models.CharField(max_length=200, unique=True, db_index=True) name = models.CharField(max_length=200, unique=True, db_index=True)
def __unicode__(self): def __unicode__(self):
return self.name return self.name
class Card(models.Model): class Card(models.Model, mtg.Card):
name = models.CharField(max_length=200, unique=True) name = models.CharField(max_length=200, unique=True)
type = models.CharField(max_length=200) type = models.ForeignKey(CardType)
attributes = models.ManyToManyField(Attribute) attributes = models.ManyToManyField(Attribute)
cost = models.CharField(max_length=80) cost = models.CharField(max_length=80)
converted_cost = models.IntegerField(default=0) converted_cost = models.IntegerField(default=0)