Ignore:
Timestamp:
26 Nov 2011, 06:49:16 (13 years ago)
Author:
Henrik Bettermann
Message:

academics: Show students in departments.

students: Search for students in department.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r7202 r7205  
    5454    IPasswordValidator)
    5555from waeup.sirp.permissions import get_users_with_local_roles, get_all_roles
     56from waeup.sirp.students.catalog import search as searchstudents
    5657from waeup.sirp.university.catalog import search
    5758from waeup.sirp.university.vocabularies import course_levels
     
    13691370            yield(dict(url=url, name=key, container=val))
    13701371
     1372class ShowStudentsPage(WAeUPPage):
     1373    """Page that lists all students in the department.
     1374    """
     1375    grok.context(IDepartment)
     1376    grok.require('waeup.showStudents')
     1377    grok.name('showstudents')
     1378    pnav = 1
     1379    label = 'Students'
     1380
     1381    @property
     1382    def title(self):
     1383        return self.context.longtitle()
     1384
     1385    @property
     1386    def getStudents(self):
     1387        hitlist = searchstudents(query=self.context.code,
     1388            searchtype='depcode', view=self)
     1389        return hitlist
     1390
     1391    def update(self, *args, **kw):
     1392        datatable.need()
     1393        return
     1394
    13711395class DepartmentManageFormPage(WAeUPEditFormPage):
    13721396    """Manage the basic properties of a `Department` instance.
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r7202 r7205  
    416416    text = 'Manage department'
    417417
     418class ShowDepartmentStudentsActionButton(ManageActionButton):
     419    """ 'Show students' button for departments.
     420    """
     421    grok.context(IDepartment)
     422    grok.view(DepartmentPage)
     423    grok.require('waeup.showStudents')
     424    icon = 'actionicon_student.png'
     425    text = 'Show students'
     426    target = 'showstudents'
     427
    418428class ManageCourseActionButton(ManageActionButton):
    419429    """ 'Edit settings' button for courses.
  • main/waeup.sirp/trunk/src/waeup/sirp/permissions.py

    r7193 r7205  
    5454    grok.name('waeup.manageUsers')
    5555
     56class ShowStudents(grok.Permission):
     57    grok.name('waeup.showStudents')
     58
    5659class EditUser(grok.Permission):
    5760    grok.name('waeup.editUser')
     
    7073    grok.name('waeup.local.DepartmentManager')
    7174    grok.title(u'Department Manager')
    72     grok.permissions('waeup.manageUniversity')
     75    grok.permissions('waeup.manageUniversity','waeup.showStudents')
    7376
    7477class ClearanceOfficer(grok.Role):
     
    7881    grok.name('waeup.local.ClearanceOfficer')
    7982    grok.title(u'Clearance Officer')
     83    grok.permissions('waeup.showStudents')
    8084
    8185class CourseAdviser(grok.Role):
     
    8589    grok.name('waeup.local.CourseAdviser')
    8690    grok.title(u'Course Adviser')
     91    grok.permissions('waeup.showStudents')
    8792
    8893class Owner(grok.Role):
     
    112117                     'waeup.viewStudent', 'waeup.manageStudent', 'clearStudent',
    113118                     'waeup.uploadStudentFile', 'waeup.viewStudents',
    114                      'waeup.viewHostels', 'waeup.manageHostels')
     119                     'waeup.viewHostels', 'waeup.manageHostels',
     120                     'waeup.showStudents')
    115121
    116122def get_all_roles():
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7191 r7205  
    7070    if changed_fields:
    7171        changed_fields = reduce(lambda x,y: x+y, changed_fields.values())
     72    # Inform catalog if certificate has changed
     73    # (applyData does this only for the context)
     74    if 'certificate' in changed_fields:
     75        notify(grok.ObjectModifiedEvent(view.context.getStudent()))
    7276    fields_string = ' + '.join(changed_fields)
    73     #view.context._p_changed = True
    7477    view.flash('Form has been saved.')
    7578    if fields_string:
     
    599602    @property
    600603    def department(self):
    601         if self.context.certificate:
     604        if self.context.certificate is not None:
    602605            return self.context.certificate.__parent__.__parent__
    603606        return
     
    605608    @property
    606609    def faculty(self):
    607         if self.context.certificate:
     610        if self.context.certificate is not None:
    608611            return self.context.certificate.__parent__.__parent__.__parent__
    609612        return
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/containermanagepage.pt

    r7068 r7205  
    1010    <option value="student_id">with id</option>
    1111    <option value="fullname">with name</option>
     12    <option value="reg_number">with registration number</option>
     13    <option value="matric_number">with matriculation number</option>
    1214    <option value="current_session">in session</option>
     15    <option value="depcode">in department</option>
    1316  </select>
    1417
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/containerpage.pt

    r7068 r7205  
    1313    <option value="matric_number">with matriculation number</option>
    1414    <option value="current_session">in session</option>
     15    <option value="depcode">in department</option>
    1516  </select>
    1617
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7203 r7205  
    149149        self.certificate.end_level = 500
    150150        self.app['faculties']['fac1'] = Faculty()
    151         self.app['faculties']['fac1']['dep1'] = Department()
     151        self.app['faculties']['fac1']['dep1'] = Department(code='dep1')
    152152        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
    153153            self.certificate)
     
    196196        self.student['studycourse'].current_verdict = 'A'
    197197        self.student['studycourse'].current_level = 100
     198        # Update the catalog
     199        notify(grok.ObjectModifiedEvent(self.student))
    198200
    199201        # Put the prepopulated site into test ZODB and prepare test
     
    263265        self.browser.getControl(name="searchtype").value = ['student_id']
    264266        self.browser.getControl(name="searchterm").value = self.student_id
     267        self.browser.getControl("Search").click()
     268        self.assertTrue('Anna Tester' in self.browser.contents)
     269
     270        # We can find a student in a certain department
     271        self.browser.open(self.container_path)
     272        self.browser.getControl(name="searchtype").value = ['depcode']
     273        self.browser.getControl(name="searchterm").value = 'dep1'
    265274        self.browser.getControl("Search").click()
    266275        self.assertTrue('Anna Tester' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.