remove all useless .pyc files
authorJess <jessicatz.fairymeadow@gmail.com>
Thu, 28 Aug 2014 20:08:16 +0000 (22:08 +0200)
committerJess <jessicatz.fairymeadow@gmail.com>
Thu, 28 Aug 2014 20:08:16 +0000 (22:08 +0200)
26 files changed:
data/db.sqlite3
db.sqlite3 [deleted file]
meta/__init__.pyc [deleted file]
meta/admin.pyc [deleted file]
meta/management/__init__.pyc [deleted file]
meta/management/commands/__init__.pyc [deleted file]
meta/management/commands/csvimport.pyc [deleted file]
meta/models.py
meta/models.pyc [deleted file]
meta/static/css/main.css
meta/static/js/main.js
meta/templates/base.html
meta/templates/index.html
meta/templates/rate.html
meta/templates/tournament_detail.html [new file with mode: 0644]
meta/templatetags/__init__.py [new file with mode: 0644]
meta/templatetags/meta_extras.py [new file with mode: 0644]
meta/views.py
meta/views.pyc [deleted file]
mlpccg-web/__init__.pyc [deleted file]
mlpccg-web/settings.py
mlpccg-web/settings.pyc [deleted file]
mlpccg-web/urls.py
mlpccg-web/urls.pyc [deleted file]
mlpccg-web/wsgi.pyc [deleted file]
mlpccg/DeckList.py

index 40ec1ede2c3d57076dd0396d2a596a377942d7cc..1638b65949f57f631b3ac32ddaf7b1ae9783d896 100644 (file)
Binary files a/data/db.sqlite3 and b/data/db.sqlite3 differ
diff --git a/db.sqlite3 b/db.sqlite3
deleted file mode 100644 (file)
index d711bb8..0000000
Binary files a/db.sqlite3 and /dev/null differ
diff --git a/meta/__init__.pyc b/meta/__init__.pyc
deleted file mode 100644 (file)
index 20b49d6..0000000
Binary files a/meta/__init__.pyc and /dev/null differ
diff --git a/meta/admin.pyc b/meta/admin.pyc
deleted file mode 100644 (file)
index 4bfd4dd..0000000
Binary files a/meta/admin.pyc and /dev/null differ
diff --git a/meta/management/__init__.pyc b/meta/management/__init__.pyc
deleted file mode 100644 (file)
index 859abf5..0000000
Binary files a/meta/management/__init__.pyc and /dev/null differ
diff --git a/meta/management/commands/__init__.pyc b/meta/management/commands/__init__.pyc
deleted file mode 100644 (file)
index a39dec7..0000000
Binary files a/meta/management/commands/__init__.pyc and /dev/null differ
diff --git a/meta/management/commands/csvimport.pyc b/meta/management/commands/csvimport.pyc
deleted file mode 100644 (file)
index e920111..0000000
Binary files a/meta/management/commands/csvimport.pyc and /dev/null differ
index 7ba79466c6f04a6bbc465905d1d76f80f7383258..3eb55fb2299e5fbd999b9f5f1b53d495b131b7ed 100644 (file)
@@ -10,6 +10,7 @@ class DeckListModel(models.Model):
 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'))
