Skip to content

Commit ed62de8

Browse files
Merge pull request #12 from FSU-ACM/release
Contest winners display
2 parents 544ab32 + 6d6e09e commit ed62de8

File tree

4 files changed

+52
-6
lines changed

4 files changed

+52
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,4 @@ We welcome contributions to the project! Check out `CONTRIBUTING.md` to learn ho
100100

101101
- [Marlan McInnes-Taylor](https://github.com/mmcinnestaylor) *Creator*
102102
- [Daniel Riley](https://github.com/danielmriley)
103+
- [Preston Horne](https://github.com/prestonmhorne)

src/contestadmin/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,11 @@ def get_participation(self):
7171
return self.FORMAT[self.participation - 1][1]
7272
else:
7373
return 'TBA'
74+
75+
76+
def is_contest_complete(self):
77+
"""
78+
Returns true if contest is complete, false otherwise
79+
"""
80+
81+
return self.results is not None

src/core/templates/core/teams.html

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,19 @@ <h2>Upper Division</h2>
3737
{% for team in upper_teams %}
3838
<tr>
3939
<td>
40-
<span class="d-block d-md-none ml-1">{{ team.name }}</span>
41-
<span class="d-none d-md-block ml-3">{{ team.name }}</span>
40+
{% if forloop.counter == 1 and contest.is_contest_complete %}
41+
<span class="d-block d-md-none ml-1">🥇&nbsp;{{ team.name }}</span>
42+
<span class="d-none d-md-block ml-3">🥇&nbsp;{{ team.name }}</span>
43+
{% elif forloop.counter == 2 and contest.is_contest_complete %}
44+
<span class="d-block d-md-none ml-1">🥈&nbsp;{{ team.name }}</span>
45+
<span class="d-none d-md-block ml-3">🥈&nbsp;{{ team.name }}</span>
46+
{% elif forloop.counter == 3 and contest.is_contest_complete %}
47+
<span class="d-block d-md-none ml-1">🥉&nbsp;{{ team.name }}</span>
48+
<span class="d-none d-md-block ml-3">🥉&nbsp;{{ team.name }}</span>
49+
{% else %}
50+
<span class="d-block d-md-none ml-1">{{ team.name }}</span>
51+
<span class="d-none d-md-block ml-3">{{ team.name }}</span>
52+
{% endif %}
4253
</td>
4354
<td class="text-center">{{ team.questions_answered }}</td>
4455
<td class="text-center">{{ team.score }}</td>
@@ -99,8 +110,19 @@ <h2>Lower Division</h2>
99110
{% for team in lower_teams %}
100111
<tr>
101112
<td>
102-
<span class="d-block d-md-none ml-1">{{ team.name }}</span>
103-
<span class="d-none d-md-block ml-3">{{ team.name }}</span>
113+
{% if forloop.counter == 1 and contest.is_contest_complete %}
114+
<span class="d-block d-md-none ml-1">🥇&nbsp;{{ team.name }}</span>
115+
<span class="d-none d-md-block ml-3">🥇&nbsp;{{ team.name }}</span>
116+
{% elif forloop.counter == 2 and contest.is_contest_complete %}
117+
<span class="d-block d-md-none ml-1">🥈&nbsp;{{ team.name }}</span>
118+
<span class="d-none d-md-block ml-3">🥈&nbsp;{{ team.name }}</span>
119+
{% elif forloop.counter == 3 and contest.is_contest_complete %}
120+
<span class="d-block d-md-none ml-1">🥉&nbsp;{{ team.name }}</span>
121+
<span class="d-none d-md-block ml-3">🥉&nbsp;{{ team.name }}</span>
122+
{% else %}
123+
<span class="d-block d-md-none ml-1">{{ team.name }}</span>
124+
<span class="d-none d-md-block ml-3">{{ team.name }}</span>
125+
{% endif %}
104126
</td>
105127
<td class="text-center">{{ team.questions_answered }}</td>
106128
<td class="text-center">{{ team.score }}</td>
@@ -161,8 +183,19 @@ <h2>Faculty</h2>
161183
{% for team in faculty_teams %}
162184
<tr>
163185
<td>
164-
<span class="d-block d-md-none ml-1">{{ team.name }}</span>
165-
<span class="d-none d-md-block ml-3">{{ team.name }}</span>
186+
{% if forloop.counter == 1 and contest.is_contest_complete %}
187+
<span class="d-block d-md-none ml-1">🥇&nbsp;{{ team.name }}</span>
188+
<span class="d-none d-md-block ml-3">🥇&nbsp;{{ team.name }}</span>
189+
{% elif forloop.counter == 2 and contest.is_contest_complete %}
190+
<span class="d-block d-md-none ml-1">🥈&nbsp;{{ team.name }}</span>
191+
<span class="d-none d-md-block ml-3">🥈&nbsp;{{ team.name }}</span>
192+
{% elif forloop.counter == 3 and contest.is_contest_complete %}
193+
<span class="d-block d-md-none ml-1">🥉&nbsp;{{ team.name }}</span>
194+
<span class="d-none d-md-block ml-3">🥉&nbsp;{{ team.name }}</span>
195+
{% else %}
196+
<span class="d-block d-md-none ml-1">{{ team.name }}</span>
197+
<span class="d-none d-md-block ml-3">{{ team.name }}</span>
198+
{% endif %}
166199
</td>
167200
<td class="text-center">{{ team.questions_answered }}</td>
168201
<td class="text-center">{{ team.score }}</td>

src/core/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def teams(request):
9797

9898
context = {}
9999

100+
# Get contest object or set to None
101+
context['contest'] = cache.get_or_set(
102+
'contest_model', Contest.objects.first(), CACHE_TIMEOUT)
103+
100104
teams_set = Team.objects.all()
101105
participants_set = Profile.objects.all()
102106

0 commit comments

Comments
 (0)