Skip to content

Commit

Permalink
Merge pull request #98 from clopedion/main
Browse files Browse the repository at this point in the history
fix visability issue in archive mode
  • Loading branch information
TheOriginalSoni authored Jan 5, 2025
2 parents 23d0def + 9c02fdf commit 35c88dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions myus/myus/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class Puzzle(models.Model):
slug = models.SlugField(help_text="A short, unique identifier for the puzzle.")

def is_viewable_by(self, team):
if self.hunt.is_archived() and not team:
return True
if team:
progress = team.progress()
else:
Expand Down
21 changes: 19 additions & 2 deletions myus/myus/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,11 @@ def setUp(self):
points=20,
solution_url="https://google.com",
)
Puzzle.objects.create(
name="Test Locked Puzzle", hunt=self.archived_hunt, progress_threshold=10
self.archive_locked_puzzle = Puzzle.objects.create(
name="Test Locked Puzzle",
hunt=self.archived_hunt,
progress_threshold=10,
slug="locked-puzzle",
)

self.teams = []
Expand Down Expand Up @@ -239,6 +242,20 @@ def test_is_archive(self):
def test_puzzle_visibility(self):
# all puzzles are public in an archived hunt
self.assertEqual(self.archived_hunt.public_puzzles().count(), 2)
res = self.client.get(
reverse(
"view_puzzle",
args=[
self.archived_hunt.id,
self.archived_hunt.slug,
self.archive_locked_puzzle.id,
self.archive_locked_puzzle.slug,
],
)
)
self.assertContains(
res, "<h1>Puzzle: Test Locked Puzzle </h1>", status_code=200
)
# team-visible in an archived hunt is still the same
self.assertEqual(self.teams[0].unlocked_puzzles().count(), 1)

Expand Down

0 comments on commit 35c88dc

Please sign in to comment.