Skip to content

Commit

Permalink
#1491 - improve time zone handling
Browse files Browse the repository at this point in the history
Handle the user's time zone from Canvas more carefully.  Don't assume it is set, doesn't have extraneous whitespace, or is valid.  If it's not set or invalid, use the `TIME_ZONE` set in `env.hjson`.
  • Loading branch information
lsloan committed Dec 21, 2023
1 parent 3ea3355 commit 41a4063
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dashboard/lti_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ def extract_launch_variables_for_tool_use(request, message_launch):
username = custom_params['user_username']
course_id = custom_params['canvas_course_id']
canvas_user_id = custom_params['canvas_user_id']
time_zone = custom_params['person_address_timezone']
time_zone = custom_params.get('person_address_timezone',
settings.TIME_ZONE).strip()

if time_zone not in pytz.all_timezones:
time_zone = settings.TIME_ZONE # default zone from `env.hjson`

canvas_course_long_id = canvas_id_to_incremented_id(course_id)
canvas_user_long_id = canvas_id_to_incremented_id(canvas_user_id)
Expand Down

0 comments on commit 41a4063

Please sign in to comment.