1616
1717from app .database .models import Comment , Event , User , UserEvent
1818from app .dependencies import get_db , logger , templates
19+ from app .internal import comment as cmt
20+ from app .internal .emotion import get_emotion
1921from app .internal .event import (
2022 get_invited_emails ,
23+ get_location_coordinates ,
2124 get_messages ,
2225 get_uninvited_regular_emails ,
2326 raise_if_zoom_link_invalid ,
2427)
25- from app .internal import comment as cmt
26- from app .internal .emotion import get_emotion
2728from app .internal .privacy import PrivacyKinds
2829from app .internal .utils import create_model , get_current_user
2930from app .routers .categories import get_user_categories
3031
32+
3133EVENT_DATA = Tuple [Event , List [Dict [str , str ]], str ]
3234TIME_FORMAT = "%Y-%m-%d %H:%M"
3335START_FORMAT = "%A, %d/%m/%Y %H:%M"
@@ -132,9 +134,16 @@ async def create_new_event(
132134 title ,
133135 invited_emails ,
134136 )
137+ latitude , longitude = None , None
135138
136139 if vc_link :
137140 raise_if_zoom_link_invalid (vc_link )
141+ else :
142+ location_details = await get_location_coordinates (location )
143+ if not isinstance (location_details , str ):
144+ location = location_details .name
145+ latitude = location_details .latitude
146+ longitude = location_details .longitude
138147
139148 event = create_event (
140149 db = session ,
@@ -145,6 +154,8 @@ async def create_new_event(
145154 owner_id = owner_id ,
146155 content = content ,
147156 location = location ,
157+ latitude = latitude ,
158+ longitude = longitude ,
148159 vc_link = vc_link ,
149160 invitees = invited_emails ,
150161 category_id = category_id ,
@@ -411,6 +422,8 @@ def create_event(
411422 content : Optional [str ] = None ,
412423 location : Optional [str ] = None ,
413424 vc_link : str = None ,
425+ latitude : Optional [str ] = None ,
426+ longitude : Optional [str ] = None ,
414427 color : Optional [str ] = None ,
415428 invitees : List [str ] = None ,
416429 category_id : Optional [int ] = None ,
@@ -432,6 +445,8 @@ def create_event(
432445 content = content ,
433446 owner_id = owner_id ,
434447 location = location ,
448+ latitude = latitude ,
449+ longitude = longitude ,
435450 vc_link = vc_link ,
436451 color = color ,
437452 emotion = get_emotion (title , content ),
0 commit comments