activity: Initially sort rows by time of last activity

Doing this on the server is somewhat easier than making sorttable do it on page load.

(imported from commit 3ed7b127ba874d674d5cfe5b102c62a74be572f8)
This commit is contained in:
Keegan McAllister 2012-12-04 18:05:10 -05:00
parent 3f5d9902ab
commit 23eef06ed0
2 changed files with 5 additions and 1 deletions

View File

@ -21,7 +21,7 @@
</tr>
</thead>
<tbody>
{% for email, row in activity.rows.iteritems %}
{% for email, row in activity.sorted_rows %}
<tr class="{{ row.class }}">
<td><strong>{{ email }}</strong></td>
<td sorttable_customkey="{{ row.get_updates_last|date:'YmdHi' }}">{{ row.get_updates_last }}</td>

View File

@ -990,6 +990,10 @@ class ActivityTable(object):
row['class'] = 'recently_active'
elif age >= datetime.timedelta(days=1):
row['class'] = 'long_inactive'
row['age'] = age
def sorted_rows(self):
return sorted(self.rows.iteritems(), key=lambda (k,r): r['age'])
@login_required(login_url = settings.HOME_NOT_LOGGED_IN)
def get_activity(request):