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)