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

Awstesting #13

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added FAQ.assets/image-20240117-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FAQ.assets/image-20240117-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ This page will list out quick responses, common bugs and their fixes, as well as
## After walking through [GETTING_STARTED.md](https://github.com/cs161-staff/extensions/blob/master/GETTING_STARTED.md)
* [The Form Responses tab is filling, but the Roster tab is not](#the-form-responses-tab-is-filling-but-the-roster-tab-is-not)
* [I need to change the name of the slack channel](#i-need-to-change-the-name-of-the-slack-channel)
* [I want to add custom comments without copy-pasting](#I-want-to-add-custom-comments-without-copy-pasting)
## Error messages
* ["Student \<name\> responded '' to DSP question in extension request, but is not marked for DSP approval on the roster. Please investigate!"](#snr)
* ["Error: ('An error occurred while sending an email:', Exception(... Insufficient system storage', '[email protected]'))"](#cs162)
@@ -35,6 +36,15 @@ This page will list out quick responses, common bugs and their fixes, as well as
### I need to change the name of the slack channel
>No problem! Changing the name of the slack channel where the webhook points will not affect it. You should be able to do this with no consequences.

### I want to add custom comments without copy-pasting
>You can take advantage of google sheets to do this! On a separate tab, type out any comments you want to be able to toggle off and on for any given email.
![image-20240117-1](FAQ.assets/image-20240117-1.png)

>Back in the roster tab, create two new columns. In one of the columns, column 1, insert a checkbox. In the other column, column 2, you can use the formula `IF(\<cell from column 1\>, \<cell of comment\>, "")`. If you want multiple comments you can use concatenate.
![image-20240117-1](FAQ.assets/image-20240117-2.png)

>To include the comment, toggle on the check box. If the checkbox is unchecked, the formula above will include an empty string instead of the comment.

<div id="snr"></div>

### "Student \<name\> responded '' to DSP question in extension request, but is not marked for DSP approval on the roster. Please investigate!"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ attrs==21.4.0
autopep8==1.6.0
beautifulsoup4==4.10.0
black==21.12b0
boto3==1.0.0
bs4==0.0.1
cachetools==4.2.4
certifi==2021.10.8
49 changes: 48 additions & 1 deletion src/email.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@

import os
from datetime import datetime, timedelta
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formataddr
from smtplib import SMTP_SSL, SMTPException
from typing import List

from sicp.common.rpc.mail import send_email
@@ -99,7 +103,7 @@ def fmt_date(dt: datetime):
body=body,
)

def send(self) -> None:
def OLDsend(self) -> None:
# TODO: When 162 adds HTML support, bring back HTML emails.
# html_body = Markdown().convert(self.body)
# extra_headers = [("Content-Type", "text/html; charset=UTF-8")]
@@ -125,3 +129,46 @@ def send(self) -> None:

except Exception as e:
raise EmailError("An error occurred while sending an email:", e)


def send(self) -> None:
PORT = 465 # For starttls
HOST = "bcop.berkeley.edu"
username = "svc-bcop-seamless-learning"
sender_email = "[email protected]"
SENDERNAME = Environment.get(ENV_EMAIL_FROM)
receiver_email = self.to_email
cc_emails = self.cc_emails
reply_to_email = self.reply_to_email
password = "RbLgAvAcba3Ba3chbsW5VQ4Z"
SUBJECT = self.subject
# message = """\
# Subject: Hi there

# This message is sent from Python."""

BODY_TEXT = ("BCOP TEST TEST")

msg = MIMEMultipart('alternative')
msg['Subject'] = SUBJECT
msg['From'] = formataddr((SENDERNAME, sender_email))
msg['To'] = receiver_email
msg.add_header('reply-to', reply_to_email)
if len(cc_emails) > 0:
msg['CC'] = ",".join(cc_emails)
# Comment or delete the next line if you are not using a configuration set
# msg.add_header('X-SES-CONFIGURATION-SET',CONFIGURATION_SET)

# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(self.body, 'plain')

# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part1)

with SMTP_SSL(HOST, PORT) as server:
server.login(username, password)
server.sendmail(sender_email, receiver_email, msg.as_string())
server.close()
print("Email sent!")