Commits

Juan Martínez committed ca8ea19

Added "medals" to the ratings page

- used fixed width font, limit the displayed titles (long names)
- added icons for "medals": a game controller, based in Tango icon (public domain)

  • Participants
  • Parent commits 0c88af4

Comments (0)

Files changed (6)

File pyweek/challenge/media/bronze.png

Added
New image

File pyweek/challenge/media/challenge.css

     float: left;
 }
 
+span.prize {
+    display: block-inline;
+    padding-left: 24px;
+    padding-right: 4px;
+    font-family: fixed;
+    background-repeat: no-repeat;
+    background-position: left top;
+    line-height: 18px;
+}
+span.gold {
+    background-image: url('gold.png');
+}
+span.silver {
+    background-image: url('silver.png');
+}
+span.bronze {
+    background-image: url('bronze.png');
+}
+
 ul.errorlist {
     background: rgb(255,214,214);
     margin: 0px;

File pyweek/challenge/media/gold.png

Added
New image

File pyweek/challenge/media/silver.png

Added
New image

File pyweek/challenge/models.py

         return [e for e in Entry.objects.filter(winner=self.number) if e.is_team()]
 
 class Entry(models.Model):
+    SHORT_TITLE_LEN = 14
+
     name = models.CharField(max_length=15, primary_key=True,
         validators=[validators.validate_slug])
     title = models.CharField(max_length=100)
     def __unicode__(self):
         return u'Entry "%s"' % (self.name.decode('utf8', 'replace'), )
 
+    @property
+    def short_title(self):
+        if len(self.title) <= Entry.SHORT_TITLE_LEN:
+            return self.title
+        return u"%s..." % self.title[:Entry.SHORT_TITLE_LEN]
+
     def is_team(self):
         return len(self.users.all()) > 1
 

File pyweek/challenge/templates/challenge/ratings.html

 <tr>
   <td>
     {% for rating in individual_overall %}
-      ({{ rating.overall|floatformat:2  }}) <a href="/e/{{ rating.entry.name }}/">{{ rating.entry.title }}</a><br/>
+    <span class="prize {% cycle "gold" "silver" "bronze" %}">{{ rating.overall|floatformat:2  }}</span> <a href="/e/{{ rating.entry.name }}/" title="{{ rating.entry.title }}">{{ rating.entry.short_title }}</a><br />
     {% endfor %}
   </td>
   <td>
     {% for rating in individual_fun %}
-      ({{ rating.fun|floatformat:2  }}) <a href="/e/{{ rating.entry.name }}/">{{ rating.entry.title }}</a><br/>
+    <span class="prize {% cycle "gold" "silver" "bronze" %}">{{ rating.fun|floatformat:2  }}</span> <a href="/e/{{ rating.entry.name }}/" title="{{ rating.entry.title }}">{{ rating.entry.short_title }}</a><br/>
     {% endfor %}
   </td>
   <td>
     {% for rating in individual_inno %}
-    ({{ rating.innovation|floatformat:2  }}) <a href="/e/{{ rating.entry.name }}/">{{ rating.entry.title }}</a><br/>
+    <span class="prize {% cycle "gold" "silver" "bronze" %}">{{ rating.innovation|floatformat:2  }}</span> <a href="/e/{{ rating.entry.name }}/" title="{{ rating.entry.title }}">{{ rating.entry.short_title }}</a><br/>
     {% endfor %}
   </td>
   <td>
     {% for rating in individual_prod %}
-    ({{ rating.production|floatformat:2  }}) <a href="/e/{{ rating.entry.name }}/">{{ rating.entry.title }}</a><br/>
+    <span class="prize {% cycle "gold" "silver" "bronze" %}">{{ rating.production|floatformat:2  }}</span> <a href="/e/{{ rating.entry.name }}/" title="{{ rating.entry.title }}">{{ rating.entry.short_title }}</a><br/>
     {% endfor %}
   </td>
 </tr>
 <tr>
   <td>
     {% for rating in team_overall %}
-    ({{ rating.overall|floatformat:2  }}) <a href="/e/{{ rating.entry.name }}/">{{ rating.entry.title }}</a><br/>
+    <span class="prize {% cycle "gold" "silver" "bronze" %}">{{ rating.overall|floatformat:2  }}</span> <a href="/e/{{ rating.entry.name }}/" title="{{ rating.entry.title }}">{{ rating.entry.short_title }}</a><br/>
     {% endfor %}
   </td>
   <td>
     {% for rating in team_fun %}
-    ({{ rating.fun|floatformat:2  }}) <a href="/e/{{ rating.entry.name }}/">{{ rating.entry.title }}</a><br/>
+    <span class="prize {% cycle "gold" "silver" "bronze" %}">{{ rating.fun|floatformat:2  }}</span> <a href="/e/{{ rating.entry.name }}/" title="{{ rating.entry.title }}">{{ rating.entry.short_title }}</a><br/>
     {% endfor %}
   </td>
   <td>
     {% for rating in team_inno %}
-    ({{ rating.innovation|floatformat:2  }}) <a href="/e/{{ rating.entry.name }}/">{{ rating.entry.title }}</a><br/>
+    <span class="prize {% cycle "gold" "silver" "bronze" %}">{{ rating.innovation|floatformat:2  }}</span> <a href="/e/{{ rating.entry.name }}/" title="{{ rating.entry.title }}">{{ rating.entry.short_title }}</a><br/>
     {% endfor %}
   </td>
   <td>
     {% for rating in team_prod %}
-    ({{ rating.production|floatformat:2  }}) <a href="/e/{{ rating.entry.name }}/">{{ rating.entry.title }}</a><br/>
+    <span class="prize {% cycle "gold" "silver" "bronze" %}">{{ rating.production|floatformat:2  }}</span> <a href="/e/{{ rating.entry.name }}/" title="{{ rating.entry.title }}">{{ rating.entry.short_title }}</a><br/>
     {% endfor %}
   </td>
 </tr>