Skip to content

Commit

Permalink
Add 404 page to catch all unspecified requests. (hedyorg#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereiro authored Oct 28, 2021
1 parent 934444a commit da6cd6f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def load_adventure_for_language(lang):

if not adventures_for_lang.has_adventures():
# The default fall back language is English
fall_back = FALL_BACK_ADVENTURE.get(lang, "en")
fall_back = FALL_BACK_ADVENTURE.get(lang, "en")
adventures_for_lang = ADVENTURES[fall_back]
return adventures_for_lang.adventures_file['adventures']

Expand Down Expand Up @@ -513,7 +513,7 @@ def get_quiz(level_source, question_nr, attempt):
option_obj['char_index'] = char_array[i]
i += 1
question_obj.append(option_obj)

html_obj = render_template('quiz_question.html',
quiz=quiz_data,
level_source=level_source,
Expand Down Expand Up @@ -819,6 +819,10 @@ def client_messages():

return response

@app.errorhandler(404)
def not_found(exception):
return utils.page_404 (TRANSLATIONS, render_main_menu('adventures'), current_user(request) ['username'], requested_lang (), TRANSLATIONS.get_translations (requested_lang (), 'ui').get ('page_not_found'))

@app.errorhandler(500)
def internal_error(exception):
import traceback
Expand Down
1 change: 1 addition & 0 deletions coursedata/texts/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ui:
no_such_adventure_level: "No such level for this Hedy adventure!"
no_such_program: "No such Hedy program!"
invalid_teacher_invitation_code: "The teacher invitation code is invalid. To become a teacher, reach out to [email protected]."
page_not_found: "We could not find that page!"
ClientErrorMessages:
Transpile_warning: "Warning!"
Transpile_error: "We can't run your program."
Expand Down
1 change: 1 addition & 0 deletions coursedata/texts/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ui:
switch_to_another_adventure: "Elegir otra aventura"
commands_title: "Comandos"
by: "por"
page_not_found: "¡No pudimos encontrar esta página!"
ClientErrorMessages:
Transpile_warning: "¡Atención!"
Transpile_error: "El servidor no puede traducir este programa."
Expand Down
3 changes: 2 additions & 1 deletion coursedata/texts/nl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ ui:
commands_title: "Commando's"
by: "door"
start_quiz: "Naar de quiz"
invalid_teacher_invitation_code: "Deze leerkrachtenuitnodigingscode is niet geldig. ALs je een nieuwe uitnodiging nodig hebt, neem dan contact op met [email protected]"
invalid_teacher_invitation_code: "Deze leerkrachtenuitnodigingscode is niet geldig. Als je een nieuwe uitnodiging nodig hebt, neem dan contact op met [email protected]"
page_not_found: "We konden deze pagina niet vinden!"
ClientErrorMessages:
Transpile_warning: "Let op!"
Transpile_error: "We konden je code niet goed lezen."
Expand Down

0 comments on commit da6cd6f

Please sign in to comment.