Changeset 9138


Ignore:
Timestamp:
31 Aug 2012, 21:35:09 (12 years ago)
Author:
Henrik Bettermann
Message:

Add StudentTransferFormPage?.

Do not show any button on old studycourse (studycourse_1 or studycourse_2) pages.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
1 added
6 edited

Legend:

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

    r9124 r9138  
    5252    IUGStudentClearance,IPGStudentClearance,
    5353    IStudentPersonal, IStudentBase, IStudentStudyCourse,
     54    IStudentStudyCourseTransfer,
    5455    IStudentAccommodation, IStudentStudyLevel,
    5556    ICourseTicket, ICourseTicketAdd, IStudentPaymentsContainer,
     
    775776                mapping = {'a':', '.join(deleted)}))
    776777        self.redirect(self.url(self.context, u'@@manage')+'?tab2')
     778        return
     779
     780class StudentTransferFormPage(KofaAddFormPage):
     781    """Page to transfer the student.
     782    """
     783    grok.context(IStudent)
     784    grok.name('transfer')
     785    grok.require('waeup.manageStudent')
     786    label = _('Transfer student')
     787    form_fields = grok.AutoFields(IStudentStudyCourseTransfer).omit(
     788        'entry_mode', 'entry_session')
     789    pnav = 4
     790
     791    def update(self):
     792        super(StudentTransferFormPage, self).update()
     793        warning.need()
     794        return
     795
     796    @jsaction(_('Transfer'))
     797    def transferStudent(self, **data):
     798        error = self.context.transfer(**data)
     799        if error == -1:
     800            self.flash(_('Current level does not match certificate levels.'))
     801        elif error == -2:
     802            self.flash(_('Former study course record incomplete.'))
     803        elif error == -3:
     804            self.flash(_('Maximum number of transfers exceeded.'))
     805        else:
     806            self.flash(_('Successfully transferred.'))
    777807        return
    778808
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9131 r9138  
    372372        )
    373373
     374class IStudentStudyCourseTransfer(IStudentStudyCourse):
     375    """An student transfers.
     376
     377    """
     378
     379    certificate = schema.Choice(
     380        title = _(u'Certificate'),
     381        source = CertificateSource(),
     382        required = True,
     383        )
     384
     385    current_level = schema.Choice(
     386        title = _(u'Current Level'),
     387        source = StudyLevelSource(),
     388        required = True,
     389        readonly = False,
     390        )
     391
     392
     393IStudentStudyCourseTransfer['certificate'].order = IStudentStudyCourse[
     394    'certificate'].order
     395IStudentStudyCourseTransfer['current_level'].order = IStudentStudyCourse[
     396    'current_level'].order
     397
    374398class IStudentVerdictUpdate(IKofaObject):
    375399    """A interface for verdict imports.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r9137 r9138  
    160160            return -1
    161161        old = self['studycourse']
     162        if getattr(old, 'entry_session', None) is None or\
     163            getattr(old, 'certificate', None) is None:
     164            return -2
    162165        studycourse.entry_session = old.entry_session
    163166        # Students can be transferred only two times.
    164167        if 'studycourse_1' in self.keys():
    165168            if 'studycourse_2' in self.keys():
    166                 return -2
     169                return -3
    167170            self['studycourse_2'] = old
    168171        else:
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9124 r9138  
    19481948                        'K1000000 - account activated' in logcontent)
    19491949
     1950    def test_student_transfer(self):
     1951        # Add second certificate
     1952        self.certificate2 = createObject('waeup.Certificate')
     1953        self.certificate2.code = u'CERT2'
     1954        self.certificate2.study_mode = 'ug_ft'
     1955        self.certificate2.start_level = 999
     1956        self.certificate2.end_level = 999
     1957        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
     1958            self.certificate2)
     1959
     1960        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1961        self.browser.open(self.student_path)
     1962        self.browser.getLink("Transfer").click()
     1963        self.browser.getControl(name="form.certificate").value = ['CERT2']
     1964        self.browser.getControl(name="form.current_session").value = ['2011']
     1965        self.browser.getControl(name="form.current_level").value = ['200']
     1966        self.browser.getControl("Transfer").click()
     1967        self.assertTrue(
     1968            'Current level does not match certificate levels'
     1969            in self.browser.contents)
     1970        self.browser.getControl(name="form.current_level").value = ['999']
     1971        self.browser.getControl("Transfer").click()
     1972        self.assertTrue('Successfully transferred' in self.browser.contents)
     1973
    19501974class StudentRequestPWTests(StudentsFullSetup):
    19511975    # Tests for student registration
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py

    r9137 r9138  
    308308        error = self.student.transfer(self.certificate2,
    309309            current_session=2013)
    310         self.assertTrue(error == -2)
     310        self.assertTrue(error == -3)
    311311        self.assertEqual([i for i in self.student.keys()],
    312312            [u'accommodation', u'payments', u'studycourse',
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r9124 r9138  
    1 ## $Id$
     13## $Id$
    22##
    33## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
     
    166166    target = 'manage_base'
    167167
     168class StudentTransfernButton(ManageActionButton):
     169    grok.order(5)
     170    grok.context(IStudent)
     171    grok.view(StudentBaseDisplayFormPage)
     172    grok.require('waeup.manageStudent')
     173    text = _('Transfer student')
     174    target = 'transfer'
     175    icon = 'actionicon_redo.png'
     176
    168177class StudentDeactivateActionButton(ManageActionButton):
    169     grok.order(5)
     178    grok.order(6)
    170179    grok.context(IStudent)
    171180    grok.view(StudentBaseDisplayFormPage)
     
    182191
    183192class StudentActivateActionButton(ManageActionButton):
    184     grok.order(5)
     193    grok.order(6)
    185194    grok.context(IStudent)
    186195    grok.view(StudentBaseDisplayFormPage)
     
    285294    target = 'manage'
    286295
     296    @property
     297    def target_url(self):
     298        if self.context.is_current:
     299            return self.view.url(self.view.context, self.target)
     300        return False
     301
    287302class StudyLevelManageActionButton(ManageActionButton):
    288303    grok.order(1)
     
    292307    text = _('Manage')
    293308    target = 'manage'
     309
     310    @property
     311    def target_url(self):
     312        is_current = self.context.__parent__.is_current
     313        if not is_current:
     314            return ''
     315        return self.view.url(self.view.context, self.target)
    294316
    295317class StudentValidateCoursesActionButton(ManageActionButton):
     
    304326    @property
    305327    def target_url(self):
     328        is_current = self.context.__parent__.is_current
    306329        if self.context.student.state != REGISTERED or \
    307             str(self.context.__parent__.current_level) != self.context.__name__:
     330            str(self.context.__parent__.current_level) != self.context.__name__ or\
     331            not is_current:
    308332            return ''
    309333        return self.view.url(self.view.context, self.target)
     
    320344    @property
    321345    def target_url(self):
     346        is_current = self.context.__parent__.is_current
    322347        if self.context.student.state not in (VALIDATED, REGISTERED) or \
    323             str(self.context.__parent__.current_level) != self.context.__name__:
     348            str(self.context.__parent__.current_level) != self.context.__name__ or\
     349            not is_current:
    324350            return ''
    325351        return self.view.url(self.view.context, self.target)
     
    334360    target = 'course_registration.pdf'
    335361
     362    @property
     363    def target_url(self):
     364        is_current = self.context.__parent__.is_current
     365        if not is_current:
     366            return ''
     367        return self.view.url(self.view.context, self.target)
     368
    336369class CourseTicketManageActionButton(ManageActionButton):
    337370    grok.order(1)
     
    479512    @property
    480513    def target_url(self):
    481         if self.context.next_session_allowed:
     514        if self.context.next_session_allowed and self.context.is_current:
    482515            return self.view.url(self.view.context, self.target)
    483516        return False
     
    497530        condition2 = str(student['studycourse'].current_level) in \
    498531            self.view.context.keys()
    499         if condition1 or condition2:
     532        condition3 = not self.context.is_current
     533        if condition1 or condition2 or condition3:
    500534            return ''
    501535        return self.view.url(self.view.context, self.target)
     
    515549        condition2 = student[
    516550            'studycourse'].current_level != self.view.context.level
    517         if condition1 or condition2:
     551        is_current = self.context.__parent__.is_current
     552        if condition1 or condition2 or not is_current:
    518553            return ''
    519554        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.