Get rid of joined_pretty_date in favor of the mixin. models-refactor
authorAnt Zucaro <azucaro@gmail.com>
Sun, 6 Nov 2016 00:17:50 +0000 (20:17 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 6 Nov 2016 00:17:50 +0000 (20:17 -0400)
xonstat/models/player.py
xonstat/templates/player_index.mako
xonstat/templates/player_info.mako
xonstat/templates/search.mako

index 5b7f97b..d9df075 100644 (file)
@@ -8,7 +8,7 @@ from xonstat.models.mixins import FuzzyDateMixin, EpochMixin, NickColorsMixin
 from xonstat.util import strip_colors, pretty_date, qfont_decode
 
 
-class Player(EpochMixin, NickColorsMixin):
+class Player(EpochMixin, NickColorsMixin, FuzzyDateMixin):
     """
     A player, which can represent either a human or a bot.
     """
@@ -19,10 +19,6 @@ class Player(EpochMixin, NickColorsMixin):
         else:
             return strip_colors(self.nick)
 
-    # TODO: use FuzzyDateMixin instead, but change the method calls
-    def joined_pretty_date(self):
-        return pretty_date(self.create_dt)
-
     def __repr__(self):
         return "<Player({}, {})>".format(self.player_id, self.nick.encode('utf-8'))
 
index 6ef400f..c991f70 100644 (file)
@@ -42,7 +42,7 @@
         <tr>
           <td>${player.player_id}</th>
           <td class="no-stretch"><a href="${request.route_url("player_info", id=player.player_id)}" title="Go to this player's info page">${player.nick_html_colors()|n}</a></th>
-          <td><span class="abstime" data-epoch="${player.epoch()}" title="${player.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${player.joined_pretty_date()}</span></th>
+          <td><span class="abstime" data-epoch="${player.epoch()}" title="${player.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${player.fuzzy_date()}</span></th>
           <td class="text-center">
             <a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="View recent games by this player">
               <i class="fa fa-list"></i>
index 2d39e10..956d335 100644 (file)
@@ -66,7 +66,7 @@
     </h2>
 
     <h5>
-      <i><span class="abstime" data-epoch="${player.epoch()}" title="${player.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">Joined ${player.joined_pretty_date()}</span> (player #${player.player_id})</i>
+      <i><span class="abstime" data-epoch="${player.epoch()}" title="${player.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">Joined ${player.fuzzy_date()}</span> (player #${player.player_id})</i>
       % if cake_day:
         <img src="/static/images/icons/24x24/cake.png" title="Happy cake day!" />
       % endif
index 45bf794..69013b0 100644 (file)
             <tr>
               <td>${player.player_id}</th>
               <td class="no-stretch"><a href="${request.route_url("player_info", id=player.player_id)}" title="Go to this player's info page">${player.nick_html_colors()|n}</a></th>
-              <td><span class="abstime" data-epoch="${player.epoch()}" title="${player.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${player.joined_pretty_date()}</span></th>
+              <td><span class="abstime" data-epoch="${player.epoch()}" title="${player.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${player.fuzzy_date()}</span></th>
               <td class="text-center">
                 <a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="View recent games by this player">
                   <i class="fa fa-list"></i>