Changeset 7229 for main/waeup.sirp/trunk/src/waeup/sirp/students
- Timestamp:
- 28 Nov 2011, 10:35:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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):
Note: See TracChangeset for help on using the changeset viewer.