Skip to content

Commit

Permalink
Sort by taboo victories
Browse files Browse the repository at this point in the history
  • Loading branch information
sometimesok committed Jun 1, 2020
1 parent 74930fa commit d0ec9cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ISS/static-src/src/user-index/user-index.less
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,15 @@
width: 100px;
}

.taboo-victories {
width: 400px;
}

.spam-cell {
width: 70px;
}

.avatar-cell, .join-date, .post-count, .spam-cell {
.avatar-cell, .join-date, .post-count, .taboo-victories, .spam-cell {
text-align: center
}
}
Expand Down
1 change: 1 addition & 0 deletions ISS/templates/user_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ <h2>
<option value="id">Sort by ID</option>
<option value="username">Sort by Username</option>
<option value="post_count">Sort by Post Count</option>
<option value="taboo_successes">Sort by Taboo Victories</option>
</select>
<input type="submit" value="Go" />
</form>
Expand Down
6 changes: 6 additions & 0 deletions ISS/templates/user_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<th class="name-cell">Username</th>
<th class="join-date">Join Date</th>
<th class="post-count">Posts</th>
<th class="taboo-victories">Taboo Victories</th>
{% if user.is_authenticated and user.is_admin %}
<th class="spam-cell">SPAM</th>
{% endif %}
Expand Down Expand Up @@ -41,6 +42,11 @@
{{ poster.post_set.count|intcomma }}
</a>
</td>
<td class="taboo-victories">
<a href="{% url 'taboo-status' %}">
{{ poster.taboo_successes.count|intcomma }}
</a>
</td>
{% if user.is_authenticated and user.is_admin %}
<td class="spam-cell">
<a href="{% url 'spam-can-user' poster.pk %}?next={{ request.get_full_path }}"
Expand Down
4 changes: 4 additions & 0 deletions ISS/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ def GET(self, request):
posters = Poster.objects.all().order_by('username')
elif sortBy == 'id':
posters = Poster.objects.all().order_by('id')
elif sortBy == 'taboo_successes':
posters = (Poster.objects
.annotate(taboo_count=Count('taboo_successes'))
.order_by('-taboo_count'))
else:
raise PermissionDenied('Invalid sortby value')

Expand Down

0 comments on commit d0ec9cc

Please sign in to comment.