This pull request introduces several changes to enhance the handling of event locations in the access_amherst_backend project. The updates include adding a new field for mapping locations, refactoring the location categorization, and improving the event extraction and saving processes.
Enhancements to Event Location Handling:
Database Schema Update:
Added a new field map_location to the Event model to store the categorized location name. [1][2]
Location Categorization:
Introduced a dictionary location_buckets to map keywords to specific locations with predefined latitude and longitude values.
Updated the categorize_location function to use the new dictionary structure for categorizing event locations.
Event Extraction and Saving:
Modified the extract_event_details function to include the map_location field in the extracted event data.
Refactored the save_event_to_db function to use hardcoded latitude and longitude values from the location_buckets dictionary, with an optional random offset for better map visualization.
Code Cleanup and Refactoring:
Removed Unused Imports:
Cleaned up imports in views.py to remove unused modules.
View Function Updates:
Updated the home view to filter events based on the new map_location field and retrieve unique map locations for filtering. [1][2]
Enhanced the map_view function to use the new map_location field and display categorized locations on the map.
This pull request introduces several changes to enhance the handling of event locations in the
access_amherst_backend
project. The updates include adding a new field for mapping locations, refactoring the location categorization, and improving the event extraction and saving processes.Enhancements to Event Location Handling:
Database Schema Update:
map_location
to theEvent
model to store the categorized location name. [1] [2]Location Categorization:
location_buckets
to map keywords to specific locations with predefined latitude and longitude values.categorize_location
function to use the new dictionary structure for categorizing event locations.Event Extraction and Saving:
extract_event_details
function to include themap_location
field in the extracted event data.save_event_to_db
function to use hardcoded latitude and longitude values from thelocation_buckets
dictionary, with an optional random offset for better map visualization.Code Cleanup and Refactoring:
Removed Unused Imports:
views.py
to remove unused modules.View Function Updates:
home
view to filter events based on the newmap_location
field and retrieve unique map locations for filtering. [1] [2]map_view
function to use the newmap_location
field and display categorized locations on the map.