class TournamentModel(models.Model):
name = models.CharField(max_length=200)
date = models.DateField()
+ verified = models.BooleanField()
def __unicode__(self):
return '%s (%s)' % (self.name, self.date.strftime('%Y-%m-%d'))
-
-
-/* ==========================================================================
- Author's custom styles
- ========================================================================== */
-
-
-
-
-
-
+.tt-dropdown-menu {
+ width: 422px;
+ margin-top: 12px;
+ padding: 8px 0;
+ background-color: #fff;
+ border: 1px solid# ccc;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ -webkit-border-radius: 8px;
+ moz-border-radius: 8px;
+ border-radius: 8px;
+ -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
+ -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
+ box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
+}
+
+.tt-query {
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+}
+
+.tt-hint {
+ color: #999
+}
+
+.tt-suggestion {
+ padding: 3px 20px;
+ /* font-size: 18px; */
+ /* line-height: 24px; */
+}
+
+.tt-suggestion.tt-cursor {
+ color: #fff;
+ background-color: #0097cf;
+
+}
+
+.tt-suggestion p {
+ margin: 0;
+}
\ No newline at end of file
}
var tournaments = new Bloodhound({
- datumTokenizer: Bloodhound.tokenizers.obj.nonword('name'),
- queryTokenizer: Bloodhound.tokenizers.nonword,
- prefetch: '/meta/tournaments'
+ datumTokenizer: Bloodhound.tokenizers.obj.nonword('name'),
+ queryTokenizer: Bloodhound.tokenizers.nonword,
+ prefetch: '/meta/tournaments'
});
+tournaments.clearPrefetchCache()
tournaments.initialize();
$(document).ready(function() {
- $('.typeahead-tournaments').typeahead(null, {
- name: 'tournaments',
+ $('.typeahead-tournaments').typeahead({
+ highlight: true
+ }, {
displayKey: 'name',
source: tournaments.ttAdapter()
});
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{{STATIC_URL}}css/bootstrap.min.css">
+ <link rel="stylesheet" href="{{STATIC_URL}}css/bootstrap-theme.min.css">
+
<style>
body {
padding-top: 50px;
padding-bottom: 20px;
}
</style>
- <link rel="stylesheet" href="{{STATIC_URL}}css/bootstrap-theme.min.css">
- <link rel="stylesheet" href="{{STATIC_URL}}css/main.css">
+ <link rel="stylesheet" href="{{STATIC_URL}}css/main.css">
<script src="{{STATIC_URL}}js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>
<body>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
- <a class="navbar-brand" href="#">meta is magic</a>
+ <a class="navbar-brand" href="/meta">meta is magic</a>
</div>
<!-- <div class="navbar-collapse collapse"> -->
<!-- <form class="navbar-form navbar-right" role="form"> -->
<div class="container">
{% block content %}{% endblock %}
- <hr>
+ </div>
+ {% block jumbotron_end %}<hr/>{% endblock %}
+
+ <div class="container">
<footer>
<p>© Yukkuri Games, 2014</p>
</footer>
{% extends "base.html" %}
+{% load meta_extras %}
{% block jumbotron %}
<div class="jumbotron">
{% csrf_token %}
<div class="form-group">
<label class="sr-only" for="ponyheadURL">ponyhead decklist url</label>
- <input type="url" name="url" class="form-control input-lg" id="ponyheadURL" placeholder="Deck URL, e.g.: http://ponyhead.com/deckbuilder?v1code=..."/>
+ <input type="url" name="url" class="form-control input-lg" id="ponyheadURL" placeholder="Deck URL"/>
<button type="submit" class="btn btn-lg btn-default btn-primary">Tell me!</button>
</div>
</form>
<p>Very fuzzy data, based on past tournaments. The more the deck was played in tournaments, the more accurate this is.</p>
<table class="table">
<tr>
- <th>Archetype ID</th>
+ <!-- <th>Archetype ID</th> -->
<th>Average placement</th>
<th>Example decks</th>
</tr>
{% load humanize %}
{% for avg, label, decks in ranking %}
<tr>
- <td>{{ label }}</td>
+ <!-- <td>{{ label }}</td> -->
<td>{{ avg|ordinal }}</td>
<td>
<ul class="list-inline">
{% for d in decks %}
- <li><a href="{{ d.ponyhead_link }}">{{ d.description }}</a></li>
+ <li><a href="{{ d.ponyhead_link }}">{{ d.name }}</a></li>
{% endfor %}
</ul>
</td>
{% for t in tournaments %}
<tr>
<td>{{ t.tournament.date }}</td>
- <td>{{ t.tournament.name }}</td>
+ <td><a href="/meta/tournaments/{{ t.tournament.id }}">{{ t.tournament.name }}</a></td>
<td>
{% for d in t.decklists|slice:":8" %}
<a href="{{ d.ponyhead_link }}">{{ d.name }} ({{ d.description }})</a><br/>
</div>
</div>
{% endblock %}
+
+{% block jumbotron_end %}
+<div class="jumbotron">
+ <div class="container">
+ <h2>Is your deck not in the list?</h2>
+ <p> Paste your <a href="http://ponyhead.com/deckbuilder">ponyhead.com</a> URL here and help make this site better!</p>
+ <p>
+ <form action="/meta/rate" method="post" class="form-inline" role="form">
+ {% csrf_token %}
+ <div class="form-group">
+ <label class="sr-only" for="ponyheadURL">ponyhead decklist url</label>
+ <input type="url" name="url" class="form-control input-lg" id="ponyheadURL" placeholder="Deck URL"/>
+ <button type="submit" class="btn btn-lg btn-default btn-primary">Add me!</button>
+ </div>
+ </form>
+ </p>
+ </div>
+</div>
+{% endblock %}
<div class="col-xs-12">
<h2><a href="{{ deck.ponyhead_link }}">{{ deck.description }}</a></h2>
<p>Decks similiar to yours and their placement in past tournaments:</p>
+ <form class="form" action="/meta/rate" method="post" role="form">
<table class="table">
<tr>
<th>Deck</th>
<th>Placement</th>
<th>Tournament</th>
- <th>Date</th>
- <th>Notes</th>
+ <th colspan="2">Date</th>
</tr>
{% for deck, record in similiar reversed %}
<tr class="{% if not record.verified %}warning{% endif %}">
</tr>
{% endfor %}
<tr>
- <td colspan="5"><strong>Played this deck in a tournament? Add your result here!</strong></td>
+ <td colspan="5">
+ <strong>Played this deck in a tournament? Add your result here!</strong>
+ <p class="help-block">This helps you and us to get a better overview over the meta-game.</p>
+ </td>
</tr>
- <form class="form-inline" action="/meta/rate" method="post" role="form">
{% csrf_token %}
<input type="hidden" name="url" value="{{ deck.ponyhead_link }}"/>
<tr class="info">
- <td><input type="text" name="deck_name" class="form-control" placeholder="Deck name"/></td>
+ <td><input type="text" name="d_name" class="form-control" placeholder="Deck name"/></td>
<td>
- <select name="placement" class="form-control">
+ <select name="t_placement" class="form-control">
<option value="1">1st</option>
<option value="2">2nd</option>
<option value="3">3rd</option>
<option value="8">8th</option>
</select>
</td>
- <td><input type="text" name="name" class="form-control typeahead-tournaments" placeholder="Tournament name"/></td>
- <td><input type="date" name="date" class="form-control"/></td>
+ <td><input type="text" name="t_name" class="form-control typeahead-tournaments" placeholder="Tournament name"/></td>
+ <td><input type="date" name="t_date" class="form-control"/></td>
<td><button type="submit" class="btn btn-primary">Submit</button></td>
</tr>
- </form>
</table>
+ </form>
</div>
</div>
--- /dev/null
+{% extends "base.html" %}
+{% load humanize %}
+
+{% block content %}
+
+<div class="row">
+ <div class="col-xs-12">
+ <h2>{{ tournament.name }}</h2>
+ <p>{{ tournament.date }}</h2>
+ <table class="table">
+ <tr>
+ <th>Placement</th>
+ <th colspan="3">Deck</th>
+ </tr>
+ {% for placement, decklist, verified in records %}
+ <tr class="{% if not verified %}warning{% endif %}">
+ <td>{{ placement|ordinal }}</td>
+ <td><a href="{{ decklist.ponyhead_link }}">{{ decklist.name }}</a></td>
+ <td>{{ decklist.description }}</td>
+ <td>{% if not verified %}user-submitted{% endif %}</td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+</div>
+
+{% endblock %}
--- /dev/null
+from django import template
+
+register = template.Library()
+
+@register.filter
+def deckicon(decklist):
+ #mane, aspects = decklist.aspects
+ return decklist.description
-import datetime
+from datetime import datetime
import difflib
import json
-from django.shortcuts import render
+from django.shortcuts import render, get_object_or_404
from django.template import RequestContext
from django.http import HttpResponse
-from meta.models import TournamentModel, RecordModel
+from meta.models import TournamentModel, RecordModel, DeckListModel
from mlpccg.CardDb import CARDDB
from mlpccg.DeckList import DeckList
from mlpccg.Clustering import Clustering
return render(request, 'index.html', {
'ranking': ranking,
- 'tournaments': tournament_data},
- context_instance=RequestContext(request))
+ 'tournaments': tournament_data
+ }, context_instance=RequestContext(request))
def tournaments(request):
- return HttpResponse(json.dumps([{'name': t.name} for t in TournamentModel.objects.all()]), content_type='application/json')
+ return HttpResponse(json.dumps([{'name': t.name, 'id': t.id} for t in TournamentModel.objects.all()]),
+ content_type='application/json')
+
+def tournaments_detail(request, tournament_id):
+ tournament = get_object_or_404(TournamentModel, pk=tournament_id)
+ records = [(record.placement,
+ DeckList(name=record.decklist.name, url=record.decklist.url),
+ record.verified) for record in tournament.recordmodel_set.all()]
+
+ records.sort(key=lambda x: x[0])
+
+ return render(request, 'tournament_detail.html', {
+ 'records': records,
+ 'tournament': tournament})
def rate(request):
decklist = DeckList(url=request.POST['url'])
+ if request.POST.get('d_name') and request.POST.get('t_date') and request.POST.get('t_name') and request.POST.get('t_placement'):
+ try:
+ tournament = TournamentModel.objects.get(name__iexact=request.POST['t_name'])
+
+ except TournamentModel.DoesNotExist:
+ tournament = TournamentModel(name=request.POST['t_name'],
+ date=datetime.strptime(request.POST['t_date'], '%Y-%m-%d'),
+ verified=False)
+ tournament.save()
+
+ decklist_model = DeckListModel(name=request.POST['d_name'], url=request.POST['url'])
+ decklist_model.save()
+
+ record = RecordModel(placement=request.POST['t_placement'],
+ tournament=tournament,
+ decklist=decklist_model,
+ verified=False)
+ record.save()
+
records = RecordModel.objects.all()
placements = [{'decklist': DeckList(name=record.decklist.name, url=record.decklist.url), 'placement': record.placement, 'record': record} for record in records if record.decklist.url]
clustering = Clustering(records=placements)
return render(request, 'rate.html', {
'deck': decklist,
- 'similiar': similiar}, context_instance=RequestContext(request))
+ 'similiar': similiar
+ }, context_instance=RequestContext(request))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+ 'NAME': os.path.join(BASE_DIR, 'data/db.sqlite3'),
}
}
url(r'^$', 'meta.views.index'),
url(r'^meta/$', 'meta.views.index'),
url(r'^meta/rate$', 'meta.views.rate'),
- url(r'^meta/tournaments', 'meta.views.tournaments')
+ url(r'^meta/tournaments$', 'meta.views.tournaments'),
+ url(r'^meta/tournaments/(?P<tournament_id>\d+)$', 'meta.views.tournaments_detail')
)
def ponyhead_link(self):
cards = defaultdict(int)
for card in self.cards:
- cards[card['id'].replace('f', 'F')] += 1
+ cards[card['id'].replace('pf', 'PF').replace('f', 'F')] += 1
cards = ['%sx%d' % (id, amount) for id, amount in cards.iteritems()]