This is a snapshot of Indico's old Trac site. Any information contained herein is most probably outdated. Access our new GitHub site here.

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)

new version of the hooks

  • 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: 
    144144            for ctype, vpath, content in attachments: 
    145145 
    146146                maintype, subtype = ctype.split('/', 1) 
    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) 
     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) 
    165165 
    166166 
    167167        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 
    804804        else: 
    805805            return False 
    806806 
    807     def sendEmailNewRegistrantDetailsPay(self, regForm,registrant): 
     807    def sendEmailNewRegistrantDetailsPay(self, regForm, registrant): 
    808808        if not registrant.getConference().getModPay().isEnableSendEmailPaymentDetails(): 
    809809            return 
    810810        fromAddr = regForm.getNotificationSender() 
    Congratulations, your registration to %s was successful%s See your information b 
    812812        getTitle=strip_ml_tags(registrant.getConference().getTitle()) 
    813813        idRegistrant=registrant.getIdPay() 
    814814        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 
    815831        subject=_("""Payment summary for '%s': %s""")%(strip_ml_tags(registrant.getConference().getTitle()), registrant.getFullName()) 
    816832        body= _(""" 
    817833Please use this information for your payment (except for e-payment):\n 
    Please use this information for your payment (except for e-payment):\n 
    876892                registrant.getConference().getModPay().getPaymentReceiptMsg(), 
    877893                "\n".join(booking), body, paymentMsg) 
    878894            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} 
    880900            GenericMailer.send(GenericNotification(maildata)) 
    881901 
    882902    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 
    2424from MaKaC.i18n import _ 
    2525 
    2626 
     27 
    2728def getSubjectIndicoTitle(): 
    2829    minfo=HelperMaKaCInfo.getMaKaCInfoInstance() 
    2930    systitle="Indico" 
    class GenericNotification : 
    145146        return True 
    146147 
    147148    def getAttachments(self): 
    148         return self._bodyHTML 
     149        return self._attachments 
    149150 
    150151    def setAttachments(self, attachments): 
    151152        if attachments is None :