Skip to content

Commit

Permalink
Merge pull request Yelp#173 from conancain/145-Calendar_link_not_time…
Browse files Browse the repository at this point in the history
…zone_aware

Issue Yelp#145: Make calendar link timezone aware
  • Loading branch information
ykdeal authored and okpoti2 committed Jul 29, 2022
2 parents c1d5fef + 2e212d6 commit bf7a10a
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 52 deletions.
7 changes: 4 additions & 3 deletions api/requirements-bootstrap.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pip==18.1
pip==22.1.2
pip-tools==6.8.0
pymonkey==0.3.1
venv-update==3.2.4
wheel==0.33.6
setuptools==60.9.3
wheel==0.37.1
36 changes: 18 additions & 18 deletions api/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
appdirs==1.4.4
attrs==20.3.0
cfgv==3.2.0
coverage==5.3.1
distlib==0.3.1
filelock==3.0.12
identify==1.5.10
attrs==21.4.0
cfgv==3.3.1
coverage==6.4.2
distlib==0.3.4
filelock==3.4.1
identify==2.5.1
iniconfig==1.1.1
mock==4.0.3
nodeenv==1.5.0
packaging==20.8
pluggy==0.13.1
pre-commit==2.9.3
py==1.10.0
pyparsing==2.4.7
pytest==6.2.1
requests-mock==1.8.0
requirements-tools==1.2.4
nodeenv==1.7.0
packaging==21.3
platformdirs==2.5.2
pluggy==1.0.0
pre-commit==2.19.0
py==1.11.0
pytest==7.1.2
requests-mock==1.9.3
requirements-tools==2.0.0
toml==0.10.2
tox==3.20.1
virtualenv==20.2.2
tomli==2.0.1
tox==3.25.1
virtualenv==20.15.1
63 changes: 33 additions & 30 deletions api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
arrow==1.1.1
boto3==1.16.45
botocore==1.19.45
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
decorator==4.4.2
Flask==1.1.2
arrow==1.2.2
boto3==1.24.24
botocore==1.27.24
certifi==2022.6.15
charset-normalizer==2.1.0
click==8.0.4
Flask==2.1.2
Flask-API-Utils==1.0.2
Flask-SQLAlchemy==2.4.4
httplib2==0.18.1
idna==2.10
itsdangerous==1.1.0
Jinja2==2.11.3
jmespath==0.10.0
MarkupSafe==1.1.1
networkx==2.5
psycopg2-binary==2.8.6
python-dateutil==2.8.1
python-http-client==3.3.1
pytz==2020.5
PyYAML==5.4
requests==2.25.1
s3transfer==0.3.3
sendgrid==6.4.8
setuptools==51.1.1
six==1.15.0
SQLAlchemy==1.3.22
starkbank-ecdsa==1.1.0
urllib3==1.26.5
Werkzeug==1.0.1
Flask-SQLAlchemy==2.5.1
greenlet==1.1.2
httplib2==0.20.4
idna==3.3
importlib-metadata==4.8.1
itsdangerous==2.1.2
Jinja2==3.1.2
jmespath==1.0.1
MarkupSafe==2.1.1
networkx==2.6.2
psycopg2-binary==2.9.3
pyparsing==3.0.9
python-dateutil==2.8.2
python-http-client==3.3.7
pytz==2022.1
PyYAML==6.0
requests==2.28.1
s3transfer==0.6.0
sendgrid==6.9.7
setuptools==60.9.3
six==1.16.0
SQLAlchemy==1.4.27
starkbank-ecdsa==2.0.3
urllib3==1.26.10
Werkzeug==2.1.2
zipp==3.6.0
35 changes: 35 additions & 0 deletions api/tests/send_email_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import datetime
from urllib.parse import parse_qs
from urllib.parse import urlparse

import pytest
import pytz
from yelp_beans.logic.meeting_spec import get_specs_for_current_week
from yelp_beans.matching.match import generate_meetings
from yelp_beans.models import User
from yelp_beans.models import UserSubscriptionPreferences
from yelp_beans.send_email import create_google_calendar_invitation_link
from yelp_beans.send_email import send_batch_initial_opt_in_email
from yelp_beans.send_email import send_batch_meeting_confirmation_email
from yelp_beans.send_email import send_batch_unmatched_email
Expand Down Expand Up @@ -58,3 +64,32 @@ def test_send_batch_meeting_confirmation_email(database, session):
def test_send_batch_unmatched_email(database, fake_user):
matches, unmatched = generate_meetings([fake_user], database.specs[0])
send_batch_unmatched_email(unmatched)

@pytest.mark.parametrize(
"test_datetime,expected_link_ctz",
[
(
datetime.datetime(2022, 5, 13, 23, 34, 45, tzinfo=pytz.timezone('America/Chicago')),
"America/Chicago"
),
(
datetime.datetime(2022, 5, 13, 23, 34, 45, tzinfo=pytz.timezone('America/Los_Angeles')),
"America/Los_Angeles"
),
(
datetime.datetime(2022, 5, 13, 23, 34, 45, tzinfo=pytz.timezone('Europe/London')),
"Europe/London"
),
(
datetime.datetime(2022, 5, 13, 23, 34, 45),
None
),
]
)
def test_create_google_calendar_invitation_link(test_datetime, expected_link_ctz):
generated_calendar_url = create_google_calendar_invitation_link([], "title", "office", "location", test_datetime,
test_datetime)
parsed_url = urlparse(generated_calendar_url)
ctz_param = parse_qs(parsed_url.query).get("ctz", None)
ctz_value = ctz_param[0] if ctz_param else None
assert ctz_value == expected_link_ctz
5 changes: 4 additions & 1 deletion api/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
project = beans
envlist = py38
sitepackages = True

requires =
tox==3.25.1
tox-requirements-bootstrap==1.0.0
tox-pip-sync==1.0.7
[testenv]
deps =
-rrequirements-dev.txt
Expand Down
6 changes: 6 additions & 0 deletions api/yelp_beans/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ def create_google_calendar_invitation_link(user_list, title, office, location, m
'location': office + " " + location,
'add': ','.join([user.email for user in user_list])
}
if meeting_datetime.tzinfo and meeting_datetime.tzinfo.zone:
# If the meeting time have a timezone specified
# and Calendar URL link doesn't contain timezone
# Add the "ctz" parameter to Google's Calendar template link
url_params["ctz"] = meeting_datetime.tzinfo.zone

invite_url += urllib.parse.urlencode(url_params)
return invite_url

Expand Down

0 comments on commit bf7a10a

Please sign in to comment.