Changeset 14981


Ignore:
Timestamp:
5 Apr 2018, 06:26:47 (7 years ago)
Author:
Henrik Bettermann
Message:

In AAUE fresh students are allowed to "unregister their course" aside the deadline.

  • no tests yet -
File:
1 edited

Legend:

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

    r14944 r14981  
    1919import csv
    2020import textwrap
     21import pytz
    2122from cStringIO import StringIO
     23from datetime import datetime
    2224from zope.i18n import translate
    2325from zope.component import getUtility, queryUtility
     
    2628from zope.catalog.interfaces import ICatalog
    2729from zope.formlib.textwidgets import BytesDisplayWidget
     30from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2831from waeup.kofa.browser.layout import UtilityView
    2932from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
     
    5255    DownloadScoresView,
    5356    StudentRequestPasswordPage,
    54     StudyCourseManageFormPage
     57    StudyCourseManageFormPage,
     58    UnregisterCoursesView
    5559    )
    5660from kofacustom.nigeria.students.browser import (
     
    390394        form_fields['imported_cgpa'].for_display = True
    391395        return form_fields
     396
     397class CustomUnregisterCoursesView(UnregisterCoursesView):
     398    """Unregister course list by student
     399    """
     400    grok.context(ICustomStudentStudyLevel)
     401
     402    def update(self):
     403        if not self.context.__parent__.is_current:
     404            emit_lock_message(self)
     405            return
     406        try:
     407            deadline = grok.getSite()['configuration'][
     408                str(self.context.level_session)].coursereg_deadline
     409        except (TypeError, KeyError):
     410            deadline = None
     411        # In AAUE fresh students are allowed to "unregister their course"
     412        # aside the deadline
     413        if deadline and not self.context.student.is_fresh \
     414            and deadline < datetime.now(pytz.utc):
     415            self.flash(_(
     416                "Course registration has ended. "
     417                "Unregistration is disabled."), type="warning")
     418        elif str(self.context.__parent__.current_level) != self.context.__name__:
     419            self.flash(_('This is not your current level.'), type="danger")
     420        elif self.context.student.state == REGISTERED:
     421            IWorkflowInfo(self.context.student).fireTransition('reset7')
     422            message = _('Course list has been unregistered.')
     423            self.flash(message)
     424        else:
     425            self.flash(_('You are in the wrong state.'), type="warning")
     426        self.redirect(self.url(self.context))
     427        return
    392428
    393429class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
Note: See TracChangeset for help on using the changeset viewer.