def test_get_user_time_zone(self): """ Test to ensure get_user_time_zone() returns the correct time zone or UTC if user has not specified time zone. """ # User time zone should be UTC when no time zone has been chosen user_tz = get_user_time_zone(self.user) self.assertEqual(user_tz, utc) # User time zone should change when user specifies time zone set_user_preference(self.user, 'time_zone', 'Asia/Tokyo') user_tz = get_user_time_zone(self.user) self.assertEqual(user_tz, timezone('Asia/Tokyo'))
def render_accordion(request, course, table_of_contents): """ Returns the HTML that renders the navigation for the given course. Expects the table_of_contents to have data on each chapter and section, including which ones are active. """ context = dict([ ('toc', table_of_contents), ('course_id', unicode(course.id)), ('csrf', csrf(request)['csrf_token']), ('due_date_display_format', course.due_date_display_format), ('time_zone', get_user_time_zone(request.user).zone), ] + TEMPLATE_IMPORTS.items()) return render_to_string('courseware/accordion.html', context)
def render_accordion(request, course, table_of_contents): """ Returns the HTML that renders the navigation for the given course. Expects the table_of_contents to have data on each chapter and section, including which ones are active. """ context = dict( [ ('toc', table_of_contents), ('course_id', unicode(course.id)), ('csrf', csrf(request)['csrf_token']), ('due_date_display_format', course.due_date_display_format), ('time_zone', get_user_time_zone(request.user).zone), ] + TEMPLATE_IMPORTS.items() ) return render_to_string('courseware/accordion.html', context)
def time_zone(self): """The time zone to display in""" return get_user_time_zone(self.user)