Ignore:
Timestamp:
28 Nov 2011, 21:42:28 (13 years ago)
Author:
Henrik Bettermann
Message:

Use new principal attributes in contact form pages (applicants not yet ready).

(And some missing things from last checkin).

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/authentication.py

    r7229 r7234  
    245245        return None
    246246
    247     def getAccount(self, login):
    248         return None
    249 
    250247class ApplicantsAuthUtility(grok.GlobalUtility):
    251248    """A global utility that sets up any PAU passed.
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt

    r7233 r7234  
    4545  >>> print browser.contents
    4646  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    47   ...>Required input is missing...
     47  ...Required input is missing...
    4848  ...
    4949
     
    187187  ...
    188188
    189 We fill the form and try to send message to contact@waeup.org)::
     189We fill the form  (this will send a real message to
     190contact@waeup.org)::
    190191
    191192  >>> browser.open('http://localhost/myuniversity/contactadmin')
     
    194195  >>> print browser.contents
    195196  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    196   ...<li class="message">You don't have a user account.</li>
    197   ...
    198 
    199 We can't send messages without a user account.
     197  ...<li class="message">Your message has been sent.</li>
     198  ...
     199
     200If this test fails, chances are, that the local machine has no SMTP
     201server installed.
     202
    200203
    201204
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r7233 r7234  
    216216    @grok.action('Send message now')
    217217    def send(self, *args, **data):
    218         useraccount = self.get_user_account
    219         if useraccount is None:
    220             self.flash("You don't have a user account.")
    221             return
    222         fullname = useraccount.title
    223         email_from = useraccount.email
    224         username = useraccount.name
     218        fullname = self.request.principal.title
     219        try:
     220            email_from = self.request.principal.email
     221        except AttributeError:
     222            email_from = self.config.email_admin
     223        username = self.request.principal.id
    225224        body = data['body']
    226225        email_to = self.config.email_admin
     
    462461    @grok.action('Send message now')
    463462    def send(self, *args, **data):
    464         useraccount = self.get_user_account
    465         if useraccount is None:
    466             self.flash("You don't have a user account.")
    467             return
    468         fullname = useraccount.title
    469         email_from = useraccount.email
    470         username = useraccount.name
     463        fullname = self.request.principal.title
     464        try:
     465            email_from = self.request.principal.email
     466        except AttributeError:
     467            email_from = self.config.email_admin
     468        username = self.request.principal.id
    471469        body = data['body']
    472470        email_to = self.context.email
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7230 r7234  
    375375    @grok.action('Send message now')
    376376    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
     377        fullname = self.request.principal.title
     378        try:
     379            email_from = self.request.principal.email
     380        except AttributeError:
     381            email_from = self.config.email_admin
     382        username = self.request.principal.id
    384383        body = data['body']
    385384        #subject = u'Mail from SIRP'
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py

    r7229 r7234  
    477477    """
    478478    principal_id = request.principal.id
    479     authenticators = getUtilitiesFor(IAuthenticatorPlugin)
    480     for authenticator in authenticators:
    481         account = authenticator[1].getAccount(principal_id)
    482         if account:
    483             break
     479    authenticator = getUtility(IAuthenticatorPlugin, name='users')
     480    account = authenticator.getAccount(principal_id)
    484481    return account
    485482
Note: See TracChangeset for help on using the changeset viewer.