Changeset 5426 for main/waeup.sirp/branches/henrik-contactforms/src/waeup
- Timestamp:
- 12 Aug 2010, 13:18:42 (14 years ago)
- Location:
- main/waeup.sirp/branches/henrik-contactforms/src/waeup/sirp/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/henrik-contactforms/src/waeup/sirp/browser/pages.py
r5414 r5426 8 8 import re 9 9 import sys 10 import time 11 import re 12 import smtplib 13 from email.mime.text import MIMEText 10 14 from hurry import yui 11 15 from hurry.workflow.interfaces import NoTransitionAvailableError … … 313 317 tt = u'Enquiries' 314 318 return tt 319 320 def update(self, *args, **kw): 321 form = self.request.form 322 if not ('fullname' in form and 'email' in form and 'descr' in form): 323 return 324 self.fullname = fullname = form['fullname'] 325 email = form['email'] 326 self.descr = descr = form['descr'] 327 regno =form['regno'] 328 if not (fullname and email and descr): 329 self.flash('Error: All fields must be filled!') 330 return 331 if not re.match("^[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", email): 332 self.flash('Error: %s is not a valid email address!' % email) 333 return 334 if regno == 'zope.anybody': 335 regno = 'Anonymous User' 336 text = """Fullname: %s 337 Member ID: %s 338 Description: %s 339 """ 340 msg = MIMEText(text % (fullname,regno,descr)) 341 msg['From'] = '%s <%s>' % (fullname,email) 342 msg['To'] = 'henrik@waeup.org' 343 msg['Subject'] = 'WAeUP Contact' 344 server = smtplib.SMTP('smtp.scientific-african.org') 345 server.login('henrik@scientific-african.org','kwamekofi') 346 server.sendmail(email,'henrik@waeup.org',msg.as_string()) 347 server.quit() 348 self.flash('Your message has been sent.') 349 return 315 350 316 351 # -
main/waeup.sirp/branches/henrik-contactforms/src/waeup/sirp/browser/templates/contactadminform.pt
r5414 r5426 1 <form id="form1" name="form1" method="post" action="mail2admin">1 <form id="form1" name="form1" method="post"> 2 2 <input type="hidden" name="regno" type="text" id="regno" 3 3 tal:attributes="value layout/getUserId"/> … … 8 8 </td> 9 9 <td tal:condition="not:layout/isAuthenticated"> 10 <input name="fullname" type="text" id="fullname" />10 <input name="fullname" type="text" id="fullname" tal:attributes="value view/fullname|nothing" /> 11 11 </td> 12 <td tal:condition="layout/isAuthenticated" tal:content="layout/getUserTitle"> 13 User Name 12 <td tal:condition="layout/isAuthenticated"> 13 <span tal:content="layout/getUserTitle" /> 14 <input type="hidden" name="fullname" type="text" id="fullname" 15 tal:attributes="value layout/getUserTitle"/> 14 16 </td> 15 17 </tr> … … 27 29 </td> 28 30 <td> 29 <textarea name="descr" rows="10" cols="60" id="descr"></textarea> 31 <textarea name="descr" rows="10" cols="60" id="descr"><span tal:replace="view/descr|nothing" /></textarea> 32 30 33 </td> 31 34 </tr>
Note: See TracChangeset for help on using the changeset viewer.