Spaces:
Runtime error
Runtime error
CaesarCloudSync
commited on
Commit
·
e8a860b
1
Parent(s):
e417bf9
checking if person exists in scheduled before changing card in changerevisioncard
Browse files- main.py +15 -13
- raspsendemail.py +5 -1
main.py
CHANGED
@@ -321,19 +321,21 @@ async def changerevisioncard(data : JSONStructure = None, authorization: str = H
|
|
321 |
email_exists = importcsv.db.accountrevisioncards.find_one({"email":current_user})
|
322 |
if email_exists: # Checks if email exists
|
323 |
# TODO Slightly buggy here - removes old schedule from the database.
|
324 |
-
|
325 |
-
if
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
|
|
|
|
337 |
|
338 |
user_revision_cards = list(importcsv.db.accountrevisioncards.find({"email": current_user}))[0]
|
339 |
left_over_image = []
|
|
|
321 |
email_exists = importcsv.db.accountrevisioncards.find_one({"email":current_user})
|
322 |
if email_exists: # Checks if email exists
|
323 |
# TODO Slightly buggy here - removes old schedule from the database.
|
324 |
+
scheduled_exists = importcsv.db.scheduledcards.find_one({"email":current_user})
|
325 |
+
if scheduled_exists:
|
326 |
+
user_scheduled_cards = list(importcsv.db.scheduledcards.find({"email": current_user}))[0]
|
327 |
+
if user_scheduled_cards :
|
328 |
+
for card in user_scheduled_cards["revisioncards"]:
|
329 |
+
oldcard = {i:data[i] for i in data if i!='newrevisioncard'}
|
330 |
+
|
331 |
+
if card == oldcard:
|
332 |
+
user_scheduled_cards["revisioncards"].remove(card)
|
333 |
+
#importcsv.db.scheduledcards.delete_many({"email":current_user})
|
334 |
+
#importcsv.db.scheduledcards.insert_one(user_scheduled_cards)
|
335 |
+
importcsv.db.scheduledcards.replace_one(
|
336 |
+
{"email":current_user},user_scheduled_cards
|
337 |
+
)
|
338 |
+
|
339 |
|
340 |
user_revision_cards = list(importcsv.db.accountrevisioncards.find({"email": current_user}))[0]
|
341 |
left_over_image = []
|
raspsendemail.py
CHANGED
@@ -17,6 +17,7 @@ class RaspEmail:
|
|
17 |
|
18 |
|
19 |
# Turn these into plain/html MIMEText objects
|
|
|
20 |
part1 = MIMEText(message, "html")
|
21 |
|
22 |
# Add HTML/plain-text parts to MIMEMultipart message.
|
@@ -50,7 +51,7 @@ class RaspEmail:
|
|
50 |
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
|
51 |
server.login(sender_email, password)
|
52 |
server.sendmail(
|
53 |
-
sender_email,
|
54 |
)
|
55 |
@staticmethod
|
56 |
def send_attachment(receiver_email,subject,filename,htmlmessage):
|
@@ -93,3 +94,6 @@ class RaspEmail:
|
|
93 |
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
|
94 |
server.login(sender_email, password)
|
95 |
server.sendmail(sender_email, receiver_email, text)
|
|
|
|
|
|
|
|
17 |
|
18 |
|
19 |
# Turn these into plain/html MIMEText objects
|
20 |
+
print(message)
|
21 |
part1 = MIMEText(message, "html")
|
22 |
|
23 |
# Add HTML/plain-text parts to MIMEMultipart message.
|
|
|
51 |
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
|
52 |
server.login(sender_email, password)
|
53 |
server.sendmail(
|
54 |
+
sender_email, email, message.as_string()
|
55 |
)
|
56 |
@staticmethod
|
57 |
def send_attachment(receiver_email,subject,filename,htmlmessage):
|
|
|
94 |
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
|
95 |
server.login(sender_email, password)
|
96 |
server.sendmail(sender_email, receiver_email, text)
|
97 |
+
if __name__ == "__main__":
|
98 |
+
RaspEmail.send(email="amari.lawal@gmail.com",subject="RevisionBank",message="<h1>Hello World</h1>")
|
99 |
+
#(**{"email":"amari.lawal@gmail.com","message":"Hello","subject":f"PhysicsAqa Papers"})
|