aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar momothereal <[email protected]>2018-06-19 23:30:28 -0400
committerGravatar momothereal <[email protected]>2018-06-19 23:30:28 -0400
commitc7f13a187300dc9eb936aaa00843ce9ed7a547f5 (patch)
tree3ea77dddd0ac9c64b86458fdb122f98a1889c7bd
parentAdd GitLab button next to username (diff)
Cleanup team list querying, add tooltip to Gitlab user button
-rw-r--r--pysite/views/main/jams/teams_list.py (renamed from pysite/views/main/jams/team.py)25
-rw-r--r--templates/main/jams/teams_list.html12
2 files changed, 16 insertions, 21 deletions
diff --git a/pysite/views/main/jams/team.py b/pysite/views/main/jams/teams_list.py
index f266536d..ed4f0748 100644
--- a/pysite/views/main/jams/team.py
+++ b/pysite/views/main/jams/teams_list.py
@@ -1,3 +1,5 @@
+import rethinkdb
+
from pysite.base_route import RouteView
from pysite.mixins import DBMixin, OAuthMixin
@@ -22,25 +24,16 @@ class JamsTeamView(RouteView, DBMixin, OAuthMixin):
"gitlab_username":
self.db.query("code_jam_participants").filter({"id": user["user_id"]})
.coerce_to("array")[0]["gitlab_username"]
- }).coerce_to("array")
+ }).coerce_to("array"),
+ "jam":
+ self.db.query("code_jams").filter(
+ lambda jam: jam["teams"].contains(team["id"])
+ ).coerce_to("array")[0]
}
- )
+ ).order_by(rethinkdb.desc("jam.number"))
teams = self.db.run(query)
- entries = []
-
- for team in teams:
- # find the jam for this team
- query = self.db.query("code_jams").filter(
- lambda jam: jam["teams"].contains(team["id"])
- )
- jam = next(self.db.run(query))
- entries.append({
- "team": team,
- "jam": jam
- })
-
return self.render(
"main/jams/teams_list.html",
- entries=entries
+ teams=teams
)
diff --git a/templates/main/jams/teams_list.html b/templates/main/jams/teams_list.html
index 1fc5bf87..fa4e1c8e 100644
--- a/templates/main/jams/teams_list.html
+++ b/templates/main/jams/teams_list.html
@@ -10,16 +10,18 @@
</h1>
<br>
- {% if entries %}
- {% for entry in entries %}
+ {% if teams %}
+ {% for team in teams %}
<div>
- <h3>Code Jam #{{ entry.jam.number }}: Team <strong>{{ entry.team.name }}</strong></h3>
+ <h3>Code Jam #{{ team.jam.number }}: Team <strong>{{ team.name }}</strong></h3>
<strong>Team Members</strong>
<ul>
- {% for member in entry.team.members %}
+ {% for member in team.members %}
<li>
{{ member.username }}#{{ member.discriminator }}
- <a class="uk-button uk-button-small" target="_blank" href="https://gitlab.com/{{ member.gitlab_username }}">
+ <a class="uk-button uk-button-small"
+ title="{{ member.gitlab_username }} on GitLab"
+ target="_blank" href="https://gitlab.com/{{ member.gitlab_username }}">
<i class="uk-icon fa-fw fab fa-gitlab"></i>
</a>
</li>