88from app .database .models import Event , User
99from app .dependencies import templates
1010
11- ZOOM_REGEX = re .compile ('https://.*?\.zoom.us/[a-z]/.[^.,\b \t \n ]+' )
11+ ZOOM_REGEX = re .compile (r 'https://.*?\.zoom.us/[a-z]/.[^.,\b\t\n]+' )
1212
1313router = APIRouter (
1414 prefix = "/event" ,
@@ -29,20 +29,25 @@ async def create_event(request: Request, session=Depends(get_db)):
2929 print (data )
3030 title = data ['title' ]
3131 content = data ['description' ]
32- start = dt .strptime (data ['start_date' ] + ' ' + data ['start_time' ], '%Y-%m-%d %H:%M' )
33- end = dt .strptime (data ['end_date' ] + ' ' + data ['end_time' ], '%Y-%m-%d %H:%M' )
32+ start = dt .strptime (data ['start_date' ] + ' ' + data ['start_time' ],
33+ '%Y-%m-%d %H:%M' )
34+ end = dt .strptime (data ['end_date' ] + ' ' + data ['end_time' ],
35+ '%Y-%m-%d %H:%M' )
3436 user = session .query (User ).filter_by (id = 1 ).first ()
3537 owner_id = user .id
3638 location_type = data ['location_type' ]
3739 is_zoom = location_type == 'vc_url'
3840 location = data ['location' ]
3941
4042 if is_zoom and not ZOOM_REGEX .findall (location ):
41- raise HTTPException (status_code = 400 , detail = "VC type with no valid zoom link" )
42- event = Event (title = title , content = content , start = start , end = end , owner_id = owner_id )
43+ raise HTTPException (status_code = 400 ,
44+ detail = "VC type with no valid zoom link" )
45+ event = Event (title = title , content = content , start = start , end = end ,
46+ owner_id = owner_id )
4347 session .add (event )
4448 session .commit ()
45- return RedirectResponse (f'/event/view/{ event .id } ' , status_code = HTTP_303_SEE_OTHER )
49+ return RedirectResponse (f'/event/view/{ event .id } ' ,
50+ status_code = HTTP_303_SEE_OTHER )
4651
4752
4853@router .get ("/view/{id}" )
0 commit comments