check for double registrations ...

i.e. do not overwrite but store and send a different csv
This commit is contained in:
Jan Grewe 2019-08-22 10:17:15 +02:00
parent 32bc459bb1
commit c05b3d4e7f

View File

@ -10,6 +10,7 @@ from email.message import EmailMessage
import re
import datetime as dt
import time
import glob
EMAIL_ACCOUNT = "bzigr02"
EMAIL_FOLDER = "INBOX"
@ -154,7 +155,13 @@ class Participation(object):
if not os.path.exists(PARTICIPANTS_FOLDER):
os.mkdir(PARTICIPANTS_FOLDER)
if not filename:
filename = os.path.join(PARTICIPANTS_FOLDER, "".join(self.name.split())) + ".csv"
stub = os.path.join(PARTICIPANTS_FOLDER, "".join(self.name.split())) + "*"
matches = glob.glob(stub)
if len(matches) > 0:
filename = os.path.join(PARTICIPANTS_FOLDER, "".join(self.name.split())) + "_%i" % len(matches) + ".csv"
else:
filename = os.path.join(PARTICIPANTS_FOLDER, "".join(self.name.split())) + ".csv"
header = ["LastName", "FirstName", "eMail", "Phone", "Institute", "Street", "City",
"RegDate", "CareerStage", "Fee", "FarewellEvent", "GwinnerAward", "LabTour",
"FoodVegetarian", "FoodVegan", "FoodGlutenFree", "FoodNoPref"]