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 %} +

Edit Hunt

+
+ {% csrf_token %} + {{ form.non_field_errors }} + + + {{ form.as_table }} +
+ +
+ +{% endblock %} diff --git a/myus/myus/templates/leaderboard_SPD.html b/myus/myus/templates/leaderboard_SPD.html new file mode 100644 index 0000000..ed8997b --- /dev/null +++ b/myus/myus/templates/leaderboard_SPD.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} +{% load duration %} +{% block nav %} + » {{ hunt.name }} + » Leaderboard +{% endblock %} +{% block main %} +

Hunt: {{ hunt.name }} / Leaderboard

+ + {% if teams %} + + + {% for team in teams %} + + + + + + + + + {% endfor %} +
TeamScoreSolvesTeam 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}}
+ {% else %} + No teams... + {% endif %} + +{% endblock %} diff --git a/myus/myus/templates/my_team.html b/myus/myus/templates/my_team.html index 11f145f..c8f5b08 100644 --- a/myus/myus/templates/my_team.html +++ b/myus/myus/templates/my_team.html @@ -6,7 +6,9 @@ {% load user_display %} {% block main %}

Hunt: {{ hunt.name }}

- leaderboard + {% if hunt.leaderboard_style != "HID" %} + leaderboard + {% endif %} {% if error %} Error: {{ error }} diff --git a/myus/myus/templates/view_hunt.html b/myus/myus/templates/view_hunt.html index 36eab14..f65592b 100644 --- a/myus/myus/templates/view_hunt.html +++ b/myus/myus/templates/view_hunt.html @@ -6,12 +6,16 @@ {% block main %}

Hunt: {{ hunt.name }}