some polishing

This commit is contained in:
Jan Grewe 2019-08-22 10:34:59 +02:00
parent 532c1da85d
commit 772a9196a6

View File

@ -84,9 +84,9 @@ class Participation(object):
def __check(self):
if "student" not in self._role and self.gwinner_award:
self._conflicts.append("Gwinner award selected but not student!")
self._conflicts.append("Gwinner award selected but participant not student!")
if (self._food_vegan or self._food_gluten or self._food_vegi) and self._food_normal:
self._conflicts.append("Conflict in food preferences!")
self._conflicts.append("Possible conflict in food preferences!")
def __calc_fee(self):
fee = .0
@ -247,7 +247,7 @@ def process_registrations(M):
return participations
msgs = msgs[0].decode('ascii').split()
print("Found %i registration mails" % len(msgs))
print("\tFound %i registration mails" % len(msgs), file=log_file)
for msg_index in msgs:
participations.append(process_message(M, msg_index))
return participations
@ -256,7 +256,7 @@ def process_registrations(M):
def send_confirmation(p=None, csv_file=None):
if p is not None:
assert(isinstance(p, Participation))
content = "Dear %s," % (p.name if p else "participant")
content = "Dear %s,\n\n" % (p.name if p else "participant")
with open("response.txt") as fp:
content += fp.read()
content += "\n"
@ -281,11 +281,13 @@ def send_confirmation(p=None, csv_file=None):
csv_msg['To'] = p._email # FIXME this is wrong!!! needs to be EMAIL_REPLY
content = ""
if p and not p.valid:
content += "Registration contains inconsistencies!\n"
content += "Registration contains inconsistencies!\n\t"
content += p.inconsistencies
content += "\n"
content += "\n\n"
if p and len(p.message) > 0:
content += "Participant left a message:\n %s \n\n" % p.message
if "_" in csv_file:
content += "This seems to be a duplication or correction of an existing registration!\n"
csv_msg.set_content(content)
with open(csv_file, 'rb') as fp:
file_data = fp.read()
@ -312,7 +314,7 @@ def check_for_mails():
new_participations = process_registrations(M)
for p in new_participations:
print("New registration by %s" % p.name, file=log_file)
print("\tNew registration by %s" % p.name, file=log_file)
csv_file = p.save_to_csv()
send_confirmation(p, csv_file)
M.close()