diff --git a/myus/myus/forms.py b/myus/myus/forms.py index 78115e5..3b8bd39 100644 --- a/myus/myus/forms.py +++ b/myus/myus/forms.py @@ -68,7 +68,7 @@ def save(self, commit=True): return user -class HuntForm(forms.ModelForm): +class NewHuntForm(forms.ModelForm): description = forms.CharField(widget=MarkdownTextarea, required=False) start_time = DateTimeLocalField(required=False, help_text="Date/time must be UTC") end_time = DateTimeLocalField(required=False, help_text="Date/time must be UTC") @@ -83,6 +83,26 @@ class Meta: "end_time", "member_limit", "guess_limit", + "leaderboard_style", + ] + + +class EditHuntForm(forms.ModelForm): + description = forms.CharField(widget=MarkdownTextarea, required=False) + start_time = DateTimeLocalField(required=False, help_text="Date/time must be UTC") + end_time = DateTimeLocalField(required=False, help_text="Date/time must be UTC") + + class Meta: + model = Hunt + fields = [ + "name", + "slug", + "description", + "start_time", + "end_time", + "member_limit", + "guess_limit", + "leaderboard_style", ] diff --git a/myus/myus/models.py b/myus/myus/models.py index 5d563de..2ec8fc0 100644 --- a/myus/myus/models.py +++ b/myus/myus/models.py @@ -29,12 +29,12 @@ class Hunt(models.Model): start_time = models.DateTimeField( blank=True, null=True, - help_text="Start time of the hunt. If empty, the hunt will never begin. For indefinitely open hunts, you can just set it to any time in the past.", + help_text="(Not implemented) Start time of the hunt. If empty, the hunt will never begin. For indefinitely open hunts, you can just set it to any time in the past.", ) end_time = models.DateTimeField( blank=True, null=True, - help_text="End date of the hunt. If empty, the hunt will always be open.", + help_text="(Not implemented) End date of the hunt. If empty, the hunt will always be open.", ) organizers = models.ManyToManyField(User, related_name="organizing_hunts") invited_organizers = models.ManyToManyField( @@ -47,7 +47,7 @@ class Hunt(models.Model): ) member_limit = models.IntegerField( default=0, - help_text="The maximum number of members allowed per team; 0 means unlimited", + help_text="(Not implemented) The maximum number of members allowed per team; 0 means unlimited", validators=[MinValueValidator(0)], ) guess_limit = models.IntegerField( @@ -55,6 +55,15 @@ class Hunt(models.Model): help_text="The default number of guesses teams get on each puzzle; 0 means unlimited", validators=[MinValueValidator(0)], ) + + class LeaderboardStyle(models.TextChoices): + DEFAULT = "DEF", "Default (ordered by score, solve count, and last solve time)" + HIDDEN = "HID", "Hidden (not displayed publicly)" + SPEEDRUN = "SPD", "Speedrun (ordered by score and time to solve)" + + leaderboard_style = models.CharField( + max_length=3, choices=LeaderboardStyle, default=LeaderboardStyle.DEFAULT + ) slug = models.SlugField(help_text="A short, unique identifier for the hunt.") def public_puzzles(self): diff --git a/myus/myus/templates/edit_hunt.html b/myus/myus/templates/edit_hunt.html new file mode 100644 index 0000000..9aae03d --- /dev/null +++ b/myus/myus/templates/edit_hunt.html @@ -0,0 +1,17 @@ +{% extends "base.html" %} +{% block nav %} + » Edit Hunt +{% endblock %} +{% block main %} +
Team | Score | Solves | Team Creation Time (UTC) | Last Solve (UTC) | Total Solve Time |
---|---|---|---|---|---|
{{ team.name }} | +{{ team.score }} | +{{ team.solve_count }} | +{{ team.creation_time|date:'Y-m-d H:i'}} | +{{ team.last_solve|date:'Y-m-d H:i'}} | +{{ team.solve_time|duration}} | +