Changeset 7497


Ignore:
Timestamp:
21 Jan 2012, 11:55:44 (13 years ago)
Author:
Henrik Bettermann
Message:

Import student password as well. This is crucial for upcoming portal migration.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/batching.py

    r7433 r7497  
    3232from zope.catalog.interfaces import ICatalog
    3333from waeup.sirp.interfaces import (
    34     IBatchProcessor, FatalCSVError, IObjectConverter)
     34    IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount)
    3535from waeup.sirp.students.interfaces import (
    3636    IStudent, IStudentStudyCourseImport,
     
    5858    def available_fields(self):
    5959        return sorted(list(set(
    60             ['student_id','reg_number','matric_number'] + getFields(
     60            ['student_id','reg_number','matric_number','password'] + getFields(
    6161                self.iface).keys())))
    6262
     
    137137        pass
    138138
     139    def updateEntry(self, obj, row, site):
     140        """Update obj to the values given in row.
     141        """
     142        for key, value in row.items():
     143            # Set student password and all fields declared in interface.
     144            if key == 'password':
     145                IUserAccount(obj).setPassword(value)
     146            elif hasattr(obj, key):
     147                setattr(obj, key, value)
     148        return
     149
    139150    def getMapping(self, path, headerfields, mode):
    140151        """Get a mapping from CSV file headerfields to actually used fieldnames.
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/sample_student_data_migration.csv

    r7357 r7497  
    1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone
    2 A123456,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234
    3 B123456,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234
    4 C123456,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234
     1student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password
     2A123456,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234,mypw1
     3B123456,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234,mypw1
     4C123456,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234,mypw1
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7463 r7497  
    682682        # Prepare a csv file for students
    683683        open('students.csv', 'wb').write(
    684 """firstname,lastname,reg_number,date_of_birth,matric_number,email,phone
    685 Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234
    686 Claus,Finau,2,1990-01-03,100001,aa@aa.ng,1234
    687 Brit,Berson,3,1990-01-04,100001,aa@aa.ng,1234
     684"""firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password
     685Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234,mypwd1
     686Claus,Finau,2,1990-01-03,100001,aa@aa.ng,1234,mypwd1
     687Brit,Berson,3,1990-01-04,100001,aa@aa.ng,1234,mypwd1
    688688""")
    689689        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    739739        # The students are properly indexed and we can
    740740        # thus find a student in  the department
    741         self.browser.open(self.container_path)
     741        self.browser.open(self.manage_container_path)
    742742        self.browser.getControl(name="searchtype").value = ['depcode']
    743743        self.browser.getControl(name="searchterm").value = 'dep1'
    744744        self.browser.getControl("Search").click()
    745745        self.assertTrue('Aaren Pieri' in self.browser.contents)
     746        # We can search for a new student by name ...
     747        self.browser.getControl(name="searchtype").value = ['fullname']
     748        self.browser.getControl(name="searchterm").value = 'Claus'
     749        self.browser.getControl("Search").click()
     750        self.assertTrue('Claus Finau' in self.browser.contents)
     751        # ... and check if the imported password has been properly set
     752        ctrl = self.browser.getControl(name='entries')
     753        value = ctrl.options[0]
     754        claus = self.app['students'][value]
     755        self.assertTrue(IUserAccount(claus).checkPassword('mypwd1'))
    746756        return
    747757
Note: See TracChangeset for help on using the changeset viewer.