diff --git a/meta/models.pyc b/meta/models.pyc
deleted file mode 100644 (file)
index bcc1dae..0000000
Binary files a/meta/models.pyc and /dev/null differ
index b4765a10612ab4df6551475d84a85d4234fddb04..23f44610489c344cb4a94988e9d265165cfe859a 100644 (file)
@@ -1,11 +1,40 @@
-
-
-/* ==========================================================================
-   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
index a2614b3ab51e93efdabab964fc38df9c899ee168..8f2924a0a591b1afe4d1f16f64ed11bdc5b158a0 100644 (file)
@@ -5,16 +5,18 @@ function rateDeck() {
 }
 
 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()
     });
index 240be55ecf3fcec77023dc0dcb3f2c3724813d91..0b5a25dea2a54a0fc6884eaa36301c4f73f4c934 100644 (file)
         <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>
@@ -35,7 +36,7 @@
             <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>&copy; Yukkuri Games, 2014</p>
       </footer>
index e4f9e6f72f3ac1d6be0e57c25bfa9b3f148c9866..c307f261fcb53b8493dc6b5d08a500e684b33ae8 100644 (file)
@@ -1,4 +1,5 @@
 {% extends "base.html" %}
+{% load meta_extras %}
 
 {% block jumbotron %}
 <div class="jumbotron">
@@ -11,7 +12,7 @@
         {% 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>
@@ -61,7 +62,7 @@
       {% 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 %}
index 939b2021b80324050a1a5579155201ad5523bc8f..196c59ef9a2848e6c567858d41299490585e5bac 100644 (file)
@@ -7,13 +7,13 @@
   <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>
 
diff --git a/meta/templates/tournament_detail.html b/meta/templates/tournament_detail.html
new file mode 100644 (file)
index 0000000..f2d3ffc
--- /dev/null
@@ -0,0 +1,27 @@
+{% 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 %}
diff --git a/meta/templatetags/__init__.py b/meta/templatetags/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/meta/templatetags/meta_extras.py b/meta/templatetags/meta_extras.py
new file mode 100644 (file)
index 0000000..6f56fd0
--- /dev/null
@@ -0,0 +1,8 @@
+from django import template
+
+register = template.Library()
+
+@register.filter
+def deckicon(decklist):
+    #mane, aspects = decklist.aspects
+    return decklist.description
index a1cf06be9c5b3466152e379c4319112d6d88be1b..0f71d00288bdb33b2c1ed4fcb3345b1d0e604a77 100644 (file)
@@ -1,10 +1,10 @@
-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
@@ -24,15 +24,47 @@ def index(request):
 
     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)
@@ -46,4 +78,5 @@ def rate(request):
 
     return render(request, 'rate.html', {
         'deck': decklist,
-        'similiar': similiar}, context_instance=RequestContext(request))
+        'similiar': similiar
+    }, context_instance=RequestContext(request))
diff --git a/meta/views.pyc b/meta/views.pyc
deleted file mode 100644 (file)
index cde0787..0000000
Binary files a/meta/views.pyc and /dev/null differ
diff --git a/mlpccg-web/__init__.pyc b/mlpccg-web/__init__.pyc
deleted file mode 100644 (file)
index 978e32d..0000000
Binary files a/mlpccg-web/__init__.pyc and /dev/null differ
index 1da064d3a5d3c2fa19604f8424836539acbb0359..5f311eb473cb37596cbcfdee6037b96084f1c82f 100644 (file)
@@ -60,7 +60,7 @@ WSGI_APPLICATION = 'mlpccg-web.wsgi.application'
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+        'NAME': os.path.join(BASE_DIR, 'data/db.sqlite3'),
     }
 }
 
diff --git a/mlpccg-web/settings.pyc b/mlpccg-web/settings.pyc
deleted file mode 100644 (file)
index 522ed8e..0000000
Binary files a/mlpccg-web/settings.pyc and /dev/null differ
index 2c05e731a94c8247ba6a16b0463a2307862c4257..f00f3e842d44b482a02bdb57f3b8be5d052b80c3 100644 (file)
@@ -9,5 +9,6 @@ urlpatterns = patterns(
     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')
 )
diff --git a/mlpccg-web/urls.pyc b/mlpccg-web/urls.pyc
deleted file mode 100644 (file)
index ae1775f..0000000
Binary files a/mlpccg-web/urls.pyc and /dev/null differ
diff --git a/mlpccg-web/wsgi.pyc b/mlpccg-web/wsgi.pyc
deleted file mode 100644 (file)
index 7def173..0000000
Binary files a/mlpccg-web/wsgi.pyc and /dev/null differ
index 5ff46bf9d6ec720dc5f20f552da6fee2a8d2aa1a..ec576456dbebf93b51238d740c76d383ef710a46 100644 (file)
@@ -57,7 +57,7 @@ class DeckList:
     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()]