Commit d4879af4 authored by Imran Hussain's avatar Imran Hussain
Browse files

Delete function now notifys the user and admins of deletes

parent 1884aeb8
Hi {$realname},
Your Swansea University Computer Society account ({$username}) has been deleted.
Thank you for being a member!
We hope you enjoyed your time within the society and consider rejoining at some point.
--
Sent by {$adminname}
Swansea University Computer Society
https://sucs.org/
{$adminname} has deleted {$username}'s account.
--
The SUCS Account Manager
https://projects.sucs.org/sucs/accountmanager
\ No newline at end of file
......@@ -168,6 +168,55 @@ def listUsers():
for hon in hons:
print(str(hon[0]) + " (" + str(hon[1]) + ")")
def emailDeletedUser(userDBinfo):
username = userDBdata[0][1]
realname = userDBdata[0][2]
email = userDBdata[0][3]
adminname = pwd.getpwuid(os.geteuid())[0]
file = codecs.open("deleted-email", encoding='utf-8')
data = file.read()
file.close()
data = data.replace("{$realname}",realname)
data = data.replace("{$username}",username)
data = data.replace("{$adminname}",adminname)
sender = 'staff@sucs.org'
receiver = email
message = MIMEMultipart()
message['From'] = sender
message['To'] = receiver
message['Subject'] = 'Your SUCS account has been deleted'
messageBody = MIMEText(data, 'plain', "UTF-8")
message.attach(messageBody)
smtpConn = smtplib.SMTP('localhost')
smtpConn.sendmail(sender, receiver, message.as_string())
smtpConn.quit()
def emailAdminDeleteUser(username):
adminname = pwd.getpwuid(os.geteuid())[0]
file = codecs.open("deleted-notify-email", encoding='utf-8')
data = file.read()
file.close()
data = data.replace("{$username}",username)
data = data.replace("{$adminname}",adminname)
sender = 'staff@sucs.org'
receiver = email
message = MIMEMultipart()
message['From'] = sender
message['To'] = "logs@sucs.org"
message['Subject'] = username +''s SUCS account has been deleted'
messageBody = MIMEText(data, 'plain', "UTF-8")
message.attach(messageBody)
smtpConn = smtplib.SMTP('localhost')
smtpConn.sendmail(sender, receiver, message.as_string())
smtpConn.quit()
def deleteUser(peopleList):
#get fs ready
......@@ -237,7 +286,19 @@ def deleteUser(peopleList):
cur.execute("INSERT into oldmembers (username,realname) VALUES (%(user)s,%(realname)s)",{"user" : username,"realname" : userDBinfo[0][2]})
DBconn.commit()
cur.close()
#notify people
#them
emailDeletedUser(userDBinfo)
#logs@
emailAdminDeleteUser(person[0])
#remove the entry from the list
peoplelist.remove(person)
#return to the deletemenu with an empty list as we've just deleted everyone
deleteMenu(peoplelist)
def reminderMenu():
print("")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment