Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/separate vc link #263

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9f12429
adding func to create new event
Jan 25, 2021
83a3f7d
fix linit (except the start of endpoint)
Jan 25, 2021
5e3035b
more fix of linit
Jan 25, 2021
11f89d5
and more linit
Jan 26, 2021
d97d751
delete long line
Jan 26, 2021
1d54aa2
add test for bad new event
Jan 26, 2021
5ec2490
linit fix
Jan 26, 2021
b96f5db
add tests for exception
Jan 26, 2021
fe6eff0
linit
Jan 26, 2021
010bb8b
change check_validation to check_date_validation
Jan 27, 2021
6d876a9
Merge branch 'develop' into develop
Michael-B-D Jan 27, 2021
0591114
linit
Jan 27, 2021
6ce4ad8
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Jan 27, 2021
86720df
Merge branch 'develop' of https://github.com/Michael-B-D/calendar int…
Jan 27, 2021
538450d
linit
Jan 27, 2021
425462a
add more tests
Jan 27, 2021
54f7eb7
use return early in event.py
Jan 29, 2021
19923eb
delete line
Jan 29, 2021
fb4a125
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Jan 29, 2021
f498b0f
/
Jan 29, 2021
6438198
pull
Jan 29, 2021
7020d75
delete whitespace
Jan 29, 2021
0b46709
add else
Feb 1, 2021
1e8b415
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 1, 2021
8bc524a
add logger
Feb 1, 2021
624fb40
lint
Feb 1, 2021
986d056
/
Feb 1, 2021
3f10db9
line
Feb 1, 2021
4f03231
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 2, 2021
8b41b4d
update
Feb 2, 2021
dfbb0e0
.
Feb 3, 2021
8b9e415
.
Feb 3, 2021
9a2d80d
linit
Feb 3, 2021
8c3f9ed
try to fix linit
Feb 5, 2021
80ce83d
try agein
Feb 5, 2021
8f6dff3
linit
Feb 5, 2021
c5da8e8
remove vc_link from tests
Feb 5, 2021
07b423c
change func is_date_before name
Feb 5, 2021
0b9fd43
.
Feb 5, 2021
b490663
.
Feb 5, 2021
a565433
moving test to test_event
Feb 6, 2021
f3dd91a
linit
Feb 6, 2021
522d68b
add venv to gitignore
Feb 8, 2021
c07fcdc
remove venv
Feb 8, 2021
c0c4033
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 8, 2021
c9c08bc
LINIT
Feb 8, 2021
b455f73
/
Feb 8, 2021
593d612
/
Feb 8, 2021
860a8e1
add claint in test app
Feb 8, 2021
2606920
/
Feb 8, 2021
b28d1ac
/
Feb 8, 2021
5f222ad
.
Feb 8, 2021
be7279c
separat vc link and location
Feb 11, 2021
4c5d7b8
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 11, 2021
7a5d783
change to vc_link in all files
Feb 11, 2021
71f1f28
tests_event is run
Feb 11, 2021
ab676b1
fix lint
Feb 11, 2021
069524b
add vc link
Feb 12, 2021
f824042
add leabels to html
Feb 13, 2021
f635e16
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 13, 2021
2e37367
remove duplicat in creat_event func
Feb 13, 2021
ed64963
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/internal/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type annotations

if ZOOM_REGEX.search(vc_link) is None:
raise HTTPException(status_code=HTTP_400_BAD_REQUEST,
detail="VC type with no valid zoom link")

Expand Down
12 changes: 7 additions & 5 deletions app/routers/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'availability': bool,
'content': (str, type(None)),
'location': (str, type(None)),
'vc_link': (str, type(None)),
'category_id': (int, type(None)),
}

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
13 changes: 7 additions & 6 deletions app/templates/event/partials/edit_event_details_tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
</div>

<div class="form_row">
<select name="location_type" required>
<option value="" disabled selected>Type</option>
<option value="vc_url">VC URL</option>
<option value="address">Address</option>
</select>
<input type="text" name="location" placeholder="VC URL/Location">
<label for="location">Location </label>
<input type="text" id="location" name="location" placeholder="Location">
</div>

<div class="form_row">
<label for="vc_link">VC link: </label>
<input type="text" id="vc_link" name="vc_link" placeholder="VC URL">
</div>

<div class="form_row">
Expand Down
2 changes: 1 addition & 1 deletion app/templates/event/partials/view_event_details_tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>{{ event.title }}</h1>
<div class="event_info_row">
<span class="icon">ICON</span>
<address>{{ event.location }}</address>
<!-- <address>LOCATION / <a href="#">VC URL</a></address>-->
<address>VC link<a href="{{ event.vc_link }}">VC URL</a></address>
</div>

<p class="event_info_row">
Expand Down
28 changes: 15 additions & 13 deletions tests/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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
Expand All @@ -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,
}
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand Down