Ignore:
Timestamp:
25 Oct 2011, 14:11:49 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement StartCourseRegistrationPage? (tests will follow).

File:
1 edited

Legend:

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

    r6943 r6944  
    4343    )
    4444from waeup.sirp.students.catalog import search
    45 from waeup.sirp.students.workflow import CLEARANCE
     45from waeup.sirp.students.workflow import CLEARANCE, RETURNING, CLEARED
    4646from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket
    4747from waeup.sirp.students.vocabularies import StudyLevelSource
     
    12221222        return
    12231223
     1224class CourseRegistrationStartActionButton(ManageActionButton):
     1225    grok.order(1)
     1226    grok.context(IStudentStudyCourse)
     1227    grok.view(StudyCourseDisplayFormPage)
     1228    grok.require('waeup.handleStudent')
     1229    icon = 'actionicon_start.png'
     1230    text = 'Start course registration'
     1231    target = 'start_course_registration'
     1232
     1233    @property
     1234    def target_url(self):
     1235        if not self.context.getStudent().state in (CLEARED,RETURNING):
     1236            return ''
     1237        return self.view.url(self.view.context, self.target)
     1238
     1239class StartCourseRegistrationPage(WAeUPPage):
     1240    grok.context(IStudentStudyCourse)
     1241    grok.name('start_course_registration')
     1242    grok.require('waeup.handleStudent')
     1243    grok.template('enterpin')
     1244    title = 'Start course registration'
     1245    label = 'Start course registration'
     1246    ac_prefix = 'SFE'
     1247    notice = ''
     1248    pnav = 4
     1249    buttonname = 'Start course registration now'
     1250
     1251    def update(self, SUBMIT=None):
     1252        if not self.context.getStudent().state in (CLEARED,RETURNING):
     1253            self.flash("Wrong state.")
     1254            self.redirect(self.url(self.context))
     1255            return
     1256        self.ac_series = self.request.form.get('ac_series', None)
     1257        self.ac_number = self.request.form.get('ac_number', None)
     1258
     1259        if SUBMIT is None:
     1260            return
     1261        pin = '%s-%s-%s' % (self.ac_prefix, self.ac_series, self.ac_number)
     1262        code = get_access_code(pin)
     1263        if not code:
     1264            self.flash('Activation code is invalid.')
     1265            return
     1266        # Mark pin as used (this also fires a pin related transition)
     1267        # and fire transition start_clearance
     1268        if code.state == USED:
     1269            self.flash('Activation code has already been used.')
     1270            return
     1271        else:
     1272            comment = u"AC invalidated for %s" % self.context.getStudent().student_id
     1273            # Here we know that the ac is in state initialized so we do not
     1274            # expect an exception, but the owner might be different
     1275            if not invalidate_accesscode(
     1276                pin,comment,self.context.getStudent().student_id):
     1277                self.flash('You are not the owner of this access code.')
     1278                return
     1279        if self.context.getStudent().state == CLEARED:
     1280            IWorkflowInfo(self.context.getStudent()).fireTransition(
     1281                'pay_first_school_fee')
     1282        elif self.context.getStudent().state == RETURNING:
     1283            IWorkflowInfo(self.context.getStudent()).fireTransition(
     1284                'pay_school_fee')
     1285        self.flash('Course registration has been started.')
     1286        self.redirect(self.url(self.context))
     1287        return
     1288
     1289
    12241290class AddStudyLevelActionButton(AddActionButton):
    12251291    grok.order(1)
Note: See TracChangeset for help on using the changeset viewer.