Skip to content

Commit

Permalink
Web: Already provide "teams.json" as soon as registration is closed
Browse files Browse the repository at this point in the history
It doesn't hurt us and teams might already benefit from it.

Co-authored-by: Simon Ruderich <simon@ruderich.org>
  • Loading branch information
F30 and rudis committed Oct 5, 2020
1 parent b93fe40 commit b63b8d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/ctf_gameserver/web/scoring/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ def func(request, *args, **kwargs):
return func


def registration_closed_required(view):
"""
View decorator which only allows access to the decorated view if registration is closed from the
GameControl object.
Format of the response is currently always JSON.
"""

@wraps(view)
def func(request, *args, **kwargs):
if GameControl.get_instance().registration_open:
return JsonResponse({'error': 'Not available yet'}, status=404)

return view(request, *args, **kwargs)

return func


def services_public_required(resp_format):
"""
View decorator which prohibits access to the decorated view if information about the services is not
Expand Down
4 changes: 2 additions & 2 deletions src/ctf_gameserver/web/scoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import ctf_gameserver.web.registration.models as registration_models

from . import models, calculations
from .decorators import services_public_required
from .decorators import registration_closed_required, services_public_required


@services_public_required('html')
Expand Down Expand Up @@ -166,7 +166,7 @@ def service_status_json(_):
@cache_page(60)
# Don't provide a list of all teams while registration is open to prevent
# crawling of registered teams and comparing with this list
@services_public_required('json')
@registration_closed_required
def teams_json(_):

teams = registration_models.Team.active_objects.values_list('net_number', flat=True)
Expand Down

0 comments on commit b63b8d5

Please sign in to comment.