Changeset 9161 for main/waeup.kofa/trunk


Ignore:
Timestamp:
6 Sep 2012, 07:43:51 (12 years ago)
Author:
Henrik Bettermann
Message:

In contrast to the comment of the last revision: We need to store validation_date and validated_by also in Kofa. They have to be set by the workflow transition events. They must not be editable (but importable and exportable).

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

Legend:

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

    r9160 r9161  
    470470    location_fields = []
    471471
    472     # Validation fields can be removed after data migration from SRP.
    473     additional_fields = ['level',
    474         'validated_by', 'validation_date']
     472    additional_fields = ['level']
    475473    additional_headers = ['level']
    476474
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r9148 r9161  
    850850    grok.require('waeup.viewStudent')
    851851    form_fields = grok.AutoFields(IStudentStudyLevel)
     852    form_fields[
     853        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    852854    grok.template('studylevelpage')
    853855    pnav = 4
     
    945947    grok.require('waeup.manageStudent')
    946948    grok.template('studylevelmanagepage')
    947     form_fields = grok.AutoFields(IStudentStudyLevel)
     949    form_fields = grok.AutoFields(IStudentStudyLevel).omit(
     950        'validation_date', 'validated_by')
    948951    pnav = 4
    949952    taboneactions = [_('Save'),_('Cancel')]
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9150 r9161  
    426426    """
    427427    level = Attribute('The level code')
    428     validation_date = Attribute('The date of validation')
    429     validated_by = Attribute('User Id of course adviser')
    430428
    431429    level_session = schema.Choice(
     
    440438        default = '0',
    441439        required = False,
     440        )
     441
     442    validated_by = schema.TextLine(
     443        title = _(u'Validated by'),
     444        default = None,
     445        required = False,
     446        )
     447
     448    validation_date = schema.Datetime(
     449        title = _(u'Validation Date'),
     450        required = False,
     451        readonly = False,
    442452        )
    443453
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py

    r8920 r9161  
    3737        super(StudentStudyLevel, self).__init__()
    3838        self.level = None
    39         self.validation_date = None
    40         self.validated_by = None
    4139        return
    4240
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9148 r9161  
    967967        self.app['users'].addUser('mrsadvise', 'mrsadvisesecret')
    968968        self.app['users']['mrsadvise'].email = 'mradvise@foo.ng'
    969         self.app['users']['mrsadvise'].title = 'Helen Procter'
     969        self.app['users']['mrsadvise'].title = u'Helen Procter'
    970970        # Assign local CourseAdviser100 role for a certificate
    971971        cert = self.app['faculties']['fac1']['dep1'].certificates['CERT1']
     
    10181018        # the 100L CA does see the 'Validate' button
    10191019        self.browser.open(L110_student_path)
    1020         self.assertFalse('Validate' in self.browser.contents)
     1020        self.assertFalse('Validate courses' in self.browser.contents)
    10211021        IWorkflowInfo(self.student).fireTransition('register_courses')
    10221022        self.browser.open(L110_student_path)
    1023         self.assertFalse('Validate' in self.browser.contents)
     1023        self.assertFalse('Validate courses' in self.browser.contents)
    10241024        self.student['studycourse'].current_level = 110
    10251025        self.browser.open(L110_student_path)
    1026         self.assertTrue('Validate' in self.browser.contents)
     1026        self.assertTrue('Validate courses' in self.browser.contents)
    10271027        # ... but a 100L CA does not see the button on other levels
    10281028        studylevel2 = StudentStudyLevel()
     
    10321032        L200_student_path = self.studycourse_path + '/200'
    10331033        self.browser.open(L200_student_path)
    1034         self.assertFalse('Validate' in self.browser.contents)
     1034        self.assertFalse('Validate courses' in self.browser.contents)
    10351035        self.browser.open(L110_student_path)
    10361036        self.browser.getLink("Validate courses").click()
    10371037        self.assertTrue('Course list has been validated' in self.browser.contents)
    10381038        self.assertTrue('courses validated' in self.browser.contents)
     1039        self.assertEqual(self.student['studycourse']['110'].validated_by,
     1040            'Helen Procter')
     1041        self.assertMatches(
     1042            '<YYYY-MM-DD hh:mm:ss>',
     1043            self.student['studycourse']['110'].validation_date.strftime(
     1044                "%Y-%m-%d %H:%M:%S"))
    10391045        self.browser.getLink("Reject courses").click()
    10401046        self.assertTrue('Course list request has been annulled.'
     
    10441050            '/contactstudent?subject=%s' % urlmessage)
    10451051        self.assertTrue('school fee paid' in self.browser.contents)
     1052        self.assertTrue(self.student['studycourse']['110'].validated_by is None)
     1053        self.assertTrue(self.student['studycourse']['110'].validation_date is None)
    10461054        IWorkflowInfo(self.student).fireTransition('register_courses')
    10471055        self.browser.open(L110_student_path)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r9148 r9161  
    209209        self.assertEqual(
    210210            result,
    211             'level,level_session,level_verdict,student_id\r\n'
    212             ',,0,\r\n'
     211            'level,level_session,level_verdict,validated_by,validation_date,'
     212            'student_id\r\n'
     213            ',,0,,,\r\n'
    213214            )
    214215        return
     
    225226        self.assertEqual(
    226227            result,
    227             'level,level_session,level_verdict,student_id\r\n'
    228             '100,2012,A,A111111\r\n'
     228            'level,level_session,level_verdict,validated_by,validation_date,'
     229            'student_id\r\n'
     230            '100,2012,A,,,A111111\r\n'
    229231            )
    230232        return
     
    239241        self.assertEqual(
    240242            result,
    241             'level,level_session,level_verdict,student_id\r\n'
    242             '100,2012,A,A111111\r\n'
     243            'level,level_session,level_verdict,validated_by,validation_date,'
     244            'student_id\r\n'
     245            '100,2012,A,,,A111111\r\n'
    243246            )
    244247        return
     
    252255        self.assertEqual(
    253256            result,
    254             'level,level_session,level_verdict,student_id\r\n'
    255             '100,2012,A,A111111\r\n'
     257            'level,level_session,level_verdict,validated_by,validation_date,'
     258            'student_id\r\n'
     259            '100,2012,A,,,A111111\r\n'
    256260            )
    257261        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/workflow.py

    r9028 r9161  
    22"""
    33import grok
     4from datetime import datetime
    45from zope.component import getUtility
    56from hurry.workflow.workflow import Transition, WorkflowState, NullCondition
     
    1213from waeup.kofa.workflow import KofaWorkflow, KofaWorkflowInfo
    1314from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
     15from waeup.kofa.utils.helpers import get_current_principal
    1416
    1517
     
    234236        new_session = obj['studycourse'].current_session + 1
    235237        obj['studycourse'].current_session = new_session
     238    elif event.transition.transition_id == 'validate_courses':
     239        current_level = obj['studycourse'].current_level
     240        level_object = obj['studycourse'].get(str(current_level), None)
     241        if level_object is not None:
     242            user = get_current_principal()
     243            if user is None:
     244                usertitle = 'system'
     245            else:
     246                usertitle = getattr(user, 'public_name', None)
     247                if not usertitle:
     248                    usertitle = user.title
     249            level_object.validated_by = usertitle
     250            level_object.validation_date = datetime.utcnow()
     251    elif event.transition.transition_id == 'reset8':
     252        current_level = obj['studycourse'].current_level
     253        level_object = obj['studycourse'].get(str(current_level), None)
     254        if level_object is not None:
     255            level_object.validated_by = None
     256            level_object.validation_date = None
    236257    # In some tests we don't have a students container
    237258    try:
Note: See TracChangeset for help on using the changeset viewer.