Ignore:
Timestamp:
19 Jun 2019, 06:03:06 (5 years ago)
Author:
Henrik Bettermann
Message:

Use deadlines also for course unregistration.

File:
1 edited

Legend:

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

    r15457 r15461  
    406406        return form_fields
    407407
    408 #class CustomUnregisterCoursesView(UnregisterCoursesView):
    409 #    """Unregister course list by student
    410 #    """
    411 #    grok.context(ICustomStudentStudyLevel)
    412 
    413 #    def update(self):
    414 #        if not self.context.__parent__.is_current:
    415 #            emit_lock_message(self)
    416 #            return
    417 #        try:
    418 #            deadline = grok.getSite()['configuration'][
    419 #                str(self.context.level_session)].coursereg_deadline
    420 #        except (TypeError, KeyError):
    421 #            deadline = None
    422 #        # In AAUE fresh students are allowed to "unregister their course"
    423 #        # aside the deadline
    424 #        if deadline and not self.context.student.is_fresh \
    425 #            and deadline < datetime.now(pytz.utc):
    426 #            self.flash(_(
    427 #                "Course registration has ended. "
    428 #                "Unregistration is disabled."), type="warning")
    429 #        elif str(self.context.__parent__.current_level) != self.context.__name__:
    430 #            self.flash(_('This is not your current level.'), type="danger")
    431 #        elif self.context.student.state == REGISTERED:
    432 #            IWorkflowInfo(self.context.student).fireTransition('reset7')
    433 #            message = _('Course list has been unregistered.')
    434 #            self.flash(message)
    435 #        else:
    436 #            self.flash(_('You are in the wrong state.'), type="warning")
    437 #        self.redirect(self.url(self.context))
    438 #        return
     408class CustomUnregisterCoursesView(UnregisterCoursesView):
     409    """Unregister course list by student
     410    """
     411    grok.context(ICustomStudentStudyLevel)
     412
     413    def update(self):
     414        if not self.context.__parent__.is_current:
     415            emit_lock_message(self)
     416            return
     417        try:
     418            academic_session = grok.getSite()['configuration'][
     419                str(self.context.level_session)]
     420            if self.context.student.is_postgrad:
     421                deadline = academic_session.coursereg_deadline_pg
     422            elif self.context.student.current_mode.startswith('dp'):
     423                deadline = academic_session.coursereg_deadline_dp
     424            elif self.context.student.current_mode.endswith('_pt'):
     425                deadline = academic_session.coursereg_deadline_pt
     426            elif self.context.student.current_mode == 'found':
     427                deadline = academic_session.coursereg_deadline_found
     428            elif self.context.student.current_mode == 'bridge':
     429                deadline = academic_session.coursereg_deadline_bridge
     430            else:
     431                deadline = academic_session.coursereg_deadline
     432        except (TypeError, KeyError):
     433            deadline = None
     434        if deadline and deadline < datetime.now(pytz.utc):
     435            self.flash(_(
     436                "Course registration has ended. "
     437                "Unregistration is disabled."), type="danger")
     438        elif str(self.context.__parent__.current_level) != self.context.__name__:
     439            self.flash(_('This is not your current level.'), type="danger")
     440        elif self.context.student.state == REGISTERED:
     441            IWorkflowInfo(self.context.student).fireTransition('reset7')
     442            message = _('Course list has been unregistered.')
     443            self.flash(message)
     444        else:
     445            self.flash(_('You are in the wrong state.'), type="warning")
     446        self.redirect(self.url(self.context))
     447        return
    439448
    440449class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
Note: See TracChangeset for help on using the changeset viewer.