Changeset 7358 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 16 Dec 2011, 07:13:28 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r7335 r7358 50 50 ILocalRolesAssignable, DuplicationError, IConfigurationContainer, 51 51 ISessionConfiguration, ISessionConfigurationAdd, 52 IPasswordValidator, IContactForm )52 IPasswordValidator, IContactForm, ISIRPUtils) 53 53 from waeup.sirp.permissions import get_users_with_local_roles, get_all_roles 54 54 from waeup.sirp.students.catalog import search as searchstudents … … 58 58 from waeup.sirp.widgets.restwidget import ReSTDisplayWidget 59 59 from waeup.sirp.authentication import get_principal_role_manager 60 from waeup.sirp.utils.helpers import get_user_account , send_mail60 from waeup.sirp.utils.helpers import get_user_account 61 61 from waeup.sirp.browser.layout import jsaction, JSAction 62 62 … … 228 228 email_to = self.config.email_admin 229 229 subject = self.config.email_subject 230 success = send_mail(fullname,username,usertype,self.config.name, 231 body,email_from,email_to,subject) 230 sirp_utils = getUtility(ISIRPUtils) 231 success = sirp_utils.sendMail(fullname,username,usertype, 232 self.config.name,body,email_from,email_to,subject) 232 233 if success: 233 234 self.flash('Your message has been sent.') … … 252 253 subject = self.config.email_subject 253 254 usertype = u'Anonymous' 254 success = send_mail(fullname,username,usertype,self.config.name, 255 body,email_from,email_to,subject) 255 sirp_utils = getUtility(ISIRPUtils) 256 success = sirp_utils.sendMail(fullname,username,usertype, 257 self.config.name,body,email_from,email_to,subject) 256 258 if success: 257 259 self.flash('Your message has been sent.') … … 476 478 email_to = self.context.email 477 479 subject = self.config.email_subject 478 success = send_mail(fullname,username,usertype,self.config.name, 479 body,email_from,email_to,subject) 480 sirp_utils = getUtility(ISIRPUtils) 481 success = sirp_utils.sendMail(fullname,username,usertype, 482 self.config.name,body,email_from,email_to,subject) 480 483 if success: 481 484 self.flash('Your message has been sent.') -
main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py
r7323 r7358 140 140 return value 141 141 142 class ISIRPUtils(Interface): 143 """A collection of methods which are subject to customization. 144 """ 145 def sendMail(fullname,username,usertype,portal,body,email_from,email_to,subject): 146 """Send an email with data provided by forms. 147 """ 148 142 149 class ISIRPObject(Interface): 143 150 """A SIRP object. -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7357 r7358 40 40 from waeup.sirp.browser.layout import jsaction, JSAction 41 41 from waeup.sirp.interfaces import ( 42 ISIRPObject, IUserAccount, IExtFileStore, IPasswordValidator, IContactForm) 42 ISIRPObject, IUserAccount, IExtFileStore, IPasswordValidator, IContactForm, 43 ISIRPUtils) 43 44 from waeup.sirp.widgets.datewidget import ( 44 45 FriendlyDateWidget, FriendlyDateDisplayWidget, … … 60 61 from waeup.sirp.applicants.interfaces import IApplicantBaseData 61 62 from waeup.sirp.hostels.hostel import NOT_OCCUPIED 62 from waeup.sirp.utils.helpers import send_mail63 63 64 64 def write_log_message(view, message): … … 393 393 subject = data['subject'] 394 394 email_to = self.context.email 395 success = send_mail(fullname,username,usertype,self.config.name, 395 sirp_utils = getUtility(ISIRPUtils) 396 success = sirp_utils.sendMail(fullname,username,usertype,self.config.name, 396 397 body,email_from,email_to,subject) 397 398 if success: -
main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py
r7319 r7358 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 """General helper functions for the student section.18 """General helper functions and utilities for the student section. 19 19 """ 20 20 import grok -
main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py
r7321 r7358 480 480 account = authenticator.getAccount(principal_id) 481 481 return account 482 483 def send_mail(fullname,username,usertype,portal,body,email_from,email_to,subject):484 """Send an email with data provided by forms.485 """486 config = grok.getSite()['configuration']487 text = """Fullname: %s488 User Id: %s489 User Type: %s490 Portal: %s491 492 %s493 """494 msg = MIMEText(text % (fullname,username,usertype,portal,body))495 msg['From'] = '%s <%s>' % (fullname,email_from)496 msg['To'] = email_to497 msg['Subject'] = subject498 server = smtplib.SMTP(config.smtp_server)499 if config.smtp_requires_login:500 server.login(config.smtp_username,config.smtp_password)501 try:502 server.sendmail(email_from,email_to,msg.as_string())503 except:504 return False505 server.quit()506 return True
Note: See TracChangeset for help on using the changeset viewer.