mtg-web/cards/views.py

11 lines
474 B
Python
Executable file

# 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):
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})