Skip to content

Commit

Permalink
Merge branch 'main' into programs-count
Browse files Browse the repository at this point in the history
  • Loading branch information
Annelein committed Apr 17, 2024
2 parents 8d5a691 + c64fb12 commit 17452ce
Show file tree
Hide file tree
Showing 245 changed files with 17,665 additions and 5,499 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/update-weblate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ jobs:
runs-on: ubuntu-latest

steps:
# If an open Weblate/translations PR still exists, we shouldn't tell Weblate to push again.
# Because we ended our previous push with a 'reset', Weblate would otherwise force-push
# new changes over the unmerged old changes, causing them to lost.
- name: Check for existence of old Weblate PR
run: |
prs=$(gh pr -R hedyorg/hedy list -q '.[] | select(.title | contains("Translations update"))' --json title)
if [[ "$prs" != "" ]]; then
echo "Open Pull Request for Weblate!"
gh pr -R hedyorg/hedy list --search 'Translations update'
exit 1
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Set up Python 3.12
uses: actions/setup-python@v1
with:
Expand All @@ -38,6 +51,10 @@ jobs:
wlc pull
wlc commit
wlc push
wlc reset
# On our repo, 'wlc reset' consistently times out the TCP connection after waiting
# for 5 minutes. The actual reset does seem to work, so we just don't wait for the
# command to finish, otherwise all our workflow executions show errors.
wlc reset &
sleep 10
25 changes: 18 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ def parse():
return "if present, body.adventure_name must be a string", 400
if 'is_debug' not in body:
return "body.is_debug must be a boolean", 400
if 'raw' not in body:
return "body.raw is missing", 400
error_check = False
if 'error_check' in body:
error_check = True
Expand All @@ -544,6 +546,7 @@ def parse():

# true if kid enabled the read aloud option
read_aloud = body.get('read_aloud', False)
raw = body.get('raw')

response = {}
username = current_user()['username'] or None
Expand All @@ -559,7 +562,8 @@ def parse():
transpile_result = transpile_add_stats(code, level, lang, is_debug)
if username and not body.get('tutorial'):
DATABASE.increase_user_run_count(username)
ACHIEVEMENTS.increase_count("run")
if not raw:
ACHIEVEMENTS.increase_count("run")
except hedy.exceptions.WarningException as ex:
translated_error = get_error_text(ex, keyword_lang)
if isinstance(ex, hedy.exceptions.InvalidSpaceException):
Expand Down Expand Up @@ -632,12 +636,13 @@ def parse():
except BaseException:
pass

try:
if username and not body.get('tutorial') and ACHIEVEMENTS.verify_run_achievements(
username, code, level, response, transpile_result.commands):
response['achievements'] = ACHIEVEMENTS.get_earned_achievements()
except Exception as E:
print(f"error determining achievements for {code} with {E}")
if not raw:
try:
if username and not body.get('tutorial') and ACHIEVEMENTS.verify_run_achievements(
username, code, level, response, transpile_result.commands):
response['achievements'] = ACHIEVEMENTS.get_earned_achievements()
except Exception as E:
print(f"error determining achievements for {code} with {E}")

except hedy.exceptions.HedyException as ex:
traceback.print_exc()
Expand Down Expand Up @@ -1681,6 +1686,10 @@ def render_code_in_editor(level):
except BaseException:
return utils.error_page(error=404, ui_message=gettext('no_such_level'))

if session.get("previous_keyword_lang"):
code = hedy_translation.translate_keywords(
code, session["previous_keyword_lang"], g.keyword_lang, level=int(level))

a = Adventure(
short_name='start',
name='start',
Expand Down Expand Up @@ -2291,6 +2300,8 @@ def translate_keywords():
translated_code = hedy_translation.translate_keywords(body.get('code'), body.get(
'start_lang'), body.get('goal_lang'), level=int(body.get('level', 1)))
if translated_code or translated_code == '': # empty string is False, so explicitly allow it
session["previous_keyword_lang"] = body.get("start_lang")
session["keyword_lang"] = body.get("goal_lang")
return jsonify({'success': 200, 'code': translated_code})
else:
return gettext('translate_error'), 400
Expand Down
3 changes: 2 additions & 1 deletion build-tools/heroku/generate-client-messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
'customization_deleted',
'directly_available',
'disabled',
'adventures_restored'
'adventures_restored',
'multiple_keywords_warning'
]


Expand Down
Loading

0 comments on commit 17452ce

Please sign in to comment.