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 40ec1ed..1638b65 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 7ba7946..3eb55fb 100644 (file)
@@ -10,6 +10,7 @@ class DeckListModel(models.Model):
 class TournamentModel(models.Model):
     name = models.CharField(max_length=200)
     date = models.DateField()
 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'))
 
     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 b4765a1..23f4461 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 a2614b3..8f2924a 100644 (file)
@@ -5,16 +5,18 @@ function rateDeck() {
 }
 
 var tournaments = new Bloodhound({
 }
 
 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() {
 tournaments.initialize();
 
 $(document).ready(function() {
-    $('.typeahead-tournaments').typeahead(null, {
-        name: 'tournaments',
+    $('.typeahead-tournaments').typeahead({
+        highlight: true
+    }, {
         displayKey: 'name',
         source: tournaments.ttAdapter()
     });
         displayKey: 'name',
         source: tournaments.ttAdapter()
     });
index 240be55..0b5a25d 100644 (file)
         <meta name="viewport" content="width=device-width, initial-scale=1">
 
         <link rel="stylesheet" href="{{STATIC_URL}}css/bootstrap.min.css">
         <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>
         <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>
         <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>
             <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>
         <!-- <div class="navbar-collapse collapse"> -->
         <!--   <form class="navbar-form navbar-right" role="form"> -->
 
     <div class="container">
       {% block content %}{% endblock %}
 
     <div class="container">
       {% block content %}{% endblock %}
-      <hr>
+    </div>
 
 
+    {% block jumbotron_end %}<hr/>{% endblock %}
+
+    <div class="container">
       <footer>
         <p>&copy; Yukkuri Games, 2014</p>
       </footer>
       <footer>
         <p>&copy; Yukkuri Games, 2014</p>
       </footer>
index e4f9e6f..c307f26 100644 (file)
@@ -1,4 +1,5 @@
 {% extends "base.html" %}
 {% extends "base.html" %}
+{% load meta_extras %}
 
 {% block jumbotron %}
 <div class="jumbotron">
 
 {% 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>
         {% 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>
           <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>
     <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>
         <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 %}
         <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>
             {% endfor %}
           </ul>
         </td>
@@ -61,7 +62,7 @@
       {% for t in tournaments %}
       <tr>
         <td>{{ t.tournament.date }}</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/>
         <td>
           {% for d in t.decklists|slice:":8" %}
           <a href="{{ d.ponyhead_link }}">{{ d.name }} ({{ d.description }})</a><br/>
   </div>
 </div>
 {% endblock %}
   </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 939b202..196c59e 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>
   <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>
     <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>
     {% for deck, record in similiar reversed %}
       <tr class="{% if not record.verified %}warning{% endif %}">
       </tr>
     {% endfor %}
       <tr>
       </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>
       </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">
         {% 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>
           <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="1">1st</option>
               <option value="2">2nd</option>
               <option value="3">3rd</option>
               <option value="8">8th</option>
             </select>
           </td>
               <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>
           <td><button type="submit" class="btn btn-primary">Submit</button></td>
         </tr>
-      </form>
     </table>
     </table>
+    </form>
   </div>
 </div>
 
   </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 a1cf06b..0f71d00 100644 (file)
@@ -1,10 +1,10 @@
-import datetime
+from datetime import datetime
 import difflib
 import json
 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 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
 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,
 
     return render(request, 'index.html', {
         'ranking': ranking,
-        'tournaments': tournament_data},
-                  context_instance=RequestContext(request))
+        'tournaments': tournament_data
+    }, context_instance=RequestContext(request))
 
 def tournaments(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'])
 
 
 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)
     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,
 
     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 1da064d..5f311eb 100644 (file)
@@ -60,7 +60,7 @@ WSGI_APPLICATION = 'mlpccg-web.wsgi.application'
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.sqlite3',
 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 2c05e73..f00f3e8 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.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 5ff46bf..ec57645 100644 (file)
@@ -57,7 +57,7 @@ class DeckList:
     def ponyhead_link(self):
         cards = defaultdict(int)
         for card in self.cards:
     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()]
 
 
         cards = ['%sx%d' % (id, amount) for id, amount in cards.iteritems()]