Made cards database driven
This commit is contained in:
parent
8e1bba2ceb
commit
ccff6b2c88
2 changed files with 12 additions and 13 deletions
|
@ -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})
|
||||
|
|
|
@ -65,21 +65,17 @@
|
|||
<div class="title">
|
||||
<span class="name">{{ card.name|title }}</span>
|
||||
<span class="cost">
|
||||
{% if card.cost %}
|
||||
{% with card.cost as cost %}
|
||||
{% include 'cards/manacost.html' %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<div class="picture"></div>
|
||||
<div class="info">
|
||||
<span class="type">
|
||||
{{ card.type|title }}
|
||||
{% if card.attributes %}
|
||||
—
|
||||
{{ card.attributes|join:" "|title }}
|
||||
{% endif %}
|
||||
{% for attr in card.attributes.all %}
|
||||
{{ attr|title }}
|
||||
{% endfor %}
|
||||
</span>
|
||||
<span class="rarity {{ card.rarity }}">
|
||||
{% for key, rarity in card.rarities.items %}
|
||||
|
@ -89,7 +85,7 @@
|
|||
</div>
|
||||
<div class="text">
|
||||
<ul>
|
||||
{% for ability in card.text %}
|
||||
{% for ability in abilities %}
|
||||
<li>{{ ability }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue