Changeset 7231 for main/waeup.sirp/trunk/src/waeup/sirp/browser
- Timestamp:
- 28 Nov 2011, 11:12:39 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r7229 r7231 189 189 190 190 # 191 # Contact form... 192 # 193 194 class ContactAdminForm(Form): 195 grok.name('contactadmin') 196 #grok.context(IUniversity) 197 grok.template('contactform') 198 grok.require('waeup.Authenticated') 199 pnav = 2 200 form_fields = grok.AutoFields(IContactForm).select('body') 201 202 @property 203 def config(self): 204 return grok.getSite()['configuration'] 205 206 def title(self): 207 userid = self.request.principal.id 208 return u'Contact %s' % self.config.name_admin 209 210 def label(self): 211 return self.title() 212 213 @property 214 def get_user_account(self): 215 return get_user_account(self.request) 216 217 @grok.action('Send message now') 218 def send(self, *args, **data): 219 useraccount = self.get_user_account 220 if useraccount is None: 221 self.flash("You don't have a user account.") 222 return 223 fullname = useraccount.title 224 email_from = useraccount.email 225 username = useraccount.name 226 body = data['body'] 227 email_to = self.config.email_admin 228 subject = self.config.email_subject 229 success = send_mail(fullname,username,self.config.name, 230 body,email_from,email_to,subject) 231 if success: 232 self.flash('Your message has been sent.') 233 else: 234 self.flash('An smtp server error occurred.') 235 return 236 237 class EnquiriesForm(ContactAdminForm): 238 grok.name('enquiries') 239 grok.require('waeup.Public') 240 pnav = 2 241 form_fields = grok.AutoFields(IContactForm).select( 242 'fullname', 'email_from', 'body') 243 244 @grok.action('Send now') 245 def send(self, *args, **data): 246 email_from = data['email_from'] 247 fullname = data['fullname'] 248 body = data['body'] 249 username = u'None' 250 email_to = self.config.email_admin 251 subject = self.config.email_subject 252 success = send_mail(fullname,username,self.config.name, 253 body,email_from,email_to,subject) 254 if success: 255 self.flash('Your message has been sent.') 256 else: 257 self.flash('A smtp server error occurred.') 258 return 259 260 # 191 261 # University related pages... 192 262 # … … 377 447 return 378 448 449 class ContactUserForm(ContactAdminForm): 450 grok.name('contactuser') 451 grok.context(IUserAccount) 452 grok.template('contactform') 453 grok.require('waeup.manageUsers') 454 pnav = 0 455 form_fields = grok.AutoFields(IContactForm).select('body') 456 457 @grok.action('Send message now') 458 def send(self, *args, **data): 459 useraccount = self.get_user_account 460 if useraccount is None: 461 self.flash("You don't have a user account.") 462 return 463 fullname = useraccount.title 464 email_from = useraccount.email 465 username = useraccount.name 466 body = data['body'] 467 email_to = self.context.email 468 subject = self.config.email_subject 469 success = send_mail(fullname,username,self.config.name, 470 body,email_from,email_to,subject) 471 if success: 472 self.flash('Your message has been sent.') 473 else: 474 self.flash('An smtp server error occurred.') 475 return 476 379 477 class UserEditFormPage(UserManageFormPage): 380 478 """Edit a user account by user … … 450 548 self.query = query 451 549 self.hitlist = search(query=self.query, view=self) 452 return453 454 #455 # Contact form...456 #457 458 class ContactAdminForm(Form):459 grok.name('contactadmin')460 #grok.context(IUniversity)461 grok.template('contactform')462 grok.require('waeup.Authenticated')463 pnav = 2464 form_fields = grok.AutoFields(IContactForm).select('body')465 466 @property467 def config(self):468 return grok.getSite()['configuration']469 470 def title(self):471 userid = self.request.principal.id472 return u'Contact %s' % self.config.name_admin473 474 def label(self):475 return self.title()476 477 @property478 def get_user_account(self):479 return get_user_account(self.request)480 481 @grok.action('Send message now')482 def send(self, *args, **data):483 useraccount = self.get_user_account484 if useraccount is None:485 self.flash("You don't have a user account.")486 return487 fullname = useraccount.title488 email_from = useraccount.email489 username = useraccount.name490 body = data['body']491 email_to = self.config.email_admin492 subject = self.config.email_subject493 success = send_mail(fullname,username,self.config.name,494 body,email_from,email_to,subject)495 if success:496 self.flash('Your message has been sent.')497 else:498 self.flash('An smtp server error occurred.')499 return500 501 class EnquiriesForm(ContactAdminForm):502 grok.name('enquiries')503 grok.require('waeup.Public')504 pnav = 2505 form_fields = grok.AutoFields(IContactForm).select(506 'fullname', 'email_from', 'body')507 508 @grok.action('Send now')509 def send(self, *args, **data):510 email_from = data['email_from']511 fullname = data['fullname']512 body = data['body']513 username = u'None'514 email_to = self.config.email_admin515 subject = self.config.email_subject516 success = send_mail(fullname,username,self.config.name,517 body,email_from,email_to,subject)518 if success:519 self.flash('Your message has been sent.')520 else:521 self.flash('A smtp server error occurred.')522 550 return 523 551 -
main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py
r7225 r7231 23 23 from waeup.sirp.browser.pages import ( 24 24 UniversityPage, FacultyContainerPage, DatacenterPage, FacultyPage, 25 DepartmentPage, CoursePage, CertificatePage, CertificateCoursePage, UsersContainerPage) 25 DepartmentPage, CoursePage, CertificatePage, CertificateCoursePage, 26 UsersContainerPage, UserManageFormPage) 26 27 from waeup.sirp.browser.interfaces import ( 27 28 IFacultyContainer, IFaculty, IDepartment, ICourse, ICertificate, 28 29 ICertificateCourse, IBreadcrumbContainer, IUniversity, IUsersContainer) 29 30 from waeup.sirp.interfaces import (IWAeUPObject, IWAeUPXMLExporter, 30 IWAeUPXMLImporter, IDataCenter )31 IWAeUPXMLImporter, IDataCenter, IUserAccount) 31 32 from waeup.sirp.browser.layout import WAeUPPage 32 33 from waeup.sirp.utils.helpers import get_user_account … … 336 337 text = u'Portal Users' 337 338 339 class ContactActionButton(ManageActionButton): 340 grok.order(4) 341 grok.context(IUserAccount) 342 grok.view(UserManageFormPage) 343 grok.require('waeup.manageUsers') 344 icon = 'actionicon_mail.png' 345 text = 'Send email' 346 target = 'contactuser' 347 338 348 class ManageDataCenter(ManageLink): 339 349 """A link to datacenter, placed in upper left box.
Note: See TracChangeset for help on using the changeset viewer.