Ignore:
Timestamp:
09/19/07 15:22:13 (12 years ago)
Author:
pjotr
Message:

Modified the sendAnswers method to actualy send e-mails, we are now using secureSend instead of just send, the message id now uncoded proper utf-8 and readable, also added messaging part to the fullscreen_template so that the messages would be shown

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ExerciseMaterial.py

    r2036 r2038  
    176176        if not students_email or (teachers_email and not students_name): 
    177177            msg = _(u"You have not provided enough information to send an e-mail.") 
    178             putils.addPortalMessage(msg) 
     178            putils.addPortalMessage(msg, type='warn') 
    179179            return REQUEST.RESPONSE.redirect(self.absolute_url()) 
    180180        exercise_body = self.getBodyText() 
     
    262262             
    263263        mbody += _(u"\n\nBest regards, LeMill") 
    264          
    265         #message_from = "%s <%s>" % (students_name, students_email) 
    266         #message_subject = "Answers to exercise %s by %s" % (self.Title(), students_name) 
    267 #        try: 
    268 #            mhost.send(message, mto=teachers_email, mfrom=message_from, subject=message_subject) 
    269         msg = _(u"The e-mail has been sent to a teacher.") 
    270         putils.addPortalMessage(msg) 
    271         return REQUEST.RESPONSE.redirect(self.absolute_url()) 
    272 #        except: 
    273 #            msg = _(u"The e-mail could not be sent.") 
    274 #            putils.addPortalMessage(msg) 
    275 #            return REQUEST.RESPONSE.redirect(self.absolute_url()) 
    276  
    277  
     264        mbody = mbody.encode('utf-8') 
     265 
     266        if teachers_email: 
     267            message_from = "%s <%s>" % (students_name, students_email) 
     268            message_subject = "LeMill exercise '%s' by %s" % (self.Title(),students_name) 
     269            try: 
     270                mhost.secureSend(mbody, mto=teachers_email, mfrom=message_from, subject=message_subject, charset='utf-8') 
     271                msg = _(u"The e-mail has been sent to a teacher.") 
     272                putils.addPortalMessage(msg) 
     273                return REQUEST.RESPONSE.redirect(self.absolute_url()) 
     274            except: 
     275                msg = _(u"The e-mail could not be sent.") 
     276                putils.addPortalMessage(msg, type='warn') 
     277                return REQUEST.RESPONSE.redirect(self.absolute_url()) 
     278        else: 
     279            message_from = "%s <%s>" % ('LeMill', students_email) 
     280            message_subject = "LeMill exercise '%s' feedback" % (self.Title()) 
     281            try: 
     282                mhost.secureSend(mbody, mto=students_email, mfrom=message_from, subject=message_subject, charset='utf-8') 
     283                msg = _(u"The e-mail has been sent to you.") 
     284                putils.addPortalMessage(msg) 
     285                return REQUEST.RESPONSE.redirect(self.absolute_url()) 
     286            except: 
     287                msg = _(u"The e-mail could not be sent.") 
     288                putils.addPortalMessage(msg, type='warn') 
     289                return REQUEST.RESPONSE.redirect(self.absolute_url()) 
    278290 
    279291 
Note: See TracChangeset for help on using the changeset viewer.