Skip to content

Commit

Permalink
Merge pull request #225 from domino14/bug/224/challenges
Browse files Browse the repository at this point in the history
Fix a couple of 500s and error email logging.
  • Loading branch information
domino14 authored Mar 13, 2017
2 parents 980a23a + 44ac9ec commit cedf3c8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
21 changes: 17 additions & 4 deletions djAerolith/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def tobool(val):
LOGIN_REDIRECT_URL = "/"
# Used by social auth.
LOGIN_ERROR_URL = '/login_error/'
SERVER_EMAIL = '[email protected]'
EMAIL_HOST = "smtp.mailgun.org"
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
Expand Down Expand Up @@ -281,17 +282,23 @@ def tobool(val):
},
'loggers': {
'django.db': {
'handlers': ['console'],
'handlers': ['console', 'mail_admins'],
'level': 'INFO',
'propagate': False,
},
'social': {
'handlers': ['console'],
'level': 'ERROR',
'propagate': False,
},
'': { # catch-all
'django': {
'handlers': ['console', 'mail_admins'],
'level': 'DEBUG',
'propagate': False,
},
'': { # catch-all
'handlers': ['console', 'mail_admins'],
'level': 'DEBUG'
'level': 'DEBUG',
}
}
}
Expand All @@ -309,7 +316,13 @@ def tobool(val):
LOGGING['loggers'] = {
'django.db': {
'handlers': ['log_file', 'mail_admins'],
'level': 'INFO'
'level': 'INFO',
'propagate': False,
},
'django': {
'handlers': ['log_file', 'mail_admins'],
'level': 'DEBUG',
'propagate': False,
},
'': {
'handlers': ['log_file', 'mail_admins'],
Expand Down
1 change: 1 addition & 0 deletions djAerolith/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def get_success_url(self, user):
(r'^socket_token/', 'views.socket_token'),
(r'^base/', include('base.urls')),
(r'^js_errors/', 'views.js_error'),
(r'^500tester/', 'views.test_500'),
)

urlpatterns += staticfiles_urlpatterns() # for static serving, only works if DEBUG is true
5 changes: 5 additions & 0 deletions djAerolith/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,8 @@ def js_error(request):
logger.debug('To: %s', [admin[1] for admin in settings.ADMINS])

return response('OK')


@login_required
def test_500(request):
raise Exception('A test 500')
20 changes: 8 additions & 12 deletions djAerolith/wordwalls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ def api_challengers(request):
ch_id = request.GET.get('challenge')
ch_date = date_from_request_dict(request.GET)

return response(challengers(ch_date, lex, ch_id))
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))


## Other API views with required auth.
Expand Down Expand Up @@ -81,8 +87,8 @@ def challenges_played(request):
board__challenge=relevant_toughie, user=request.user)
except DailyChallengeLeaderboardEntry.DoesNotExist:
return response(resp)
resp.append({'challengeID': entry.board.challenge.name.pk})

resp.append({'challengeID': entry.board.challenge.name.pk})
return response(resp)


Expand Down Expand Up @@ -314,13 +320,3 @@ def date_from_str(dt):
ch_date = today

return ch_date


def challengers(dt, lex, ch_id):
try:
lex = Lexicon.objects.get(pk=lex)
ch_name = DailyChallengeName.objects.get(pk=ch_id)
except ObjectDoesNotExist:
return bad_request('Bad lexicon or challenge.')

return getLeaderboardData(lex, ch_name, dt)

0 comments on commit cedf3c8

Please sign in to comment.