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

Last change on this file since 18161 was 18161, checked in by Henrik Bettermann, 15 months ago

Round gpa.

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