Changeset 9924 for main/waeup.kofa/trunk


Ignore:
Timestamp:
30 Jan 2013, 08:58:37 (12 years ago)
Author:
Henrik Bettermann
Message:

Add new permission waeup.editStudyLevel to allow course advisers to edit study levels after rejection.

Improve logging. Creation and deletion of course tickets is now properly logged.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r9906 r9924  
    158158    view.flash(_('Successfully added ${a}.',
    159159        mapping = {'a':ticket.code}))
     160    view.context.writeLogMessage(
     161        view,'added: %s|%s|%s' % (
     162        ticket.code, ticket.getLevel(), ticket.getLevelSession()))
    160163    return True
    161164
     
    12571260                mapping = {'a':', '.join(deleted)}))
    12581261            self.context.writeLogMessage(
    1259                 self,'removed: %s' % ', '.join(deleted))
     1262                self,'removed: %s at %s' %
     1263                (', '.join(deleted), self.context.level))
    12601264        self.redirect(self.url(self.context, u'@@manage')+'?tab2')
    12611265        return
     
    23172321    grok.context(IStudentStudyLevel)
    23182322    grok.name('edit')
    2319     grok.require('waeup.handleStudent')
     2323    grok.require('waeup.editStudyLevel')
    23202324    grok.template('studyleveleditpage')
    23212325    form_fields = grok.AutoFields(IStudentStudyLevel).omit(
     
    23812385                mapping = {'a':', '.join(deleted)}))
    23822386            self.context.writeLogMessage(
    2383                 self,'removed: %s' % ', '.join(deleted))
     2387                self,'removed: %s at %s' %
     2388                (', '.join(deleted), self.context.level))
    23842389        self.redirect(self.url(self.context, u'@@edit'))
    23852390        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/permissions.py

    r9335 r9924  
    5656    grok.name('waeup.validateStudent')
    5757
     58class EditStudyLevel(grok.Permission):
     59    grok.name('waeup.editStudyLevel')
     60
    5861class TriggerTransition(grok.Permission):
    5962    grok.name('waeup.triggerTransition')
     
    6871    grok.permissions('waeup.handleStudent', 'waeup.uploadStudentFile',
    6972                     'waeup.viewStudent', 'waeup.payStudent',
    70                      'waeup.handleAccommodation')
     73                     'waeup.handleAccommodation', 'waeup.editStudyLevel')
    7174
    7275# Site Roles
     
    98101    grok.name('waeup.StudentsCourseAdviser')
    99102    grok.title(u'Course Adviser (all students)')
    100     grok.permissions('waeup.validateStudent','waeup.viewStudent')
     103    grok.permissions('waeup.validateStudent','waeup.viewStudent',
     104                     'waeup.editStudyLevel')
    101105
    102106class StudentImpersonator(grok.Role):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9922 r9924  
    750750        logcontent = open(logfile).read()
    751751        self.assertTrue('zope.mgr - students.browser.StudyLevelManageFormPage '
    752         '- K1000000 - removed: COURSE1' in logcontent)
     752        '- K1000000 - removed: COURSE1 at 100' in logcontent)
    753753        self.browser.getLink("here").click()
    754754        self.browser.getControl(name="form.course").value = ['COURSE1']
     
    14221422            cert,studylevel)
    14231423        L110_student_path = self.studycourse_path + '/110'
    1424         # Only in state courses registered and only if the current level
    1425         # corresponds with the name of the study level object
    1426         # the 100L CA does see the 'Validate' button
     1424        # The CA can neither see the Validate nor the Edit button
    14271425        self.browser.open(L110_student_path)
    14281426        self.assertFalse('Validate courses' in self.browser.contents)
     1427        self.assertFalse('Edit' in self.browser.contents)
    14291428        IWorkflowInfo(self.student).fireTransition('register_courses')
    14301429        self.browser.open(L110_student_path)
    14311430        self.assertFalse('Validate courses' in self.browser.contents)
     1431        self.assertFalse('Edit' in self.browser.contents)
     1432        # Only in state courses registered and only if the current level
     1433        # corresponds with the name of the study level object
     1434        # the 100L CA does see the 'Validate' button but not
     1435        # the edit button
    14321436        self.student['studycourse'].current_level = 110
    14331437        self.browser.open(L110_student_path)
     1438        self.assertFalse('Edit' in self.browser.contents)
    14341439        self.assertTrue('Validate courses' in self.browser.contents)
    1435         # ... but a 100L CA does not see the button on other levels
     1440        # But a 100L CA does not see the button at other levels
    14361441        studylevel2 = StudentStudyLevel()
    14371442        studylevel2.level = 200
     
    14401445        L200_student_path = self.studycourse_path + '/200'
    14411446        self.browser.open(L200_student_path)
     1447        self.assertFalse('Edit' in self.browser.contents)
    14421448        self.assertFalse('Validate courses' in self.browser.contents)
    14431449        self.browser.open(L110_student_path)
     
    14711477        self.browser.getControl("Send message now").click()
    14721478        self.assertTrue('Your message has been sent' in self.browser.contents)
     1479        # The CA does now see the Edit button and can edit
     1480        # current study level
     1481        self.browser.open(L110_student_path)
     1482        self.browser.getLink("Edit").click()
     1483        self.assertTrue('Edit course list of 100 (Year 1) on 1st probation'
     1484            in self.browser.contents)
    14731485        # The CA can't validate courses if not in state
    14741486        # courses registered
     
    20692081        self.browser.getControl("Register course list").click()
    20702082        self.assertTrue('Maximum credits of 50 exceeded' in self.browser.contents)
    2071         # Student can now remove the ticket ...
     2083        # Student can now remove the ticket
    20722084        ctrl = self.browser.getControl(name='val_id')
    20732085        ctrl.getControl(value='COURSE1').selected = True
    20742086        self.browser.getControl("Remove selected", index=0).click()
    20752087        self.assertTrue('Successfully removed' in self.browser.contents)
    2076         # ... and add the same ticket using the edit page directly.
     2088        # Removing course tickets is properly logged
     2089        logfile = os.path.join(
     2090            self.app['datacenter'].storage, 'logs', 'students.log')
     2091        logcontent = open(logfile).read()
     2092        self.assertTrue('K1000000 - students.browser.StudyLevelEditFormPage '
     2093        '- K1000000 - removed: COURSE1 at 200' in logcontent)
     2094        # They can add the same ticket using the edit page directly.
    20772095        # We can do the same by adding the course on the manage page directly
    20782096        self.browser.getControl(name="course").value = 'COURSE1'
    20792097        self.browser.getControl("Add course ticket").click()
     2098        # Adding course tickets is logged
     2099        logfile = os.path.join(
     2100            self.app['datacenter'].storage, 'logs', 'students.log')
     2101        logcontent = open(logfile).read()
     2102        self.assertTrue('K1000000 - students.browser.StudyLevelEditFormPage - '
     2103            'K1000000 - added: COURSE1|200|2004' in logcontent)
    20802104        # Course list can be registered
    20812105        self.browser.getControl("Register course list").click()
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r9865 r9924  
    583583    grok.context(IStudentStudyLevel)
    584584    grok.view(StudyLevelDisplayFormPage)
    585     grok.require('waeup.handleStudent')
     585    grok.require('waeup.editStudyLevel')
    586586    text = _('Edit course list')
    587587    target = 'edit'
Note: See TracChangeset for help on using the changeset viewer.