Skip to content

Commit

Permalink
Merge pull request #326 from domino14/feature/xxx/ignorance-is-bliss
Browse files Browse the repository at this point in the history
Add an option to hide errors
  • Loading branch information
domino14 authored Jun 7, 2019
2 parents e36c493 + e0de8c2 commit 01e3995
Show file tree
Hide file tree
Showing 17 changed files with 4,349 additions and 3,843 deletions.
22 changes: 18 additions & 4 deletions djAerolith/wordwalls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponse
from django.views.decorators.http import require_GET, require_POST
from django.utils import timezone

Expand All @@ -15,7 +14,8 @@
from base.forms import SavedListForm
from lib.response import response, bad_request
from lib.word_searches import SearchDescription
from wordwalls.views import getLeaderboardData
from wordwalls.views import (get_leaderboard_data,
get_leaderboard_data_for_dc_instance)
from wordwalls.challenges import toughies_challenge_date
from wordwalls.game import WordwallsGame, GameInitException
# from wordwalls.socket_consumers import LOBBY_CHANNEL_NAME, table_info
Expand Down Expand Up @@ -44,14 +44,28 @@ def api_challengers(request):
lex = request.GET.get('lexicon')
ch_id = request.GET.get('challenge')
ch_date = date_from_request_dict(request.GET)

tiebreaker = request.GET.get('tiebreaker', 'errors')
try:
lex = Lexicon.objects.get(pk=lex)
ch_name = DailyChallengeName.objects.get(pk=ch_id)
except (ObjectDoesNotExist, ValueError, TypeError):
return bad_request('Bad lexicon or challenge.')

return response(getLeaderboardData(lex, ch_name, ch_date))
return response(get_leaderboard_data(lex, ch_name, ch_date, tiebreaker))


def api_challengers_by_tablenum(request):
if request.method != 'GET':
return bad_request('Must use GET.')
tablenum = request.GET.get('tablenum')
tiebreaker = request.GET.get('tiebreaker', 'errors')
wwg = WordwallsGame()
dc_id = wwg.get_dc_id(tablenum)
if dc_id > 0:
dc = DailyChallenge.objects.get(pk=dc_id)
leaderboard_data = get_leaderboard_data_for_dc_instance(dc, tiebreaker)
return response(leaderboard_data)
return bad_request('No such daily challenge.')


# Other API views with required auth.
Expand Down
2 changes: 2 additions & 0 deletions djAerolith/wordwalls/api_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from django.conf.urls import url

from wordwalls.api import (
api_challengers_by_tablenum,
api_challengers,
configure,
challenges_played,
Expand All @@ -32,6 +33,7 @@
)

urlpatterns = [
url(r'^challengers_by_tablenum/$', api_challengers_by_tablenum),
url(r'^challengers/$', api_challengers),
url(r'^configure/$', configure),
url(r'^challenges_played/$', challenges_played),
Expand Down
Loading

0 comments on commit 01e3995

Please sign in to comment.