[SUCS Devel] [Git][sucs/accountmanager][master] Delete function now notifys the user and admins of deletes

Imran Hussain imranh at sucs.org
Sun Mar 10 11:42:56 GMT 2019


Imran Hussain pushed to branch master at sucs / accountmanager


Commits:
d4879af4 by Imran Hussain at 2019-03-10T11:42:15Z
Delete function now notifys the user and admins of deletes

- - - - -


3 changed files:

- + deleted-email
- + deleted-notify-email
- sucsam.py


Changes:

=====================================
deleted-email
=====================================
@@ -0,0 +1,13 @@
+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/
+


=====================================
deleted-notify-email
=====================================
@@ -0,0 +1,5 @@
+{$adminname} has deleted {$username}'s account.
+
+--
+The SUCS Account Manager
+https://projects.sucs.org/sucs/accountmanager
\ No newline at end of file


=====================================
sucsam.py
=====================================
@@ -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 at 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 at sucs.org'
+	receiver = email
+	message = MIMEMultipart()
+	message['From'] = sender
+	message['To'] = "logs at 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("")



View it on GitLab: https://projects.sucs.org/sucs/accountmanager/commit/d4879af44be2722e0cb4b7f35d656cea45fb41e9

-- 
View it on GitLab: https://projects.sucs.org/sucs/accountmanager/commit/d4879af44be2722e0cb4b7f35d656cea45fb41e9
You're receiving this email because of your account on projects.sucs.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/devel/attachments/20190310/a9b4c860/attachment-0001.html>


More information about the Devel mailing list