Ignore:
Timestamp:
30 Jun 2012, 07:39:07 (12 years ago)
Author:
Henrik Bettermann
Message:

Store user in mandate. This makes everything much easier.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/mandates
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py

    r8857 r8858  
    5555
    5656    def _setPassword(self):
    57         user_id = self.params.get('user_id', None)
     57        user = self.params.get('user', None)
    5858        pwd = self.params.get('password', None)
    59         user_type = self.params.get('user_type', None)
    60         user = None
    61         if user_type == 'student':
    62             user = grok.getSite()['students'].get(user_id, None)
    63         elif user_type == 'officer':
    64             user = grok.getSite()['users'].get(user_id, None)
    6559        if user and pwd:
    66             IUserAccount(user).setPassword(pwd)
    67             return True
     60            try:
     61                IUserAccount(user).setPassword(pwd)
     62                return True
     63            except:
     64                return False
    6865        return False
    6966
  • main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py

    r8857 r8858  
    9999        # Add and execute a perfect mandate
    100100        mandate = PasswordMandate()
    101         mandate.params['user_id'] = student.student_id
     101        mandate.params['user'] = student
    102102        mandate.params['password'] = 'mypwd1'
    103         mandate.params['user_type'] = 'student'
    104103        self.app['mandates'].addMandate(mandate)
    105104        msg = mandate.execute()
     
    115114        officer = self.app['users']['bob']
    116115        mandate = PasswordMandate()
    117         mandate.params['user_id'] = 'bob'
     116        mandate.params['user'] = officer
    118117        mandate.params['password'] = 'mypwd1'
    119         mandate.params['user_type'] = 'officer'
    120118        self.app['mandates'].addMandate(mandate)
    121119        msg = mandate.execute()
     
    142140        self.app['students'].addStudent(student)
    143141        mandate = PasswordMandate()
    144         mandate.params['user_id'] = student.student_id
    145         mandate.params['user_type'] = 'student'
     142        mandate.params['user'] = student
    146143        mandate.params['password'] = 'mypwd1'
    147144        self.app['mandates'].addMandate(mandate)
Note: See TracChangeset for help on using the changeset viewer.