This pull request includes several changes to improve timezone handling, streamline file path operations, and enhance the overall functionality of the access_amherst_backend project. The most important changes include the conversion of datetime objects to UTC, the use of dateutil.parser for parsing dates, and the simplification of file path operations.
This pull request includes several changes to improve timezone handling, streamline file path operations, and enhance the overall functionality of the
access_amherst_backend
project. The most important changes include the conversion of datetime objects to UTC, the use ofdateutil.parser
for parsing dates, and the simplification of file path operations.Timezone Handling Improvements:
access_amherst_backend/access_amherst_algo/generate_map.py
: Added conversion of user-specified hours to UTC for database queries ingenerate_heatmap
function.access_amherst_backend/access_amherst_algo/management/commands/remove_old_events.py
: Converted threshold time to UTC inhandle
function.access_amherst_backend/access_amherst_algo/parse_database.py
: Created datetime objects in UTC and converted them to the specified timezone inget_events_by_hour
function.access_amherst_backend/access_amherst_algo/views.py
: Activated EST timezone and converted start and end dates to UTC for database queries inhome
andcalendar_view
functions. [1] [2]File Path Operations Simplification:
access_amherst_backend/access_amherst_algo/email_scraper/email_parser.py
: Simplified file path operations insave_to_json_file
function.access_amherst_backend/access_amherst_algo/rss_scraper/clean_hub_data.py
: Simplified file path operations inclean_hub_data
function.access_amherst_backend/access_amherst_algo/rss_scraper/parse_rss.py
: Simplified file path operations insave_json
function.Date Parsing Enhancements:
access_amherst_backend/access_amherst_algo/rss_scraper/parse_rss.py
: Replaced manual date parsing withdateutil.parser
insave_event_to_db
andis_similar_event
functions. [1] [2]access_amherst_backend/access_amherst_algo/views.py
: Useddateutil.parser
for parsing user-provided dates inhome
function.Template and Settings Updates:
access_amherst_backend/access_amherst_algo/templates/access_amherst_algo/home.html
: Added timezone localization to event dates and Google Calendar links.access_amherst_backend/access_amherst_backend/settings.py
: Enableddjango.template.context_processors.tz
and allowed localhost inALLOWED_HOSTS
. [1] [2]Test Adjustments:
access_amherst_backend/access_amherst_tests/test_clean_hub_data.py
: Updated test to match the simplified file path operations.access_amherst_backend/access_amherst_tests/test_email_parser.py
: Updated test to match the simplified file path operations.