diff --git a/cards/views.py b/cards/views.py index 0ea2027..c291733 100755 --- a/cards/views.py +++ b/cards/views.py @@ -1,8 +1,11 @@ # Create your views here. from django.shortcuts import render_to_response +from mtgweb.analyzer.models import Card +from mtgweb.lib.mtg.mtg import ManaCost import mtgweb.lib.mtg.database as database def display(request, name): - db = database.TextDB('/home/correlr/code/mtgweb/lib/mtg/db.txt') - card = db.getCard(name.replace('_', ' ').strip()) - return render_to_response('cards/view.html', {'card': card}) + card = Card.objects.get(name=name) + cost = ManaCost(str(card.cost)) + abilities = [ability for ability in card.text.split("\n") if ability] + return render_to_response('cards/view.html', {'card': card, 'cost': cost, 'abilities': abilities}) diff --git a/templates/cards/view.html b/templates/cards/view.html index 315ee3e..1a53393 100755 --- a/templates/cards/view.html +++ b/templates/cards/view.html @@ -65,21 +65,17 @@
{{ card.name|title }} - {% if card.cost %} - {% with card.cost as cost %} - {% include 'cards/manacost.html' %} - {% endwith %} - {% endif %} + {% include 'cards/manacost.html' %}
{{ card.type|title }} - {% if card.attributes %} - — - {{ card.attributes|join:" "|title }} - {% endif %} + — + {% for attr in card.attributes.all %} + {{ attr|title }} + {% endfor %} {% for key, rarity in card.rarities.items %} @@ -89,7 +85,7 @@