Ignore:
Timestamp:
27 Jun 2024, 07:47:23 (5 months ago)
Author:
Henrik Bettermann
Message:

Implement NYSC request pages.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/students
Files:
4 edited

Legend:

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

    r17812 r17822  
    7777    IMedicalHistory,
    7878    ITiship,
     79    INYSC,
    7980    ICustomCourseTicket)
    8081from waeup.uniben.interfaces import MessageFactory as _
     
    552553        form_fields = grok.AutoFields(
    553554            ICustomStudentPersonalEdit).omit('personal_updated') + grok.AutoFields(ITiship)
    554         studycourse = self.context['studycourse']
    555         certificate = getattr(studycourse,'certificate',None)
    556         current_level = studycourse.current_level
    557         end_level = certificate.end_level
    558         if not self.context.current_level >= end_level:
    559             form_fields = form_fields.omit('nysc')
    560555        return form_fields
    561556
     
    10721067            self.context.student, omit_fields=self.omit_fields,
    10731068            letterhead_path=letterhead_path, post_text=None)
     1069
     1070class StudentNYSCEditFormPage(KofaEditFormPage):
     1071    """ Page to edit NYSC data
     1072    """
     1073    grok.context(ICustomStudent)
     1074    grok.name('edit_nysc')
     1075    grok.require('waeup.handleStudent')
     1076    label = _('NYSC Request')
     1077    pnav = 4
     1078
     1079    def update(self):
     1080        if not self.context.eligible_for_nysc:
     1081            self.flash('You are not allowed to apply for NYSC.',
     1082                type="warning")
     1083            self.redirect(self.url(self.context))
     1084            return
     1085        return super(StudentNYSCEditFormPage, self).update()
     1086
     1087    @property
     1088    def form_fields(self):
     1089        form_fields = grok.AutoFields(INYSC)
     1090        form_fields['nysc_updated'].for_display = True
     1091        form_fields['nysc_senate_info'].for_display = True
     1092        form_fields['nysc'].field.description = u'Ensure that all your school charges are paid up to date to your graduating session before making this nysc application.'
     1093        form_fields['nysc'].field.title = u'Do you want to apply for NYSC?'
     1094        form_fields[
     1095            'nysc_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     1096        form_fields['nysc'].custom_widget = CustomBooleanRadioWidget
     1097        return form_fields
     1098
     1099    @action(_('Save'), style='primary')
     1100    def save(self, **data):
     1101        msave(self, **data)
     1102        self.context.nysc_updated = datetime.utcnow()
     1103        return
     1104
     1105class StudentNYSCManageFormPage(KofaEditFormPage):
     1106    """ Page to manage NYSC data
     1107    """
     1108    grok.context(ICustomStudent)
     1109    grok.name('manage_nysc')
     1110    grok.require('waeup.manageStudent')
     1111    label = _('Manage NYSC request data')
     1112
     1113    @property
     1114    def form_fields(self):
     1115        form_fields = grok.AutoFields(INYSC)
     1116        form_fields['nysc_updated'].for_display = True
     1117        form_fields['nysc'].field.description = u''
     1118        form_fields['nysc'].field.title = u'NYSC requested'
     1119        form_fields[
     1120            'nysc_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     1121        return form_fields
     1122
     1123    @action(_('Save'), style='primary')
     1124    def save(self, **data):
     1125        msave(self, **data)
     1126        return
  • main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py

    r17395 r17822  
    2323from waeup.kofa.students.vocabularies import StudyLevelSource
    2424from kofacustom.nigeria.interfaces import GradingSystemSource
     25from waeup.kofa.schema import FormattedDate
    2526from kofacustom.nigeria.students.interfaces import (
    2627    INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance,
     
    215216        )
    216217
     218class INYSC(IKofaObject):
     219    """Student NYSC data.
     220    """
     221
     222    nysc = schema.Bool(
     223        title = u'NYSC',
     224        default = False,
     225        required = True,
     226        )
     227
     228    nysc_updated = schema.Datetime(
     229        title = _(u'NYSC request data last updated by student'),
     230        )
     231
     232    nysc_date_of_graduation = FormattedDate(
     233        title = _(u'Date of Graduation'),
     234        required = False,
     235        show_year = True,
     236        )
     237
     238    nysc_senate_info = schema.TextLine(
     239        title = _(u'Senate Info'),
     240        required = False,
     241        )
     242
    217243class ITiship(IKofaObject):
    218244    """Student tiship data.
     
    239265        )
    240266
    241     nysc = schema.Bool(
    242         title = _(u'Applying for NYSC'),
    243         default = False,
    244         required = True,
    245         )
    246 
    247267class ICustomStudentPersonalEdit(INigeriaStudentPersonalEdit):
    248268    """Interface for editing personal data by students.
     
    255275        )
    256276
    257     nysc = schema.Bool(
    258         title = _(u'Do you want to apply for NYSC?'),
    259         default = False,
    260         description = u'Ensure that all your school charges are paid up to date to your graduating session before making this nysc application.',
    261         required = True,
    262         )
    263 
    264277class ICustomUGStudentClearance(INigeriaUGStudentClearance):
    265278    """Representation of ug student clearance data.
     
    272285class ICustomStudent(ICustomStudentBase, ICustomUGStudentClearance,
    273286    ICustomPGStudentClearance, ICustomStudentPersonal, IMedicalHistory,
    274     ITiship):
     287    ITiship, INYSC):
    275288    """Representation of a student.
    276289    """
  • main/waeup.uniben/trunk/src/waeup/uniben/students/student.py

    r17395 r17822  
    2929from kofacustom.nigeria.students.student import NigeriaStudent
    3030from waeup.uniben.students.interfaces import (
    31     ICustomStudent, ICustomStudentPersonalEdit, IMedicalHistory, ITiship)
     31    ICustomStudent, ICustomStudentPersonalEdit,
     32    IMedicalHistory, ITiship, INYSC)
    3233
    3334
     
    3839    grok.implements(
    3940        ICustomStudent, IStudentNavigation, ICustomStudentPersonalEdit,
    40         IMedicalHistory, ITiship)
     41        IMedicalHistory, ITiship, INYSC)
    4142    grok.provides(ICustomStudent)
    4243
     
    6465        return self.state in (TRANSREL, TRANSVAL)
    6566
     67    @property
     68    def eligible_for_nysc(self):
     69        if not self.current_mode.startswith('ug') \
     70            and not self.current_mode.startswith('de'):
     71            return False
     72        studycourse = self['studycourse']
     73        certificate = getattr(studycourse,'certificate',None)
     74        current_level = studycourse.current_level
     75        end_level = certificate.end_level
     76        if not self.current_level >= end_level:
     77            return False
     78        return True
     79
    6680
    6781# Set all attributes of Student required in IStudent as field
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r17812 r17822  
    237237        return self.view.url(self.view.context, self.target)
    238238
     239class NYSCEditActionButton(ManageActionButton):
     240    grok.order(13)
     241    grok.context(ICustomStudent)
     242    grok.view(StudentBaseDisplayFormPage)
     243    grok.require('waeup.handleStudent')
     244    text = _('NYSC Request')
     245    target = 'edit_nysc'
     246    icon = 'actionicon_nigeria.png'
     247
     248    @property
     249    def target_url(self):
     250        if not self.context.eligible_for_nysc:
     251            return ''
     252        return self.view.url(self.view.context, self.target)
     253
     254class NYSCManageActionButton(ManageActionButton):
     255    grok.require('waeup.manageStudent')
     256    text = _('Manage NYSC request data')
     257    target = 'manage_nysc'
     258    grok.order(13)
     259    grok.context(ICustomStudent)
     260    grok.view(StudentBaseDisplayFormPage)
     261    icon = 'actionicon_nigeria.png'
     262
    239263# JAMB Letter
    240264
Note: See TracChangeset for help on using the changeset viewer.