Skip to content

Commit

Permalink
Added staff hunt info page, fixes #66
Browse files Browse the repository at this point in the history
  • Loading branch information
dlareau committed Oct 5, 2018
1 parent 8a79f11 commit feb038d
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 5 deletions.
2 changes: 1 addition & 1 deletion huntserver/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, *args, **kwargs):
super(PersonForm, self).__init__(*args, **kwargs)
self.fields['phone'].help_text = "Optional"
self.fields['allergies'].help_text = "Optional"
self.fields['allergies'].label = "Food Preferences"
self.fields['allergies'].label = "Allergies/Preferences"

class Meta:
model = Person
Expand Down
4 changes: 4 additions & 0 deletions huntserver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ def is_normal_team(self):
def __unicode__(self):
return str(self.person_set.count()) + " (" + self.location + ") " + self.team_name

@property
def short_name(self):
""" A boolean indicating whether or not the team is a playtesting team """
return self.team_name[:30]

class Person(models.Model):
""" A class to associate more personal information with the default django auth user class """
Expand Down
22 changes: 21 additions & 1 deletion huntserver/staff_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import json
import networkx as nx

from .models import Submission, Hunt, Team, Puzzle, Unlock, Solve, Message
from .models import Submission, Hunt, Team, Puzzle, Unlock, Solve, Message, Person
from .forms import SubmissionForm, UnlockForm, EmailForm
from .utils import unlock_puzzles, download_puzzle

Expand Down Expand Up @@ -319,6 +319,26 @@ def hunt_management(request):
hunts = Hunt.objects.all()
return render(request, 'hunt_management.html', {'hunts': hunts})

@staff_member_required
def hunt_info(request):
""" A view to render the hunt info page """

curr_hunt = Hunt.objects.get(is_current_hunt=True)
teams = curr_hunt.real_teams
people = []
for team in teams:
people = people + list(team.person_set.all())
need_teams = teams.filter(location="need_a_room") | teams.filter(location="needs_a_room")
have_teams = teams.exclude(location="need_a_room").exclude(location="needs_a_room").exclude(location="off_campus")
offsite_teams = teams.filter(location="off_campus")

context = {'curr_hunt': curr_hunt,
'people': people,
'need_teams': need_teams.all(),
'have_teams': have_teams.all(),
'offsite_teams': offsite_teams.all()}
return render(request, 'staff_hunt_info.html', context)


@staff_member_required
def control(request):
Expand Down
1 change: 1 addition & 0 deletions huntserver/templates/staff_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<li><a href="/staff/queue">Queue</a></li>
<li><a href="/staff/chat">Chat</a></li>
<li><a href="/staff/management">Management</a></li>
<li><a href="/staff/info">Info</a></li>
<li><a href="/staff/emails">Email</a></li>
<li><a href="/staff/charts">Charts</a></li>
</ul>
Expand Down
47 changes: 47 additions & 0 deletions huntserver/templates/staff_hunt_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "staff_base.html" %}
{% load admin_urls %}
{% block title %}Hunt Info{% endblock title %}

{% block content %}
<h1>Hunt Info</h1>
<div class="row">
<div class="col-xs-12 col-sm-8 col-lg-5">
{{ curr_hunt.real_teams.count }} Teams: <br>
<b>Needs a room: ({{ need_teams.count }})</b><br>
<table>
{% for team in need_teams %}
<tr><td>{{ team.short_name }}</td> <td>{{ team.location }}</td></tr>
{% endfor %}
</table>
<br>
<b>Has a room: ({{ have_teams.count }})</b><br>
<table>
{% for team in have_teams %}
<tr><td>{{ team.short_name }}</td> <td>{{ team.location }}</td></tr>
{% endfor %}
</table>
<br>
<b>Off Campus: ({{ offsite_teams.count }})</b><br>
<table>
{% for team in offsite_teams %}
<tr><td>{{ team.short_name }}</td> <td>{{ team.location }}</td></tr>
{% endfor %}
</table>
</div>
<div class="col-xs-12 col-sm-4 col-lg-7">
<b>{{ people|length }} People</b><br><br>

<b> Allergies/Preferences: </b>
</br>
{% for person in people %}
{% if person.allergies %}
<a href="{% url 'admin:huntserver_person_change' person.pk %}">
{{person.allergies}}
</a>
</br>
{% endif %}
{% endfor %}
</div>
</div>

{% endblock content %}
9 changes: 7 additions & 2 deletions huntserver/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#python manage.py dumpdata --indent=4 --exclude=contenttypes --exclude=sessions --exclude=admin --exclude=auth.permission

# Users: jlareau, user1, user2, user3, user4, user5, user6
# jlareau is superuser/staff and on no teams
# Users: admin, user1, user2, user3, user4, user5, user6
# admin is superuser/staff and on no teams
# user1 is on teams 2, 6, 8 (1-2, 2-3, 3-2)
# user2 is on teams 2, 6, 9 (1-2, 2-3, 3-3) # Reserved for ratelimiting
# user3 is on teams 3, 5 (1-3, 2-2 )
Expand Down Expand Up @@ -620,6 +620,11 @@ def test_staff_management(self):
login(self, 'admin')
response = get_and_check_page(self, 'huntserver:hunt_management', 200)

def test_staff_info(self):
"Test the staff info view"
login(self, 'admin')
response = get_and_check_page(self, 'huntserver:hunt_info', 200)

def test_staff_depgraph(self):
"Test the staff depgraph view"
login(self, 'admin')
Expand Down
1 change: 1 addition & 0 deletions huntserver/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
url(r'^puzzles/$', RedirectView.as_view(url='/admin/huntserver/puzzle/', permanent=False)),
url(r'^emails/$', staff_views.emails, name='emails'),
url(r'^management/$', staff_views.hunt_management, name='hunt_management'),
url(r'^info/$', staff_views.hunt_info, name='hunt_info'),
url(r'^depgraph/$', staff_views.depgraph, name='depgraph'),
])),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<p class="permission-warning">{% trans "You don't have permission to edit anything." %}</p>
{% endif %}

{% if "progress" in current_url or "queue" in current_url or "chat" in current_url or "management" in current_url or "emails" in current_url or "charts" in current_url %}
{% if "progress" in current_url or "queue" in current_url or "chat" in current_url or "management" in current_url or "emails" in current_url or "charts" in current_url or "info" in current_url %}
<ul class="nav nav-sidebar app-staffpages module has-active-menu show-models">
{% else %}
<ul class="nav nav-sidebar app-staffpages module">
Expand All @@ -39,6 +39,9 @@
</li>
<li {% if "management" in current_url %}class="active"{% endif %}>
<a href="/staff/management">Management</a>
</li>
<li {% if "info" in current_url %}class="active"{% endif %}>
<a href="/staff/info">Info</a>
</li>
<li {% if "emails" in current_url %}class="active"{% endif %}>
<a href="/staff/emails">Email</a>
Expand Down

0 comments on commit feb038d

Please sign in to comment.