diff --git a/auction/database.db b/auction/database.db index aded12b..a4e7ae7 100644 Binary files a/auction/database.db and b/auction/database.db differ diff --git a/auction/routes.py b/auction/routes.py index 6290396..cd96de6 100644 --- a/auction/routes.py +++ b/auction/routes.py @@ -191,7 +191,7 @@ def sold(item_id): # allows a user to mark an item as sold # prevents another user marking items they don't own if item.user_id == user.id: # if the current user is the items owner - item.sold = True + item.sold = False db.session.commit() else: @@ -228,21 +228,24 @@ def bid(item_id): # allows a user to bid on an item def notify_winner(winner, item): # emails a user if they win an auction - message = "you have won the "+item.item_name+" auction!!" # not allowing me to send an email with a link in it, coming in blank - winner_email = winner.email - send_email("pythonflaskemail@gmail.com", "josephlees79@gmail.com", message) # changed reciever to reduce spam when testing + subj = "You won an auction!" + body = "Hey {}!".format(winner.username) + body += "\nYou just won the {} auction!".format(item.item_name) # not allowing me to send an email with a link in it, coming in blank + send_email("pythonflaskemail@gmail.com", winner.email, subj, body) # changed reciever to reduce spam when testing def notify_outbid(user, item): # emails a user if they are outbid - message = "you have been outbid on the "+item.item_name+" auction!" # wont allow me to put a link in the email - outbid_email = user.email - send_email("pythonflaskemail@gmail.com", "josephlees79@gmail.com", message) + subj = "You were just outbid!" + body = "Hey {}!".format(user.username) + body += "\nYou just got outbid on the {} auction!".format(item.item_name) # wont allow me to put a link in the email + send_email("pythonflaskemail@gmail.com", user.email, subj, body) -def send_email(sender, reciever, message): # sends the email using smtplib module +def send_email(sender, reciever, subj, message): # sends the email using smtplib module password = "Python150*" + msg = "From: %s\nTo: %s\nSubject: %s\n\n%s" % ( sender, reciever, subj, message ) server = smtplib.SMTP("smtp.gmail.com", 587) server.starttls() server.login(sender, password) - server.sendmail(sender, "josephlees79@gmail.com", message) \ No newline at end of file + server.sendmail(sender, "josephlees79@gmail.com", msg) \ No newline at end of file