var tournaments = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.nonword('name'),
queryTokenizer: Bloodhound.tokenizers.nonword,
- prefetch: '/tournaments'
+ prefetch: '/tournaments_json'
});
tournaments.clearPrefetchCache()
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="{% url 'meta.views.index' %}">meta is magic</a>
- </div>
- <div class="navbar-right">
- <a class="navbar-brand" href="{% url 'meta.views.index' %}">BETA</a>
+ <a class="navbar-brand" href="{% url 'meta.views.index' %}">meta is magic BETA</a>
</div>
<!-- <div class="navbar-collapse collapse"> -->
<!-- <form class="navbar-form navbar-right" 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"/>
+ <input type="url" name="url" class="form-control input-lg" id="ponyheadURL" placeholder="PonyHead URL"/>
<button type="submit" class="btn btn-lg btn-default btn-primary">Tell me!</button>
</div>
</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"/>
+ <input type="url" name="url" class="form-control input-lg" id="ponyheadURL" placeholder="PonyHead URL"/>
+ <label class="sr-only" for="decklistName">decklist name</label>
+ <input type="text" name="text" class="form-control input-lg" id="decklistName" placeholder="Deck name (optional)"/>
<button type="submit" class="btn btn-lg btn-default btn-primary">Add me!</button>
</div>
</form>
'tournaments': tournament_data
}, context_instance=RequestContext(request))
-def tournaments(request):
+def tournaments_json(request):
return HttpResponse(json.dumps([{'name': t.name, 'id': t.id} for t in TournamentModel.objects.all()]),
content_type='application/json')
'records': records,
'tournament': tournament})
+def decklists(request):
+ decklists = DeckListModel.objects.all()
+
+ return render(request, 'decklists.html', {
+ 'decklists': decklists})
+
+def decklists_detail(request, decklist_id):
+ decklist = get_object_or_404(DeckListModel, pk=decklist_id)
+
+ return render(request, 'decklists_detail.html', {
+ 'decklist': decklist})
+
def rate(request):
- decklist = DeckList(url=request.POST['url'])
+ url = request.POST.get('url', 'v1code=%s' % request.GET.get('v1code'))
+
+ decklist = DeckList(url=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:
url(r'^admin/', include(admin.site.urls)),
url(r'^$', 'meta.views.index'),
url(r'^rate$', 'meta.views.rate'),
- url(r'^tournaments$', 'meta.views.tournaments'),
- url(r'^tournaments/(?P<tournament_id>\d+)$', 'meta.views.tournaments_detail')
+ url(r'^tournaments_json$', 'meta.views.tournaments_json'),
+ url(r'^tournaments/(?P<tournament_id>\d+)$', 'meta.views.tournaments_detail'),
+ url(r'^decklists$', 'meta.views.decklists')
)