Skip to content

Commit

Permalink
Merge pull request PuzzleTechHub#43 from PuzzleTechHub/answer-in-puzz…
Browse files Browse the repository at this point in the history
…le-list

Add answer column in the hunt's main page (closes PuzzleTechHub#25)
  • Loading branch information
TheOriginalSoni authored Mar 5, 2024
2 parents e77e35e + ce3e6e6 commit e53dee7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions myus/myus/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.contrib.auth.models import AbstractUser

from django.db.models import OuterRef, Exists, Sum, Q
from django.db.models import Subquery, OuterRef, Exists, Sum, Q

from django.core.validators import MinValueValidator

Expand Down Expand Up @@ -153,8 +153,8 @@ def unlocked_puzzles(self):

def unlocked_puzzles_with_solved(self):
return self.unlocked_puzzles().annotate(
solved=Exists(
Guess.objects.filter(team=self, puzzle=OuterRef("pk"), correct=True)
correct_guess=Subquery(
Guess.objects.filter(team=self, puzzle=OuterRef("pk"), correct=True).values('guess')
),
)

Expand Down
4 changes: 4 additions & 0 deletions myus/myus/static/css/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ table.classic th.small {
font-size: 85%;
}

samp {
font-size: 1.2em;
}

h1 {
margin-top: 0;
}
5 changes: 3 additions & 2 deletions myus/myus/templates/view_hunt.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ <h2>Puzzles</h2>

{% if puzzles %}
<table class="classic">
<tr><th>Puzzle</th><th>Solved?</th><th>Solves</th><th>Guesses</th></tr>
<tr><th>Puzzle</th><th>Solved?</th><th>Answer</th><th>Solves</th><th>Guesses</th></tr>
{% for puzzle in puzzles %}
<tr>
<td><a href="{% url 'view_puzzle' hunt.id hunt.slug puzzle.id puzzle.slug %}">{{ puzzle.name }}</a></td>
<td>{% if puzzle.solved %}✅{% endif %}</td>
<td>{% if puzzle.correct_guess %}✅{% endif %}</td>
<td>{% if puzzle.correct_guess %}<samp>{{ puzzle.correct_guess }}</samp>{% endif %}</td>
<td>{{ puzzle.solve_count }}</td>
<td>{{ puzzle.guess_count }}</td>
</tr>
Expand Down

0 comments on commit e53dee7

Please sign in to comment.