diff --git a/app/database/models.py b/app/database/models.py index f8df04d3..0dcc0cb5 100644 --- a/app/database/models.py +++ b/app/database/models.py @@ -57,6 +57,7 @@ class Event(Base): end = Column(DateTime, nullable=False) content = Column(String) location = Column(String) + vc_link = Column(String) color = Column(String, nullable=True) availability = Column(Boolean, default=True, nullable=False) invitees = Column(String) diff --git a/app/internal/event.py b/app/internal/event.py index 46e9cf26..5207761e 100644 --- a/app/internal/event.py +++ b/app/internal/event.py @@ -12,8 +12,8 @@ ZOOM_REGEX = re.compile(r'https://.*?\.zoom.us/[a-z]/.[^.,\b\s]+') -def raise_if_zoom_link_invalid(location): - if ZOOM_REGEX.search(location) is None: +def raise_if_zoom_link_invalid(vc_link): + if ZOOM_REGEX.search(vc_link) is None: raise HTTPException(status_code=HTTP_400_BAD_REQUEST, detail="VC type with no valid zoom link") diff --git a/app/routers/event.py b/app/routers/event.py index 50b227f2..111a766c 100644 --- a/app/routers/event.py +++ b/app/routers/event.py @@ -32,6 +32,7 @@ 'availability': bool, 'content': (str, type(None)), 'location': (str, type(None)), + 'vc_link': (str, type(None)), 'category_id': (int, type(None)), } @@ -60,20 +61,19 @@ async def create_new_event(request: Request, TIME_FORMAT) owner_id = get_current_user(session).id availability = data.get('availability', 'True') == 'True' - location_type = data['location_type'] - is_zoom = location_type == 'vc_url' location = data['location'] + vc_link = data['vc_link'] category_id = data.get('category_id') invited_emails = get_invited_emails(data['invited']) uninvited_contacts = get_uninvited_regular_emails(session, owner_id, title, invited_emails) - if is_zoom: - raise_if_zoom_link_invalid(location) + if vc_link is not None: + raise_if_zoom_link_invalid(vc_link) event = create_event(session, title, start, end, owner_id, content, - location, invitees=invited_emails, + location, vc_link, invitees=invited_emails, category_id=category_id, availability=availability) @@ -205,6 +205,7 @@ def update_event(event_id: int, event: Dict, db: Session def create_event(db: Session, title: str, start, end, owner_id: int, content: Optional[str] = None, location: Optional[str] = None, + vc_link: str = None, color: Optional[str] = None, invitees: List[str] = None, category_id: Optional[int] = None, @@ -222,6 +223,7 @@ def create_event(db: Session, title: str, start, end, owner_id: int, content=content, owner_id=owner_id, location=location, + vc_link=vc_link, color=color, emotion=get_emotion(title, content), invitees=invitees_concatenated, diff --git a/app/templates/event/partials/edit_event_details_tab.html b/app/templates/event/partials/edit_event_details_tab.html index 152a600b..0d2c1461 100644 --- a/app/templates/event/partials/edit_event_details_tab.html +++ b/app/templates/event/partials/edit_event_details_tab.html @@ -13,12 +13,13 @@
- - + + +
+ +
+ +
diff --git a/app/templates/event/partials/view_event_details_tab.html b/app/templates/event/partials/view_event_details_tab.html index 3e8380f5..f8d13cdc 100644 --- a/app/templates/event/partials/view_event_details_tab.html +++ b/app/templates/event/partials/view_event_details_tab.html @@ -23,7 +23,7 @@

{{ event.title }}

ICON
{{ event.location }}
- +
VC linkVC URL

diff --git a/tests/test_event.py b/tests/test_event.py index 94a48989..358aab72 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -19,8 +19,8 @@ 'start_time': '12:59', 'end_date': '2021-01-28', 'end_time': '15:01', - 'location_type': 'vc_url', - 'location': 'https://us02web.zoom.us/j/875384596', + 'location': 'fake city', + 'vc_link': 'https://us02web.zoom.us/j/875384596', 'description': 'content', 'color': 'red', 'availability': 'True', @@ -34,8 +34,8 @@ 'start_time': '15:59', 'end_date': '2021-01-27', 'end_time': '15:01', - 'location_type': 'vc_url', - 'location': 'not a zoom link', + 'location': 'fake city', + 'vc_link': 'not a zoom link', 'description': 'content', 'color': 'red', 'availability': 'True', @@ -49,8 +49,8 @@ 'start_time': '15:59', 'end_date': '2021-01-27', 'end_time': '15:01', - 'location_type': 'vc_url', - 'location': 'https://us02web.zoom.us/j/875384596', + 'location': 'fake city', + 'vc_link': 'https://us02web.zoom.us/j/875384596', 'description': 'content', 'color': 'red', 'availability': 'busy', @@ -64,8 +64,8 @@ 'start_time': '12:59', 'end_date': '2021-02-04', 'end_time': '15:01', - 'location_type': 'vc_url', - 'location': 'https://us02web.zoom.us/j/875384596', + 'location': 'fake city', + 'vc_link': 'https://us02web.zoom.us/j/875384596', 'description': 'content', 'color': 'red', 'availability': 'busy', @@ -79,8 +79,8 @@ 'start_time': '12:59', 'end_date': '2021-02-11', 'end_time': '15:01', - 'location_type': 'vc_url', - 'location': 'https://us02web.zoom.us/j/875384596', + 'location': 'fake city', + 'vc_link': 'https://us02web.zoom.us/j/875384596', 'description': 'content', 'color': 'red', 'availability': 'busy', @@ -107,7 +107,8 @@ def test_eventedit(event_test_client): def test_eventview_with_id(event_test_client, session, event): event_id = event.id - event_details = [event.title, event.content, event.location, event.start, + event_details = [event.title, event.content, event.location, + event.vc_link, event.start, event.end, event.color, event.category_id] response = event_test_client.get(f"/event/{event_id}") assert response.ok @@ -125,7 +126,7 @@ def test_create_event_with_default_availability(client, user, session): 'title': 'test title', 'start': datetime.strptime('2021-01-01 15:59', '%Y-%m-%d %H:%M'), 'end': datetime.strptime('2021-01-02 15:01', '%Y-%m-%d %H:%M'), - 'location': 'https://us02web.zoom.us/j/875384596', + 'vc_link': 'https://us02web.zoom.us/j/875384596', 'content': 'content', 'owner_id': user.id, } @@ -142,7 +143,7 @@ def test_create_event_with_free_availability(client, user, session): 'title': 'test title', 'start': datetime.strptime('2021-01-01 15:59', '%Y-%m-%d %H:%M'), 'end': datetime.strptime('2021-01-02 15:01', '%Y-%m-%d %H:%M'), - 'location': 'https://us02web.zoom.us/j/875384596', + 'vc_link': 'https://us02web.zoom.us/j/875384596', 'content': 'content', 'owner_id': user.id, 'availability': False, @@ -438,6 +439,7 @@ class TestApp: event_test_data = { 'title': "Test Title", "location": "Fake City", + 'vc_link': 'https://us02web.zoom.us/j/875384596', "start": date_test_data[0], "end": date_test_data[1], "content": "Any Words",