Changeset 9437


Ignore:
Timestamp:
27 Oct 2012, 05:35:04 (12 years ago)
Author:
Henrik Bettermann
Message:

Make level_session required and let officers select the right level_session when adding study levels.

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

    r9428 r9437  
    4343from waeup.kofa.interfaces import (
    4444    IKofaObject, IUserAccount, IExtFileStore, IPasswordValidator, IContactForm,
    45     IKofaUtils, IUniversity, IObjectHistory)
     45    IKofaUtils, IUniversity, IObjectHistory, academic_sessions)
    4646from waeup.kofa.interfaces import MessageFactory as _
    4747from waeup.kofa.widgets.datewidget import (
     
    878878            yield(dict(code=code, title=title))
    879879
     880    @property
     881    def session_dict(self):
     882        yield(dict(code='', title='--'))
     883        for item in academic_sessions():
     884            code = item[1]
     885            title = item[0]
     886            yield(dict(code=code, title=title))
     887
    880888    @action(_('Add study level'))
    881889    def addStudyLevel(self, **data):
    882890        level_code = self.request.form.get('addlevel', None)
     891        level_session = self.request.form.get('level_session', None)
     892        if not level_session:
     893            self.flash(_('You must select a session for the level.'))
     894            self.redirect(self.url(self.context, u'@@manage')+'?tab2')
     895            return
    883896        studylevel = createObject(u'waeup.StudentStudyLevel')
    884897        studylevel.level = int(level_code)
    885         studylevel.level_session = self.context.current_session
     898        studylevel.level_session = int(level_session)
    886899        try:
    887900            self.context.addStudentStudyLevel(
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/studycoursemanagepage.pt

    r7811 r9437  
    7070          </span>
    7171        </span>
    72         <select id="addlevel" name="addlevel">
     72        <select id="addlevel" name="addlevel" class='span5'>
    7373          <option tal:attributes="value level/code" tal:repeat="level view/level_dict">
    7474            <span tal:replace="level/title">LEVELTITLE
     75          </span>
     76          </option>
     77        </select>
     78        &nbsp;&nbsp;<span i18n:translate="">in session</span>&nbsp;&nbsp;
     79        <select id="level_session" name="level_session" class='span3'>
     80          <option tal:attributes="value session/code" tal:repeat="session view/session_dict">
     81            <span tal:replace="session/title">LEVELSESSION
    7582          </span>
    7683          </option>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9424 r9437  
    461461        title = _(u'Session'),
    462462        source = academic_sessions_vocab,
    463         required = False,
     463        required = True,
    464464        )
    465465
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9424 r9437  
    674674        self.browser.getControl(name="addlevel").value = ['100']
    675675        self.browser.getControl("Add study level").click()
     676        self.assertMatches(
     677            '...You must select a session...', self.browser.contents)
     678        self.browser.getControl(name="addlevel").value = ['100']
     679        self.browser.getControl(name="level_session").value = ['2004']
     680        self.browser.getControl("Add study level").click()
    676681        self.assertMatches('...<span>100</span>...', self.browser.contents)
    677682        self.assertEqual(self.student['studycourse']['100'].level, 100)
    678683        self.assertEqual(self.student['studycourse']['100'].level_session, 2004)
     684        self.browser.getControl(name="addlevel").value = ['100']
     685        self.browser.getControl(name="level_session").value = ['2004']
    679686        self.browser.getControl("Add study level").click()
    680687        self.assertMatches('...This level exists...', self.browser.contents)
     
    683690            '...No study level selected...', self.browser.contents)
    684691        self.browser.getControl(name="val_id").value = ['100']
     692        self.browser.getControl(name="level_session").value = ['2004']
    685693        self.browser.getControl("Remove selected").click()
    686694        self.assertMatches('...Successfully removed...', self.browser.contents)
     
    693701        # Add level again
    694702        self.browser.getControl(name="addlevel").value = ['100']
     703        self.browser.getControl(name="level_session").value = ['2004']
    695704        self.browser.getControl("Add study level").click()
    696705
     
    732741        # Add next level
    733742        self.browser.getControl(name="addlevel").value = ['200']
     743        self.browser.getControl(name="level_session").value = ['2005']
    734744        self.browser.getControl("Add study level").click()
    735745        self.browser.getLink("200").click()
Note: See TracChangeset for help on using the changeset viewer.