-
Notifications
You must be signed in to change notification settings - Fork 6
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
Gcal Integration #378
base: master
Are you sure you want to change the base?
Gcal Integration #378
Changes from 1 commit
137f73e
0ab0f57
35f82bd
e1b9ada
0168e78
ccbdd7e
9bea3e1
581c692
89d636d
858324f
f242563
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ db.sqlite3 | |
venv | ||
staticfiles/* | ||
!staticfiles/.gitignore | ||
.env | ||
.envrc | ||
.direnv | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,12 @@ | |
from pytz import timezone, utc | ||
from sentry_sdk import capture_exception | ||
|
||
from bot.utils import build_share_string, comma_split | ||
from common.utils import get_slack_client | ||
from pennychat.models import PennyChatSlackInvitation, Participant | ||
from users.models import ( | ||
SocialProfile, | ||
get_or_create_social_profile_from_slack_id, | ||
get_or_create_social_profile_from_slack_ids, | ||
) | ||
|
||
VIEW_SUBMISSION = 'view_submission' | ||
|
@@ -197,11 +197,13 @@ def _penny_chat_details_blocks(penny_chat_invitation, mode=None): | |
if include_calendar_link: | ||
start_date = penny_chat_invitation.date.astimezone(utc).strftime('%Y%m%dT%H%M%SZ') | ||
end_date = (penny_chat_invitation.date.astimezone(utc) + timedelta(hours=1)).strftime('%Y%m%dT%H%M%SZ') | ||
|
||
description = f'{penny_chat_invitation.description} [Video Link]({penny_chat_invitation.video_conference_link})' | ||
google_cal_url = 'https://calendar.google.com/calendar/render?' \ | ||
'action=TEMPLATE&text=' \ | ||
f'{urllib.parse.quote(penny_chat_invitation.title)}&dates=' \ | ||
f'{start_date}/{end_date}&details=' \ | ||
f'{urllib.parse.quote(penny_chat_invitation.description)}' | ||
f'{urllib.parse.quote(description)}' | ||
|
||
date_time_block['accessory'] = { | ||
'type': 'button', | ||
|
@@ -240,6 +242,45 @@ def _penny_chat_details_blocks(penny_chat_invitation, mode=None): | |
date_time_block | ||
] | ||
|
||
if penny_chat_invitation.video_conference_link: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably a nit pick, but rather than have 3 sections here, I'd just have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So just remove the Video Link header from the invite and add parentheses? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, just like you did - looks good |
||
body.append( | ||
{ | ||
'type': 'section', | ||
'text': { | ||
'type': 'mrkdwn', | ||
'text': f'*Video Call Link*' | ||
mrshwah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
) | ||
if mode in {PREVIEW, INVITE, UPDATE}: | ||
body.append( | ||
{ | ||
'type': 'section', | ||
'text': { | ||
'type': 'mrkdwn', | ||
'text': f'A video link will be provided shortly before the chat starts' | ||
} | ||
} | ||
) | ||
elif mode in {REMIND}: | ||
body.append( | ||
{ | ||
'type': 'actions', | ||
'elements': [ | ||
{ | ||
'type': 'button', | ||
'text': { | ||
'type': 'plain_text', | ||
'text': 'Join Video Call :call_me_hand:', | ||
'emoji': True, | ||
}, | ||
'url': penny_chat_invitation.video_conference_link, | ||
'style': 'primary', | ||
} | ||
] | ||
} | ||
) | ||
|
||
if include_rsvp: | ||
body.append( | ||
{ | ||
|
@@ -368,25 +409,7 @@ def _followup_reminder_blocks(penny_chat_invitation): | |
|
||
|
||
def organizer_edit_after_share_blocks(slack_client, penny_chat_invitation): | ||
shares = [] | ||
users = get_or_create_social_profile_from_slack_ids( | ||
comma_split(penny_chat_invitation.invitees), | ||
slack_client=slack_client, | ||
) | ||
for slack_user_id in comma_split(penny_chat_invitation.invitees): | ||
shares.append(users[slack_user_id].real_name) | ||
|
||
if len(penny_chat_invitation.channels) > 0: | ||
for channel in comma_split(penny_chat_invitation.channels): | ||
shares.append(f'<#{channel}>') | ||
|
||
if len(shares) == 1: | ||
share_string = shares[0] | ||
elif len(shares) == 2: | ||
share_string = ' and '.join(shares) | ||
elif len(shares) > 2: | ||
shares[-1] = f'and {shares[-1]}' | ||
share_string = ', '.join(shares) | ||
share_string = build_share_string(slack_client, penny_chat_invitation) | ||
|
||
shared_message_preview_blocks = _penny_chat_details_blocks(penny_chat_invitation, mode=PREVIEW) + [ | ||
{ | ||
|
@@ -422,8 +445,3 @@ def organizer_edit_after_share_blocks(slack_client, penny_chat_invitation): | |
] | ||
|
||
return shared_message_preview_blocks | ||
|
||
|
||
def comma_split(comma_delimited_string): | ||
"""normal string split for ''.split(',') returns [''], so using this instead""" | ||
return [x for x in comma_delimited_string.split(',') if x] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a new line?
...description}\n[Video...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, I totally forgot to revisit this. Adding to todos...