Ticket #1078: 0002-FEATURE-Add-hook-to-get-etxra-payment-details.patch
File 0002-FEATURE-Add-hook-to-get-etxra-payment-details.patch, 5.9 KB (added by pedersen, 2 years ago) |
---|
-
indico/MaKaC/common/mail.py
From 180166a29006b56908ccca9e847365201b116110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Pedersen?= <bjoern.pedersen@frm2.tum.de> Date: Wed, 22 Aug 2012 13:41:09 +0200 Subject: [PATCH 2/4] [FEATURE] Add hook to get etxra payment details Add a hook in the payment module to get extra details from indiviual payment submodules --- indico/MaKaC/common/mail.py | 36 ++++++++++++++++++------------------ indico/MaKaC/registration.py | 24 ++++++++++++++++++++++-- indico/MaKaC/webinterface/mail.py | 3 ++- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/indico/MaKaC/common/mail.py b/indico/MaKaC/common/mail.py index ffe0f13..e95a577 100644
a b class GenericMailer: 144 144 for ctype, vpath, content in attachments: 145 145 146 146 maintype, subtype = ctype.split('/', 1) 147 if maintype == 'text':148 # Note: we should handle calculating the charset149 msg = MIMEText(content , _subtype=subtype)150 elif maintype == 'image':151 with open(content, 'rb') as fp:152 msg = MIMEImage(fp.read(), _subtype=subtype)153 elif maintype == 'audio':154 with open(content, 'rb') as fp:155 msg = MIMEAudio(fp.read(), _subtype=subtype)156 else:157 with open(content, 'rb') as fp:158 msg = MIMEBase(maintype, subtype)159 msg.set_payload(fp.read())160 # Encode the payload using Base64161 encoders.encode_base64(msg)162 # Set the filename parameter163 msg.add_header('Content-Disposition', 'attachment', filename=vpath)164 outer.attach(msg)147 if maintype == 'text': 148 # Note: we should handle calculating the charset 149 msg = MIMEText(content , _subtype=subtype) 150 elif maintype == 'image': 151 with open(content, 'rb') as fp: 152 msg = MIMEImage(fp.read(), _subtype=subtype) 153 elif maintype == 'audio': 154 with open(content, 'rb') as fp: 155 msg = MIMEAudio(fp.read(), _subtype=subtype) 156 else: 157 with open(content, 'rb') as fp: 158 msg = MIMEBase(maintype, subtype) 159 msg.set_payload(fp.read()) 160 # Encode the payload using Base64 161 encoders.encode_base64(msg) 162 # Set the filename parameter 163 msg.add_header('Content-Disposition', 'attachment', filename=vpath) 164 outer.attach(msg) 165 165 166 166 167 167 toList = notification.getToList() -
indico/MaKaC/registration.py
diff --git a/indico/MaKaC/registration.py b/indico/MaKaC/registration.py index b836f1a..cb6e84d 100644
a b Congratulations, your registration to %s was successful%s See your information b 804 804 else: 805 805 return False 806 806 807 def sendEmailNewRegistrantDetailsPay(self, regForm, registrant):807 def sendEmailNewRegistrantDetailsPay(self, regForm, registrant): 808 808 if not registrant.getConference().getModPay().isEnableSendEmailPaymentDetails(): 809 809 return 810 810 fromAddr = regForm.getNotificationSender() … … Congratulations, your registration to %s was successful%s See your information b 812 812 getTitle=strip_ml_tags(registrant.getConference().getTitle()) 813 813 idRegistrant=registrant.getIdPay() 814 814 detailPayment=registrant.getConference().getModPay().getPaymentDetails() 815 816 msgs = [] 817 attachments = [] 818 for ePayMod in registrant.getConference().getModPay().getSortedEnabledModPay(): 819 try: 820 msgs.append(ePayMod.getExtraPaymentDetails(registrant)) 821 except Exception: 822 pass 823 try: 824 attach = ePayMod.getExtraPaymentDetailsAttachment(registrant) 825 attachments.append(attach) 826 except Exception: 827 pass 828 detailPayment = detailPayment + "\n".join(msgs) 829 if len(attachments) < 1: 830 attachments = None 815 831 subject=_("""Payment summary for '%s': %s""")%(strip_ml_tags(registrant.getConference().getTitle()), registrant.getFullName()) 816 832 body= _(""" 817 833 Please use this information for your payment (except for e-payment):\n … … Please use this information for your payment (except for e-payment):\n 876 892 registrant.getConference().getModPay().getPaymentReceiptMsg(), 877 893 "\n".join(booking), body, paymentMsg) 878 894 to=registrant.getEmail().strip() 879 maildata = { "fromAddr": fromAddr, "toList": [to], "subject": subject, "body": bodyReg } 895 maildata = { "fromAddr": fromAddr, 896 "toList": [to], 897 "subject": subject, 898 "body": bodyReg , 899 "attachments": attachments} 880 900 GenericMailer.send(GenericNotification(maildata)) 881 901 882 902 def sendEmailNewRegistrantConfirmPay(self, regForm,registrant): -
indico/MaKaC/webinterface/mail.py
diff --git a/indico/MaKaC/webinterface/mail.py b/indico/MaKaC/webinterface/mail.py index f78fedb..43a63e7 100644
a b from MaKaC.common import Config 24 24 from MaKaC.i18n import _ 25 25 26 26 27 27 28 def getSubjectIndicoTitle(): 28 29 minfo=HelperMaKaCInfo.getMaKaCInfoInstance() 29 30 systitle="Indico" … … class GenericNotification : 145 146 return True 146 147 147 148 def getAttachments(self): 148 return self._ bodyHTML149 return self._attachments 149 150 150 151 def setAttachments(self, attachments): 151 152 if attachments is None :