source: main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py @ 16982

Last change on this file since 16982 was 16936, checked in by Henrik Bettermann, 3 years ago

Remove condition.

  • Property svn:keywords set to Id
File size: 28.2 KB
RevLine 
[7419]1## $Id: utils.py 16936 2022-04-27 06:47:43Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
[7151]18import grok
[8600]19from time import time
[14918]20from zope.component import createObject, queryUtility
21from zope.catalog.interfaces import ICatalog
[10922]22from waeup.kofa.interfaces import (
[13594]23    ADMITTED, CLEARANCE, REQUESTED, CLEARED, RETURNING, PAID,
[16667]24    REGISTERED, VALIDATED, academic_sessions_vocab)
[8823]25from kofacustom.nigeria.students.utils import NigeriaStudentsUtils
[8247]26from waeup.kofa.accesscodes import create_accesscode
[10922]27from waeup.kofa.students.utils import trans
[13720]28from waeup.aaue.interswitch.browser import gateway_net_amt, GATEWAY_AMT
[8444]29from waeup.aaue.interfaces import MessageFactory as _
[6902]30
[14663]31MINIMUM_UNITS_THRESHOLD = 15
32
[8823]33class CustomStudentsUtils(NigeriaStudentsUtils):
[7151]34    """A collection of customized methods.
35
36    """
37
[16672]38    # PORTRAIT_CHANGE_STATES = (ADMITTED, CLEARANCE, REQUESTED, CLEARED)
[13348]39
[16672]40    def allowPortraitChange(self, student):
41        if student.is_fresh:
42            return True
43        return False
44
[14918]45    def GPABoundaries(self, faccode=None, depcode=None,
46                            certcode=None, student=None):
47        if student and student.current_mode.startswith('dp'):
[14959]48            return ((1.5, 'IRNS / NER / NYV'),
[14918]49                    (2.4, 'Pass'),
50                    (3.5, 'Merit'),
51                    (4.5, 'Credit'),
52                    (5, 'Distinction'))
53        elif student:
54            return ((1, 'FRNS / NER / NYV'),
55                    (1.5, 'Pass'),
56                    (2.4, '3rd Class Honours'),
57                    (3.5, '2nd Class Honours Lower Division'),
58                    (4.5, '2nd Class Honours Upper Division'),
59                    (5, '1st Class Honours'))
60        # Session Results Presentations depend on certificate
61        results = None
62        if certcode:
63            cat = queryUtility(ICatalog, name='certificates_catalog')
64            results = list(
65                cat.searchResults(code=(certcode, certcode)))
66        if results and results[0].study_mode.startswith('dp'):
[14975]67            return ((1.5, 'IRNS / NER / NYV'),
[14918]68                    (2.4, 'Pass'),
69                    (3.5, 'Merit'),
70                    (4.5, 'Credit'),
71                    (5, 'Distinction'))
72        else:
73            return ((1, 'FRNS / NER / NYV'),
74                    (1.5, 'Pass'),
75                    (2.4, '3rd Class Honours'),
76                    (3.5, '2nd Class Honours Lower Division'),
77                    (4.5, '2nd Class Honours Upper Division'),
78                    (5, '1st Class Honours'))
[14899]79
[14462]80    def getClassFromCGPA(self, gpa, student):
[14918]81        gpa_boundaries = self.GPABoundaries(student=student)
[15095]82
83        try:
84            certificate = getattr(student['studycourse'],'certificate',None)
85            end_level = getattr(certificate, 'end_level', None)
86            final_level = max([studylevel.level for studylevel in student['studycourse'].values()])
87            if end_level and final_level >= end_level:
88                dummy, repeat = divmod(final_level, 100)
89                if gpa <= 5.1 and repeat == 20:
90                    # Irrespective of the CGPA of a student, if the He/She has
91                    # 3rd Extension, such student will be graduated with a "Pass".
92                    return 1, gpa_boundaries[1][1]
93        except ValueError:
94            pass
95
[14899]96        if gpa < gpa_boundaries[0][0]:
97            # FRNS / Fail
98            return 0, gpa_boundaries[0][1]
[14977]99        if student.entry_session < 2013 or \
100            student.current_mode.startswith('dp'):
[14899]101            if gpa < gpa_boundaries[1][0]:
[14462]102                # Pass
[14899]103                return 1, gpa_boundaries[1][1]
[14462]104        else:
[14899]105            if gpa < gpa_boundaries[1][0]:
[14977]106                # FRNS
107                # Pass degree has been phased out in 2013 for non-diploma
108                # students
[14899]109                return 0, gpa_boundaries[0][1]
110        if gpa < gpa_boundaries[2][0]:
[15095]111            # 3rd / Merit
[14899]112            return 2, gpa_boundaries[2][1]
113        if gpa < gpa_boundaries[3][0]:
[15095]114            # 2nd L / Credit
[14899]115            return 3, gpa_boundaries[3][1]
116        if gpa < gpa_boundaries[4][0]:
[15095]117            # 2nd U / Distinction
[14899]118            return 4, gpa_boundaries[4][1]
119        if gpa <= gpa_boundaries[5][0]:
[15095]120            # 1st
[14899]121            return 5, gpa_boundaries[5][1]
[15095]122        return
[14462]123
[14160]124    def getDegreeClassNumber(self, level_obj):
[14415]125        """Get degree class number (used for SessionResultsPresentation
126        reports).
127        """
[14459]128        certificate = getattr(level_obj.__parent__,'certificate', None)
[14160]129        end_level = getattr(certificate, 'end_level', None)
[16708]130        if level_obj.level_verdict in ('FRNS', 'NER', 'NYV'):
[16652]131            return 0
[14459]132        if end_level and level_obj.level >= end_level:
[16708]133            if level_obj.level > end_level:
134                # spill-over level
135                if level_obj.gpa_params[1] == 0:
136                    # no credits taken
137                    return 0
138            elif level_obj.gpa_params[1] < MINIMUM_UNITS_THRESHOLD:
139                # credits taken below limit
140                return 0
[14160]141            failed_courses = level_obj.passed_params[4]
[14411]142            not_taken_courses = level_obj.passed_params[5]
[14160]143            if '_m' in failed_courses:
144                return 0
[14441]145            if len(not_taken_courses) \
[14506]146                and not not_taken_courses == 'Nil':
[14411]147                return 0
[16708]148        elif level_obj.gpa_params[1] < MINIMUM_UNITS_THRESHOLD:
149            # credits taken below limit
[14464]150            return 0
[14160]151        # use gpa_boundaries above
[14462]152        return self.getClassFromCGPA(
153            level_obj.cumulative_params[0], level_obj.student)[0]
[14160]154
[13359]155    def increaseMatricInteger(self, student):
156        """Increase counter for matric numbers.
157        This counter can be a centrally stored attribute or an attribute of
158        faculties, departments or certificates. In the base package the counter
159        is as an attribute of the site configuration container.
160        """
[15382]161        if student.current_mode in ('ug_pt', 'de_pt', 'ug_dsh', 'de_dsh'):
[13359]162            grok.getSite()['configuration'].next_matric_integer += 1
163            return
[13609]164        elif student.is_postgrad:
165            grok.getSite()['configuration'].next_matric_integer_3 += 1
166            return
[13793]167        elif student.current_mode in ('dp_ft',):
168            grok.getSite()['configuration'].next_matric_integer_4 += 1
169            return
[13359]170        grok.getSite()['configuration'].next_matric_integer_2 += 1
171        return
172
[13749]173    def _concessionalPaymentMade(self, student):
174        if len(student['payments']):
175            for ticket in student['payments'].values():
176                if ticket.p_state == 'paid' and \
177                    ticket.p_category == 'concessional':
178                    return True
179        return False
180
[11596]181    def constructMatricNumber(self, student):
[11593]182        faccode = student.faccode
183        depcode = student.depcode
[13609]184        certcode = student.certcode
[13664]185        degree = getattr(
186            getattr(student.get('studycourse', None), 'certificate', None),
187                'degree', None)
[11593]188        year = unicode(student.entry_session)[2:]
[13359]189        if not student.state in (PAID, ) or not student.is_fresh or \
[14615]190            student.current_mode in ('found', 'ijmbe'):
[13359]191            return _('Matriculation number cannot be set.'), None
[13755]192        #if student.current_mode not in ('mug_ft', 'mde_ft') and \
193        #    not self._concessionalPaymentMade(student):
194        #    return _('Matriculation number cannot be set.'), None
[13571]195        if student.is_postgrad:
[13609]196            next_integer = grok.getSite()['configuration'].next_matric_integer_3
[13664]197            if not degree or next_integer == 0:
[13609]198                return _('Matriculation number cannot be set.'), None
[13846]199            if student.faccode in ('IOE'):
200                return None, "AAU/SPS/%s/%s/%s/%05d" % (
201                    faccode, year, degree, next_integer)
[13609]202            return None, "AAU/SPS/%s/%s/%s/%s/%05d" % (
[13664]203                faccode, depcode, year, degree, next_integer)
[15382]204        if student.current_mode in ('ug_dsh', 'de_dsh'):
[15368]205            next_integer = grok.getSite()['configuration'].next_matric_integer
206            if next_integer == 0:
207                return _('Matriculation number cannot be set.'), None
[15376]208            return None, "DSH/%s/%s/%s/%05d" % (
[15368]209                faccode, depcode, year, next_integer)
[13359]210        if student.current_mode in ('ug_pt', 'de_pt'):
211            next_integer = grok.getSite()['configuration'].next_matric_integer
212            if next_integer == 0:
213                return _('Matriculation number cannot be set.'), None
[12975]214            return None, "PTP/%s/%s/%s/%05d" % (
215                faccode, depcode, year, next_integer)
[13793]216        if student.current_mode in ('dp_ft',):
217            next_integer = grok.getSite()['configuration'].next_matric_integer_4
218            if next_integer == 0:
219                return _('Matriculation number cannot be set.'), None
220            return None, "IOE/DIP/%s/%05d" % (year, next_integer)
[13359]221        next_integer = grok.getSite()['configuration'].next_matric_integer_2
222        if next_integer == 0:
223            return _('Matriculation number cannot be set.'), None
[16822]224        if student.faccode in ('FBM', 'FCS', 'FMLS'):
[13359]225            return None, "CMS/%s/%s/%s/%05d" % (
226                faccode, depcode, year, next_integer)
227        return None, "%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
[12975]228
[8270]229    def getReturningData(self, student):
230        """ This method defines what happens after school fee payment
[8319]231        of returning students depending on the student's senate verdict.
[8270]232        """
[8319]233        prev_level = student['studycourse'].current_level
234        cur_verdict = student['studycourse'].current_verdict
[14958]235        if cur_verdict in ('A','B','L','M','N','Z',):
[8319]236            # Successful student
237            new_level = divmod(int(prev_level),100)[0]*100 + 100
[14958]238        elif cur_verdict == 'C':
239            # Student on probation
240            new_level = int(prev_level) + 10
[8319]241        else:
242            # Student is somehow in an undefined state.
243            # Level has to be set manually.
244            new_level = prev_level
[8270]245        new_session = student['studycourse'].current_session + 1
246        return new_session, new_level
247
[13454]248    def _isPaymentDisabled(self, p_session, category, student):
249        academic_session = self._getSessionConfiguration(p_session)
[14246]250        if category.startswith('schoolfee'):
251            if 'sf_all' in academic_session.payment_disabled:
252                return True
253            if 'sf_pg' in academic_session.payment_disabled and \
254                student.is_postgrad:
255                return True
[14571]256            if 'sf_ug_pt' in academic_session.payment_disabled and \
257                student.current_mode in ('ug_pt', 'de_pt'):
[14246]258                return True
259            if 'sf_found' in academic_session.payment_disabled and \
260                student.current_mode == 'found':
261                return True
[13794]262        if category.startswith('clearance') and \
263            'cl_regular' in academic_session.payment_disabled and \
264            student.current_mode in ('ug_ft', 'de_ft', 'mug_ft', 'mde_ft'):
265            return True
[13454]266        if category == 'hostel_maintenance' and \
267            'maint_all' in academic_session.payment_disabled:
268            return True
269        return False
270
[9154]271    def setPaymentDetails(self, category, student,
[15667]272            previous_session=None, previous_level=None, combi=[]):
[8600]273        """Create Payment object and set the payment data of a student for
274        the payment category specified.
275
276        """
[8306]277        details = {}
[8600]278        p_item = u''
279        amount = 0.0
280        error = u''
[9154]281        if previous_session:
[14544]282            if previous_session < student['studycourse'].entry_session:
283                return _('The previous session must not fall below '
284                         'your entry session.'), None
285            if category == 'schoolfee':
286                # School fee is always paid for the following session
287                if previous_session > student['studycourse'].current_session:
288                    return _('This is not a previous session.'), None
289            else:
290                if previous_session > student['studycourse'].current_session - 1:
291                    return _('This is not a previous session.'), None
292            p_session = previous_session
293            p_level = previous_level
294            p_current = False
295        else:
296            p_session = student['studycourse'].current_session
297            p_level = student['studycourse'].current_level
298            p_current = True
[9527]299        academic_session = self._getSessionConfiguration(p_session)
300        if academic_session == None:
[8600]301            return _(u'Session configuration object is not available.'), None
[8677]302        # Determine fee.
[7151]303        if category == 'transfer':
[8600]304            amount = academic_session.transfer_fee
[14296]305        elif category == 'transcript_local':
306            amount = academic_session.transcript_fee_local
307        elif category == 'transcript_inter':
308            amount = academic_session.transcript_fee_inter
[7151]309        elif category == 'bed_allocation':
[8600]310            amount = academic_session.booking_fee
[14378]311        elif category == 'restitution':
[15178]312            if student.current_session != 2016 \
313                or student.current_mode not in ('ug_ft', 'dp_ft') \
314                or student.is_fresh:
[14378]315                return _(u'Restitution fee payment not required.'), None
316            amount = academic_session.restitution_fee
[7151]317        elif category == 'hostel_maintenance':
[13418]318            amount = 0.0
319            bedticket = student['accommodation'].get(
320                str(student.current_session), None)
[13502]321            if bedticket is not None and bedticket.bed is not None:
[13474]322                p_item = bedticket.display_coordinates
[13418]323                if bedticket.bed.__parent__.maint_fee > 0:
324                    amount = bedticket.bed.__parent__.maint_fee
325                else:
326                    # fallback
327                    amount = academic_session.maint_fee
328            else:
[13506]329                return _(u'No bed allocated.'), None
[13636]330        elif student.current_mode == 'found' and category not in (
331            'schoolfee', 'clearance', 'late_registration'):
332            return _('Not allowed.'), None
[13400]333        elif category.startswith('clearance'):
[13594]334            if student.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED):
335                return _(u'Acceptance Fee payments not allowed.'), None
[13855]336            if student.current_mode in (
337                'ug_ft', 'ug_pt', 'de_ft', 'de_pt',
338                'transfer', 'mug_ft', 'mde_ft') \
339                and category != 'clearance_incl':
340                    return _("Additional fees must be included."), None
[14518]341            if student.current_mode == 'ijmbe':
342                amount = academic_session.clearance_fee_ijmbe
[15373]343            elif student.current_mode == 'bridge':
344                amount = academic_session.clearance_fee_bridge
[14954]345            elif student.current_mode == 'dp_ft':
346                amount = academic_session.clearance_fee_dp
[14518]347            elif student.faccode == 'FP':
[11653]348                amount = academic_session.clearance_fee_fp
[15393]349            elif student.current_mode in ('ug_pt', 'de_pt', 'ug_dsh', 'de_dsh'):
350                amount = academic_session.clearance_fee_ug_pt
351            elif student.current_mode == 'special_pg_pt':
352                amount = academic_session.clearance_fee_pg_pt
[13466]353            elif student.faccode == 'FCS':
354                # Students in clinical medical sciences pay the medical
355                # acceptance fee
[13377]356                amount = academic_session.clearance_fee_med
[15393]357            elif student.current_mode == 'special_pg_ft':
[13853]358                if category != 'clearance':
[13854]359                    return _("No additional fees required."), None
[13526]360                amount = academic_session.clearance_fee_pg
[11653]361            else:
362                amount = academic_session.clearance_fee
[8753]363            p_item = student['studycourse'].certificate.code
[13689]364            if amount in (0.0, None):
365                return _(u'Amount could not be determined.'), None
[14239]366            # Add Matric Gown Fee and Lapel Fee
[13689]367            if category == 'clearance_incl':
[13414]368                amount += gateway_net_amt(academic_session.matric_gown_fee) + \
369                    gateway_net_amt(academic_session.lapel_fee)
[11004]370        elif category == 'late_registration':
[14117]371            if student.is_postgrad:
372                amount = academic_session.late_pg_registration_fee
373            else:
374                amount = academic_session.late_registration_fee
[16667]375        elif category == 'ict':
376            if student.is_fresh:
377                amount = 2200
378            else:
379                amount = 1200
[13400]380        elif category.startswith('schoolfee'):
[8600]381            try:
[8753]382                certificate = student['studycourse'].certificate
383                p_item = certificate.code
[8600]384            except (AttributeError, TypeError):
385                return _('Study course data are incomplete.'), None
[13853]386            if student.is_postgrad and category != 'schoolfee':
[13854]387                return _("No additional fees required."), None
[14544]388            if not previous_session and student.current_mode in (
[13855]389                'ug_ft', 'ug_pt', 'de_ft', 'de_pt',
390                'transfer', 'mug_ft', 'mde_ft') \
391                and not category in (
392                'schoolfee_incl', 'schoolfee_1', 'schoolfee_2'):
[14244]393                    return _("You must choose a payment which includes "
[13855]394                             "additional fees."), None
[13780]395            if category in ('schoolfee_1', 'schoolfee_2'):
396                if student.current_mode == 'ug_pt':
397                    return _("Part-time students are not allowed "
398                             "to pay by instalments."), None
[14241]399                if student.entry_session < 2015:
400                    return _("You are not allowed "
401                             "to pay by instalments."), None
[14544]402            if previous_session:
403                # Students can pay for previous sessions in all
404                # workflow states.  Fresh students are excluded by the
405                # update method of the PreviousPaymentAddFormPage.
406                if previous_level == 100:
407                    amount = getattr(certificate, 'school_fee_1', 0.0)
408                else:
[14954]409                    if student.entry_session in (2015, 2016):
[14544]410                        amount = getattr(certificate, 'school_fee_2', 0.0)
411                    else:
412                        amount = getattr(certificate, 'school_fee_3', 0.0)
413            elif student.state == CLEARED and category != 'schoolfee_2':
[14229]414                amount = getattr(certificate, 'school_fee_1', 0.0)
[13512]415                # Cut school fee by 50%
[14241]416                if category == 'schoolfee_1' and amount:
417                    amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
418            elif student.is_fresh and category == 'schoolfee_2':
419                amount = getattr(certificate, 'school_fee_1', 0.0)
420                # Cut school fee by 50%
421                if amount:
422                    amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
[14396]423            elif student.state == RETURNING and category != 'schoolfee_2':
[13482]424                if not student.father_name:
425                    return _("Personal data form is not properly filled."), None
[13374]426                # In case of returning school fee payment the payment session
427                # and level contain the values of the session the student
428                # has paid for.
429                p_session, p_level = self.getReturningData(student)
[8961]430                try:
431                    academic_session = grok.getSite()[
432                        'configuration'][str(p_session)]
433                except KeyError:
434                    return _(u'Session configuration object is not available.'), None
[15871]435                if student.entry_session >= 2015:
[14229]436                    amount = getattr(certificate, 'school_fee_2', 0.0)
[13374]437                else:
[14229]438                    amount = getattr(certificate, 'school_fee_3', 0.0)
[14954]439                # Cut school fee by 50%
440                if category == 'schoolfee_1' and amount:
441                    amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
[14241]442            elif category == 'schoolfee_2':
443                amount = getattr(certificate, 'school_fee_2', 0.0)
444                # Cut school fee by 50%
445                if amount:
446                    amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
[8600]447            else:
[8753]448                return _('Wrong state.'), None
[13417]449            if amount in (0.0, None):
450                return _(u'Amount could not be determined.'), None
[15180]451            # Add Student Union Fee, Student Id Card Fee, Sports Dev. Fee,
452            # Library Dev. Fee and Welfare Assurance
[15997]453            if category in ('schoolfee_incl', 'schoolfee_1') \
454                and student.current_mode != 'ijmbe':
455                amount += gateway_net_amt(academic_session.welfare_fee) + \
456                    gateway_net_amt(academic_session.union_fee)
[15976]457                if student.entry_session >= 2018 and student.is_fresh:
[15192]458                    amount += gateway_net_amt(academic_session.sports_fee)
459                    if student.is_postgrad:
[15971]460                        amount += gateway_net_amt(academic_session.library_pg_fee)
[15192]461                    else:
462                        amount += gateway_net_amt(academic_session.library_fee)
[16936]463                if student.entry_session >= 2021 \
[16934]464                    and student.current_mode == 'ug_ft':
465                    amount += gateway_net_amt(academic_session.lms_sund_fee)
[15763]466            # Add non-indigenous fee and session specific penalty fees
[13534]467            if student.is_postgrad:
468                amount += academic_session.penalty_pg
[15763]469                if student.lga and not student.lga.startswith('edo'):
470                    amount += 20000.0
[13534]471            else:
472                amount += academic_session.penalty_ug
[16179]473        #elif category == ('fac_dep'):
474        #    if student.faccode in ('FAT', 'FED', 'FLW', 'FMS', 'FSS'):
475        #        amount = 4200.0
476        #    elif student.faccode in ('FAG', 'FBM', 'FCS',
477        #                             'FES', 'FET', 'FLS', 'FPS'):
478        #        amount = 5200.0
479        #    elif student.faccode == 'FAG' and student.current_level == 400:
480        #        amount = 10200.0
481        #    elif student.depcode == 'VTE':
482        #        amount = 5200.0
483        #    if student.entry_session >= 2019:
484        #        amount += gateway_net_amt(academic_session.ict_fee)
[16123]485        elif category == 'sports_library': # temporarily in 2020
[16124]486            if student.is_postgrad:
487                amount = academic_session.sports_fee + gateway_net_amt(
488                    academic_session.library_pg_fee)
489            else:
490                amount = academic_session.sports_fee + gateway_net_amt(
491                    academic_session.library_fee)
[14248]492        elif not student.is_postgrad:
493            fee_name = category + '_fee'
494            amount = getattr(academic_session, fee_name, 0.0)
[8600]495        if amount in (0.0, None):
496            return _(u'Amount could not be determined.'), None
[8677]497        # Create ticket.
[8600]498        for key in student['payments'].keys():
499            ticket = student['payments'][key]
500            if ticket.p_state == 'paid' and\
501               ticket.p_category == category and \
[15096]502               not ticket.p_category.startswith('transcript') and \
[8600]503               ticket.p_item == p_item and \
504               ticket.p_session == p_session:
505                  return _('This type of payment has already been made.'), None
[13786]506            # Additional condition in AAUE
507            if category in ('schoolfee', 'schoolfee_incl', 'schoolfee_1'):
508                if ticket.p_state == 'paid' and \
509                   ticket.p_category in ('schoolfee',
510                                         'schoolfee_incl',
511                                         'schoolfee_1') and \
512                   ticket.p_item == p_item and \
513                   ticket.p_session == p_session:
514                      return _(
515                          'Another school fee payment for this '
516                          'session has already been made.'), None
517
[11455]518        if self._isPaymentDisabled(p_session, category, student):
[13798]519            return _('This category of payments has been disabled.'), None
[8712]520        payment = createObject(u'waeup.StudentOnlinePayment')
[8954]521        timestamp = ("%d" % int(time()*10000))[1:]
[8600]522        payment.p_id = "p%s" % timestamp
523        payment.p_category = category
524        payment.p_item = p_item
525        payment.p_session = p_session
526        payment.p_level = p_level
[9154]527        payment.p_current = p_current
[8600]528        payment.amount_auth = amount
529        return None, payment
[7621]530
[10922]531    def _admissionText(self, student, portal_language):
532        inst_name = grok.getSite()['configuration'].name
533        entry_session = student['studycourse'].entry_session
534        entry_session = academic_sessions_vocab.getTerm(entry_session).title
535        text = trans(_(
[10953]536            'This is to inform you that you have been offered provisional'
537            ' admission into ${a} for the ${b} academic session as follows:',
[10922]538            mapping = {'a': inst_name, 'b': entry_session}),
539            portal_language)
540        return text
541
[14585]542    def warnCreditsOOR(self, studylevel, course=None):
[14733]543        studycourse = studylevel.__parent__
544        certificate = getattr(studycourse,'certificate', None)
545        current_level = studycourse.current_level
546        if None in (current_level, certificate):
547            return
548        end_level = certificate.end_level
549        if current_level >= end_level:
550            limit = 52
551        else:
552            limit = 48
553        if course and studylevel.total_credits + course.credits > limit:
[14585]554            return  _('Maximum credits exceeded.')
[14733]555        elif studylevel.total_credits > limit:
[14585]556            return _('Maximum credits exceeded.')
557        return
[10051]558
[13353]559    def getBedCoordinates(self, bedticket):
560        """Return descriptive bed coordinates.
561        This method can be used to customize the `display_coordinates`
562        property method in order to  display a
563        customary description of the bed space.
564        """
565        bc = bedticket.bed_coordinates.split(',')
566        if len(bc) == 4:
567            return bc[0]
568        return bedticket.bed_coordinates
569
[13415]570    def getAccommodationDetails(self, student):
571        """Determine the accommodation data of a student.
572        """
573        d = {}
574        d['error'] = u''
575        hostels = grok.getSite()['hostels']
576        d['booking_session'] = hostels.accommodation_session
577        d['allowed_states'] = hostels.accommodation_states
578        d['startdate'] = hostels.startdate
579        d['enddate'] = hostels.enddate
580        d['expired'] = hostels.expired
581        # Determine bed type
[13416]582        bt = 'all'
[13415]583        if student.sex == 'f':
584            sex = 'female'
585        else:
586            sex = 'male'
587        special_handling = 'regular'
588        d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
589        return d
590
[13753]591    def checkAccommodationRequirements(self, student, acc_details):
[14238]592        msg = super(CustomStudentsUtils, self).checkAccommodationRequirements(
[13753]593            student, acc_details)
[14238]594        if msg:
595            return msg
[13753]596        if student.current_mode not in ('ug_ft', 'de_ft', 'mug_ft', 'mde_ft'):
597            return _('You are not eligible to book accommodation.')
598        return
599
[8444]600    # AAUE prefix
[14593]601    STUDENT_ID_PREFIX = u'E'
602
[15925]603    STUDENT_EXPORTER_NAMES = (
604            'students',
605            'studentstudycourses',
[16896]606            'studentstudycourses_1',
[15925]607            'studentstudylevels',
[16896]608            #'studentstudylevels_1',
[15925]609            'coursetickets',
[16896]610            #'coursetickets_1',
[15925]611            'studentpayments',
612            'bedtickets',
613            'unpaidpayments',
614            'sfpaymentsoverview',
615            'studylevelsoverview',
616            'combocard',
617            'bursary',
[15874]618            'levelreportdata',
[15925]619            'outstandingcourses',
[15897]620            'sessionpaymentsoverview',
[15925]621            'accommodationpayments',
[16033]622            'transcriptdata',
623            'trimmedpayments',
624            'trimmed',
[16859]625            'outstandingcourses_2'
[16033]626            )
[15948]627
628    # Maximum size of upload files in kB
629    MAX_KB = 500
Note: See TracBrowser for help on using the repository browser.