Changeset 7221 for main/waeup.sirp/trunk
- Timestamp:
- 27 Nov 2011, 06:50:43 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/authentication.py
r7197 r7221 84 84 85 85 def __init__(self, name, password, title=None, description=None, 86 roles = []):86 email=None, roles = []): 87 87 self.name = name 88 88 if title is None: … … 92 92 self.title = title 93 93 self.description = description 94 self.email = email 94 95 self.setPassword(password) 95 96 #self.setSiteRolesForPrincipal(roles) -
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r7214 r7221 313 313 name = data['name'] 314 314 title = data['title'] 315 email = data['email'] 315 316 description = data['description'] 316 317 #password = data['password'] … … 326 327 return 327 328 try: 328 self.context.addUser(name, password, title=title, 329 self.context.addUser(name, password, title=title, email=email, 329 330 description=description, roles=roles) 330 331 except KeyError: … … 506 507 msg['From'] = '%s <%s>' % (fullname,email) 507 508 508 # These parameters should be part of the portal configuration. 509 msg['To'] = 'contact@waeup.org' 510 msg['Subject'] = 'WAeUP Contact' 511 #server = smtplib.SMTP('smtp_server') 512 # Also connection details (username, passwords, host, port, 513 # etc.) should be settable somewhere. 514 # server.login('user_name','secret_password') 515 server = smtplib.SMTP('localhost') 516 server.sendmail(email,'contact@waeup.org',msg.as_string()) 509 config = grok.getSite()['configuration'] 510 msg['To'] = config.email_admin 511 msg['Subject'] = config.email_subject 512 server = smtplib.SMTP(config.smtp_server) 513 if config.smtp_requires_login: 514 server.login(config.smtp_username,config.smtp_password) 515 server.sendmail(email,config.email_admin,msg.as_string()) 517 516 518 517 server.quit() -
main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py
r7197 r7221 17 17 ## 18 18 import os 19 import re 19 20 from datetime import datetime 20 21 from hurry.file.interfaces import IFileRetrieval … … 71 72 ) 72 73 74 # Define a valiation method for email addresses 75 class NotAnEmailAddress(schema.ValidationError): 76 __doc__ = u"Invalid email address" 77 78 check_email = re.compile( 79 r"[a-zA-Z0-9._%-]+@([a-zA-Z0-9-]+.)*[a-zA-Z]{2,4}").match 80 81 def validate_email(value): 82 if not check_email(value): 83 raise NotAnEmailAddress(value) 84 return True 85 73 86 class FatalCSVError(Exception): 74 87 """Some row could not be processed. … … 196 209 description = u'Login name of user', 197 210 required = True,) 211 198 212 title = schema.TextLine( 199 213 title = u'Name', 200 214 description = u'Real name of user', 201 215 required = False,) 216 202 217 description = schema.Text( 203 218 title = u'Description/Notice', 204 219 required = False,) 220 221 email = schema.ASCIILine( 222 title = u'Email', 223 default = None, 224 required = False, 225 constraint=validate_email, 226 ) 227 205 228 roles = schema.List( 206 229 title = u'Portal roles', … … 287 310 default = [], 288 311 ) 312 313 email_admin = schema.ASCIILine( 314 title = u'Email', 315 default = 'contact@waeup.org', 316 required = False, 317 constraint=validate_email, 318 ) 319 320 email_subject = schema.TextLine( 321 title = u'Subject of Email to Administrator', 322 default = u'SIRP Contact', 323 required = False, 324 ) 325 326 smtp_server = schema.TextLine( 327 title = u'Adress of SMTP Server', 328 default = u'localhost', 329 required = False, 330 ) 331 332 smtp_requires_login = schema.Bool( 333 title = u'Server requires login', 334 default = False, 335 ) 336 337 smtp_username = schema.TextLine( 338 title = u'Username for SMTP Account', 339 default = None, 340 required = False, 341 ) 342 343 smtp_password = schema.Password( 344 title = u'Password for SMTP Account', 345 default = None, 346 required = False, 347 ) 348 289 349 290 350 class ISessionConfiguration(IWAeUPObject): -
main/waeup.sirp/trunk/src/waeup/sirp/students/authentication.py
r7190 r7221 52 52 53 53 @property 54 def email(self): 55 return self.context.email 56 57 @property 54 58 def description(self): 55 59 return self.title -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r7214 r7221 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 import re19 18 from datetime import datetime 20 19 from zope.interface import Attribute, invariant, Interface 21 20 from zope.interface.exceptions import Invalid 22 21 from zope import schema 23 from waeup.sirp.interfaces import IWAeUPObject, academic_sessions_vocab 22 from waeup.sirp.interfaces import ( 23 IWAeUPObject, academic_sessions_vocab, validate_email) 24 24 from waeup.sirp.schema import TextLineChoice 25 25 from waeup.sirp.university.vocabularies import CourseSource, study_modes … … 30 30 from waeup.sirp.payments.interfaces import IPaymentsContainer, IOnlinePayment 31 31 32 # Define a valiation method for email addresses33 class NotAnEmailAddress(schema.ValidationError):34 __doc__ = u"Invalid email address"35 36 check_email = re.compile(37 r"[a-zA-Z0-9._%-]+@([a-zA-Z0-9-]+.)*[a-zA-Z]{2,4}").match38 def validate_email(value):39 if not check_email(value):40 raise NotAnEmailAddress(value)41 return True42 43 32 class IStudentsUtils(Interface): 44 33 """A collection of methods which are subject to customization. -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_authentication.py
r7193 r7221 63 63 fullname = 'Test User' 64 64 password = None 65 email = None 65 66 66 67 -
main/waeup.sirp/trunk/src/waeup/sirp/userscontainer.py
r7197 r7221 31 31 grok.require('waeup.manageUsers') 32 32 33 def addUser(self, name, password, title=None, description=None, roles=[]): 33 def addUser(self, name, password, title=None, 34 description=None, email=None, roles=[]): 34 35 """Add a new Account instance, created from parameters. 35 36 """ … … 38 39 #if description is None: 39 40 # description = title 40 self[name] = Account(name, password, title, description, roles)41 self[name] = Account(name, password, title, description, email, roles) 41 42 42 43 def addAccount(self, account):
Note: See TracChangeset for help on using the changeset viewer.