WIP: contrôle cotisation

This commit is contained in:
Adrien Bourmault 2022-09-14 23:41:43 +02:00
parent aa55c5aa39
commit 104eab4859
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
2 changed files with 20 additions and 2 deletions

View File

@ -1,6 +1,7 @@
Content-Language: fr
From: =?UTF-8?Q?Tr=c3=a9sorier_de_Libre_en_Communs?= <tresorier@a-lec.org>
To: <COURRIEL-COTISANT>
Bcc: <tresorier@a-lec.org>
Subject: =?UTF-8?Q?=5bTr=c3=a9sorerie=5d_Re=c3=a7u_pour_votre_cotisation_de_?=
=?UTF-8?Q?membre?=
Mime-Version: 1.0

View File

@ -101,11 +101,13 @@ def sendmail(headers, data):
msg = bytes(headers + "\n", 'utf-8') + quopri.encodestring(bytes(data, 'utf-8'))
subprocess.run([SENDMAIL_LOCATION, "-t", "-oi"], input=msg)
def sendmail_with_attachment(headers, data, attachment_header, attachment):
def sendmail_with_attachment(headers, data, attachment_header, attachment, ending):
msg = bytes(headers + "\n", 'utf-8') \
+ quopri.encodestring(bytes(data, 'utf-8')) \
+ bytes(attachment_header + "\n", 'utf-8') \
+ bytes(attachment, 'base64')
+ bytes(attachment, 'base64') \
+ bytes(ending + "\n", 'utf-8')
subprocess.run([SENDMAIL_LOCATION, "-t", "-oi"], input=msg)
def gestion_get_expired():
@ -330,6 +332,21 @@ def validate(member):
os.system("cd {} && pdflatex {}".format(WORKDIR+"/validé/", filename+".tex"))
os.remove(WORKDIR+"/transition/"+member)
# Preparing mail
mailheaders = get_file_content_all(RECEPT_MAIL_HEADERS) + "\n"
mailtext = get_file_content_all(RECEPT_MAIL).replace("COURRIEL-COTISANT",
answer["email"]) + "\n")
mailtattach = get_file_content_all(RECEPT_MAIL_ATTACHMENT) + "\n"
# Opening PDF file as binary
attachment = open(WORKDIR+"/validé/", filename+".pdf", "rb")
data = attachment.read()
attachment.close()
ending = "\n--------------3yxkFgv0AINs5nd0i6BJrWaV--"
sendmail_with_attachment(mailheaders, mailtext, mailtattach, data, ending)
def validate_members():
for record in os.listdir(WORKDIR+"/transition"):
validate(record)