- Timestamp:
- 28 Nov 2011, 10:35:47 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/authentication.py
r7192 r7229 245 245 return None 246 246 247 def getAccount(self, login): 248 return None 249 247 250 class ApplicantsAuthUtility(grok.GlobalUtility): 248 251 """A global utility that sets up any PAU passed. -
main/waeup.sirp/trunk/src/waeup/sirp/browser/__init__.py
r7137 r7229 4 4 WAeUPPage, WAeUPLayout, WAeUPDisplayFormPage, WAeUPEditFormPage, 5 5 WAeUPAddFormPage, NullValidator) 6 from waeup.sirp.browser.pages import ContactAdminForm 6 7 7 8 IMAGE_PATH = os.path.join( -
main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt
r7225 r7229 45 45 >>> print browser.contents 46 46 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... 47 ... There were errors...47 ...>Required input is missing... 48 48 ... 49 49 -
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r7227 r7229 479 479 return get_user_account(self.request) 480 480 481 @grok.action('Send now')481 @grok.action('Send message now') 482 482 def send(self, *args, **data): 483 483 useraccount = self.get_user_account -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7205 r7229 31 31 from waeup.sirp.accesscodes.workflow import USED 32 32 from waeup.sirp.browser import ( 33 WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, WAeUPDisplayFormPage) 33 WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, WAeUPDisplayFormPage, 34 ContactAdminForm) 34 35 from waeup.sirp.browser.breadcrumbs import Breadcrumb 35 36 from waeup.sirp.browser.resources import datepicker, datatable, tabs … … 37 38 ManageActionButton, AddActionButton) 38 39 from waeup.sirp.interfaces import ( 39 IWAeUPObject, IUserAccount, IExtFileStore, IPasswordValidator )40 IWAeUPObject, IUserAccount, IExtFileStore, IPasswordValidator, IContactForm) 40 41 from waeup.sirp.widgets.datewidget import ( 41 42 FriendlyDateWidget, FriendlyDateDisplayWidget, … … 57 58 from waeup.sirp.authentication import get_principal_role_manager 58 59 from waeup.sirp.hostels.hostel import NOT_OCCUPIED 60 from waeup.sirp.utils.helpers import get_user_account, send_mail 59 61 60 62 def write_log_message(view, message): … … 350 352 return 'set' 351 353 return 'unset' 354 355 class ContactActionButton(ManageActionButton): 356 grok.order(4) 357 grok.context(IStudent) 358 grok.view(StudentBaseDisplayFormPage) 359 grok.require('waeup.manageStudent') 360 icon = 'actionicon_mail.png' 361 text = 'Send email' 362 target = 'contacstudent' 363 364 class ContactStudentForm(ContactAdminForm): 365 grok.context(IStudent) 366 grok.name('contacstudent') 367 grok.require('waeup.manageStudent') 368 pnav = 4 369 title = 'Contact' 370 form_fields = grok.AutoFields(IContactForm).select('subject', 'body') 371 372 def label(self): 373 return u'Send message to %s' % self.context.fullname 374 375 @grok.action('Send message now') 376 def send(self, *args, **data): 377 useraccount = self.get_user_account 378 if useraccount is None: 379 self.flash("You don't have a user account.") 380 return 381 fullname = useraccount.title 382 email_from = useraccount.email 383 username = useraccount.name 384 body = data['body'] 385 #subject = u'Mail from SIRP' 386 subject = data['subject'] 387 email_to = self.context.email 388 success = send_mail(fullname,username,self.config.name, 389 body,email_from,email_to,subject) 390 if success: 391 self.flash('Your message has been sent.') 392 else: 393 self.flash('An smtp server error occurred.') 394 return 352 395 353 396 class StudentBaseManageActionButton(ManageActionButton): -
main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py
r7225 r7229 27 27 from cStringIO import StringIO 28 28 from docutils.core import publish_string 29 from zope.component import getUtility 29 from zope.component import getUtility, getUtilitiesFor 30 30 from zope.component.interfaces import IFactory 31 31 from zope.interface import implementedBy … … 477 477 """ 478 478 principal_id = request.principal.id 479 authenticator = getUtility(IAuthenticatorPlugin, name='users') 480 account = authenticator.getAccount(principal_id) 479 authenticators = getUtilitiesFor(IAuthenticatorPlugin) 480 for authenticator in authenticators: 481 account = authenticator[1].getAccount(principal_id) 482 if account: 483 break 481 484 return account 482 485
Note: See TracChangeset for help on using the changeset viewer.