source: main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py @ 15607

Last change on this file since 15607 was 15584, checked in by Henrik Bettermann, 5 years ago

Import missing escape function.

  • Property svn:keywords set to Id
File size: 48.3 KB
RevLine 
[7191]1## $Id: utils.py 15584 2019-09-11 07:21:28Z 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##
[13076]18"""General helper functions and utilities for the students section.
[6651]19"""
[7150]20import grok
[15234]21import textwrap
[15584]22from cgi import escape
[8595]23from time import time
[15163]24from cStringIO import StringIO
[7318]25from reportlab.lib import colors
[7019]26from reportlab.lib.units import cm
27from reportlab.lib.pagesizes import A4
[9015]28from reportlab.lib.styles import getSampleStyleSheet
29from reportlab.platypus import Paragraph, Image, Table, Spacer
[14256]30from reportlab.platypus.doctemplate import LayoutError
[11589]31from zope.event import notify
[9922]32from zope.schema.interfaces import ConstraintNotSatisfied
[9015]33from zope.component import getUtility, createObject
[7019]34from zope.formlib.form import setUpEditWidgets
[9015]35from zope.i18n import translate
[8596]36from waeup.kofa.interfaces import (
[9762]37    IExtFileStore, IKofaUtils, RETURNING, PAID, CLEARED,
[15163]38    academic_sessions_vocab, IFileStoreNameChooser)
[7811]39from waeup.kofa.interfaces import MessageFactory as _
40from waeup.kofa.students.interfaces import IStudentsUtils
[10706]41from waeup.kofa.students.workflow import ADMITTED
[11589]42from waeup.kofa.students.vocabularies import StudyLevelSource, MatNumNotInSource
[9910]43from waeup.kofa.browser.pdf import (
[9965]44    ENTRY1_STYLE, format_html, NOTE_STYLE, HEADING_STYLE,
[11550]45    get_signature_tables, get_qrcode)
[9910]46from waeup.kofa.browser.interfaces import IPDFCreator
[10256]47from waeup.kofa.utils.helpers import to_timezone
[6651]48
[7318]49SLIP_STYLE = [
50    ('VALIGN',(0,0),(-1,-1),'TOP'),
51    #('FONT', (0,0), (-1,-1), 'Helvetica', 11),
52    ]
[7019]53
[7318]54CONTENT_STYLE = [
55    ('VALIGN',(0,0),(-1,-1),'TOP'),
56    #('FONT', (0,0), (-1,-1), 'Helvetica', 8),
57    #('TEXTCOLOR',(0,0),(-1,0),colors.white),
[9906]58    #('BACKGROUND',(0,0),(-1,0),colors.black),
59    ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
60    ('BOX', (0,0), (-1,-1), 1, colors.black),
[7318]61    ]
[7304]62
[7318]63FONT_SIZE = 10
64FONT_COLOR = 'black'
65
[8112]66def trans(text, lang):
67    # shortcut
68    return translate(text, 'waeup.kofa', target_language=lang)
69
[10261]70def formatted_text(text, color=FONT_COLOR, lang='en'):
[7511]71    """Turn `text`, `color` and `size` into an HTML snippet.
[7318]72
[7511]73    The snippet is suitable for use with reportlab and generating PDFs.
74    Wraps the `text` into a ``<font>`` tag with passed attributes.
75
76    Also non-strings are converted. Raw strings are expected to be
77    utf-8 encoded (usually the case for widgets etc.).
78
[7804]79    Finally, a br tag is added if widgets contain div tags
80    which are not supported by reportlab.
81
[7511]82    The returned snippet is unicode type.
83    """
84    if not isinstance(text, unicode):
85        if isinstance(text, basestring):
86            text = text.decode('utf-8')
87        else:
88            text = unicode(text)
[9717]89    if text == 'None':
90        text = ''
[13665]91    # Very long matriculation numbers need to be wrapped
92    if text.find(' ') == -1 and len(text.split('/')) > 6:
93        text = '/'.join(text.split('/')[:5]) + \
94            '/ ' + '/'.join(text.split('/')[5:])
[8141]95    # Mainly for boolean values we need our customized
96    # localisation of the zope domain
[10261]97    text = translate(text, 'zope', target_language=lang)
[7804]98    text = text.replace('</div>', '<br /></div>')
[9910]99    tag1 = u'<font color="%s">' % (color)
[7511]100    return tag1 + u'%s</font>' % text
101
[8481]102def generate_student_id():
[8410]103    students = grok.getSite()['students']
104    new_id = students.unique_student_id
105    return new_id
[6742]106
[7186]107def set_up_widgets(view, ignore_request=False):
[7019]108    view.adapters = {}
109    view.widgets = setUpEditWidgets(
110        view.form_fields, view.prefix, view.context, view.request,
111        adapters=view.adapters, for_display=True,
112        ignore_request=ignore_request
113        )
114
[11550]115def render_student_data(studentview, context, omit_fields=(),
[14292]116                        lang='en', slipname=None, no_passport=False):
[7318]117    """Render student table for an existing frame.
118    """
119    width, height = A4
[7186]120    set_up_widgets(studentview, ignore_request=True)
[7318]121    data_left = []
[11550]122    data_middle = []
[7019]123    style = getSampleStyleSheet()
[7280]124    img = getUtility(IExtFileStore).getFileByContext(
125        studentview.context, attr='passport.jpg')
126    if img is None:
[7811]127        from waeup.kofa.browser import DEFAULT_PASSPORT_IMAGE_PATH
[7280]128        img = open(DEFAULT_PASSPORT_IMAGE_PATH, 'rb')
[7318]129    doc_img = Image(img.name, width=4*cm, height=4*cm, kind='bound')
130    data_left.append([doc_img])
131    #data.append([Spacer(1, 12)])
[9141]132
[10261]133    f_label = trans(_('Name:'), lang)
[9910]134    f_label = Paragraph(f_label, ENTRY1_STYLE)
[9911]135    f_text = formatted_text(studentview.context.display_fullname)
[9910]136    f_text = Paragraph(f_text, ENTRY1_STYLE)
[11550]137    data_middle.append([f_label,f_text])
[9141]138
[7019]139    for widget in studentview.widgets:
[9141]140        if 'name' in widget.name:
[7019]141            continue
[9911]142        f_label = translate(
[7811]143            widget.label.strip(), 'waeup.kofa',
[10261]144            target_language=lang)
[9911]145        f_label = Paragraph('%s:' % f_label, ENTRY1_STYLE)
[10261]146        f_text = formatted_text(widget(), lang=lang)
[9910]147        f_text = Paragraph(f_text, ENTRY1_STYLE)
[11550]148        data_middle.append([f_label,f_text])
[9141]149
[9452]150    if getattr(studentview.context, 'certcode', None):
[10250]151        if not 'certificate' in omit_fields:
[10261]152            f_label = trans(_('Study Course:'), lang)
[10250]153            f_label = Paragraph(f_label, ENTRY1_STYLE)
154            f_text = formatted_text(
[10650]155                studentview.context['studycourse'].certificate.longtitle)
[10250]156            f_text = Paragraph(f_text, ENTRY1_STYLE)
[11550]157            data_middle.append([f_label,f_text])
[10250]158        if not 'department' in omit_fields:
[10261]159            f_label = trans(_('Department:'), lang)
[10250]160            f_label = Paragraph(f_label, ENTRY1_STYLE)
161            f_text = formatted_text(
162                studentview.context[
[10650]163                'studycourse'].certificate.__parent__.__parent__.longtitle,
[10250]164                )
165            f_text = Paragraph(f_text, ENTRY1_STYLE)
[11550]166            data_middle.append([f_label,f_text])
[10250]167        if not 'faculty' in omit_fields:
[10261]168            f_label = trans(_('Faculty:'), lang)
[10250]169            f_label = Paragraph(f_label, ENTRY1_STYLE)
170            f_text = formatted_text(
171                studentview.context[
[10650]172                'studycourse'].certificate.__parent__.__parent__.__parent__.longtitle,
[10250]173                )
174            f_text = Paragraph(f_text, ENTRY1_STYLE)
[11550]175            data_middle.append([f_label,f_text])
[10688]176        if not 'current_mode' in omit_fields:
177            studymodes_dict = getUtility(IKofaUtils).STUDY_MODES_DICT
[11535]178            sm = studymodes_dict[studentview.context.current_mode]
[10688]179            f_label = trans(_('Study Mode:'), lang)
180            f_label = Paragraph(f_label, ENTRY1_STYLE)
181            f_text = formatted_text(sm)
182            f_text = Paragraph(f_text, ENTRY1_STYLE)
[11550]183            data_middle.append([f_label,f_text])
[10250]184        if not 'entry_session' in omit_fields:
[10261]185            f_label = trans(_('Entry Session:'), lang)
[10250]186            f_label = Paragraph(f_label, ENTRY1_STYLE)
[11535]187            entry_session = studentview.context.entry_session
[10250]188            entry_session = academic_sessions_vocab.getTerm(entry_session).title
189            f_text = formatted_text(entry_session)
190            f_text = Paragraph(f_text, ENTRY1_STYLE)
[11550]191            data_middle.append([f_label,f_text])
[11535]192        # Requested by Uniben, does not really make sense
193        if not 'current_level' in omit_fields:
194            f_label = trans(_('Current Level:'), lang)
195            f_label = Paragraph(f_label, ENTRY1_STYLE)
196            current_level = studentview.context['studycourse'].current_level
197            studylevelsource = StudyLevelSource().factory
198            current_level = studylevelsource.getTitle(
199                studentview.context, current_level)
200            f_text = formatted_text(current_level)
201            f_text = Paragraph(f_text, ENTRY1_STYLE)
[11550]202            data_middle.append([f_label,f_text])
[10256]203        if not 'date_of_birth' in omit_fields:
[10261]204            f_label = trans(_('Date of Birth:'), lang)
[10256]205            f_label = Paragraph(f_label, ENTRY1_STYLE)
206            date_of_birth = studentview.context.date_of_birth
207            tz = getUtility(IKofaUtils).tzinfo
208            date_of_birth = to_timezone(date_of_birth, tz)
209            if date_of_birth is not None:
210                date_of_birth = date_of_birth.strftime("%d/%m/%Y")
211            f_text = formatted_text(date_of_birth)
212            f_text = Paragraph(f_text, ENTRY1_STYLE)
[11550]213            data_middle.append([f_label,f_text])
[9141]214
[14292]215    if no_passport:
[14294]216        table = Table(data_middle,style=SLIP_STYLE)
[14292]217        table.hAlign = 'LEFT'
218        return table
219
[11550]220    # append QR code to the right
221    if slipname:
222        url = studentview.url(context, slipname)
223        data_right = [[get_qrcode(url, width=70.0)]]
224        table_right = Table(data_right,style=SLIP_STYLE)
225    else:
226        table_right = None
227
[7318]228    table_left = Table(data_left,style=SLIP_STYLE)
[11550]229    table_middle = Table(data_middle,style=SLIP_STYLE, colWidths=[5*cm, 5*cm])
230    table = Table([[table_left, table_middle, table_right],],style=SLIP_STYLE)
[7019]231    return table
232
[10261]233def render_table_data(tableheader, tabledata, lang='en'):
[7318]234    """Render children table for an existing frame.
235    """
[7304]236    data = []
[7318]237    #data.append([Spacer(1, 12)])
[7304]238    line = []
239    style = getSampleStyleSheet()
240    for element in tableheader:
[10261]241        field = '<strong>%s</strong>' % formatted_text(element[0], lang=lang)
[7310]242        field = Paragraph(field, style["Normal"])
[7304]243        line.append(field)
244    data.append(line)
245    for ticket in tabledata:
246        line = []
247        for element in tableheader:
[7511]248              field = formatted_text(getattr(ticket,element[1],u' '))
[7318]249              field = Paragraph(field, style["Normal"])
[7304]250              line.append(field)
251        data.append(line)
[7310]252    table = Table(data,colWidths=[
[7318]253        element[2]*cm for element in tableheader], style=CONTENT_STYLE)
[7304]254    return table
255
[10261]256def render_transcript_data(view, tableheader, levels_data, lang='en'):
[10250]257    """Render children table for an existing frame.
258    """
259    data = []
260    style = getSampleStyleSheet()
[14473]261    format_float = getUtility(IKofaUtils).format_float
[10250]262    for level in levels_data:
263        level_obj = level['level']
[10251]264        tickets = level['tickets_1'] + level['tickets_2'] + level['tickets_3']
265        headerline = []
266        tabledata = []
[15203]267        if 'evel' in view.level_dict.get('ticket.level', str(level_obj.level)):
268            subheader = '%s %s, %s' % (
269                trans(_('Session'), lang),
270                view.session_dict[level_obj.level_session],
271                view.level_dict.get('ticket.level', str(level_obj.level)))
272        else:
273            subheader = '%s %s, %s %s' % (
274                trans(_('Session'), lang),
275                view.session_dict[level_obj.level_session],
276                trans(_('Level'), lang),
[15212]277                view.level_dict.get(level_obj.level, str(level_obj.level)))
[10250]278        data.append(Paragraph(subheader, HEADING_STYLE))
279        for element in tableheader:
280            field = '<strong>%s</strong>' % formatted_text(element[0])
281            field = Paragraph(field, style["Normal"])
[10251]282            headerline.append(field)
283        tabledata.append(headerline)
[10250]284        for ticket in tickets:
[10251]285            ticketline = []
[10250]286            for element in tableheader:
287                  field = formatted_text(getattr(ticket,element[1],u' '))
288                  field = Paragraph(field, style["Normal"])
[10251]289                  ticketline.append(field)
290            tabledata.append(ticketline)
[10250]291        table = Table(tabledata,colWidths=[
292            element[2]*cm for element in tableheader], style=CONTENT_STYLE)
293        data.append(table)
[14473]294        sgpa = format_float(level['sgpa'], 2)
295        sgpa = '%s: %s' % (trans('Sessional GPA (rectified)', lang), sgpa)
296        #sgpa = '%s: %.2f' % (trans('Sessional GPA (rectified)', lang), level['sgpa'])
[10261]297        data.append(Paragraph(sgpa, style["Normal"]))
[15333]298        if getattr(level_obj, 'transcript_remark', None):
[15331]299            remark = '%s: %s' % (
[15333]300                trans('Transcript Remark', lang),
301                getattr(level_obj, 'transcript_remark'))
[15331]302            data.append(Paragraph(remark, style["Normal"]))
[10250]303    return data
304
[8112]305def docs_as_flowables(view, lang='en'):
306    """Create reportlab flowables out of scanned docs.
307    """
308    # XXX: fix circular import problem
[12448]309    from waeup.kofa.browser.fileviewlets import FileManager
[8112]310    from waeup.kofa.browser import DEFAULT_IMAGE_PATH
311    style = getSampleStyleSheet()
312    data = []
[7318]313
[8112]314    # Collect viewlets
315    fm = FileManager(view.context, view.request, view)
316    fm.update()
317    if fm.viewlets:
318        sc_translation = trans(_('Scanned Documents'), lang)
[9910]319        data.append(Paragraph(sc_translation, HEADING_STYLE))
[8112]320        # Insert list of scanned documents
321        table_data = []
322        for viewlet in fm.viewlets:
[10020]323            if viewlet.file_exists:
324                # Show viewlet only if file exists
325                f_label = Paragraph(trans(viewlet.label, lang), ENTRY1_STYLE)
326                img_path = getattr(getUtility(IExtFileStore).getFileByContext(
327                    view.context, attr=viewlet.download_name), 'name', None)
328                #f_text = Paragraph(trans(_('(not provided)'),lang), ENTRY1_STYLE)
329                if img_path is None:
330                    pass
331                elif not img_path[-4:] in ('.jpg', '.JPG'):
332                    # reportlab requires jpg images, I think.
333                    f_text = Paragraph('%s (not displayable)' % (
334                        viewlet.title,), ENTRY1_STYLE)
335                else:
336                    f_text = Image(img_path, width=2*cm, height=1*cm, kind='bound')
337                table_data.append([f_label, f_text])
[8112]338        if table_data:
339            # safety belt; empty tables lead to problems.
340            data.append(Table(table_data, style=SLIP_STYLE))
341    return data
342
[7150]343class StudentsUtils(grok.GlobalUtility):
344    """A collection of methods subject to customization.
345    """
346    grok.implements(IStudentsUtils)
[7019]347
[8268]348    def getReturningData(self, student):
[9005]349        """ Define what happens after school fee payment
[7841]350        depending on the student's senate verdict.
351        In the base configuration current level is always increased
352        by 100 no matter which verdict has been assigned.
353        """
[8268]354        new_level = student['studycourse'].current_level + 100
355        new_session = student['studycourse'].current_session + 1
356        return new_session, new_level
357
358    def setReturningData(self, student):
[9005]359        """ Define what happens after school fee payment
360        depending on the student's senate verdict.
[13124]361        This method folllows the same algorithm as `getReturningData` but
[9005]362        it also sets the new values.
[8268]363        """
364        new_session, new_level = self.getReturningData(student)
[9922]365        try:
366            student['studycourse'].current_level = new_level
367        except ConstraintNotSatisfied:
368            # Do not change level if level exceeds the
369            # certificate's end_level.
370            pass
[8268]371        student['studycourse'].current_session = new_session
[7615]372        verdict = student['studycourse'].current_verdict
[8820]373        student['studycourse'].current_verdict = '0'
[7615]374        student['studycourse'].previous_verdict = verdict
375        return
376
[9519]377    def _getSessionConfiguration(self, session):
378        try:
379            return grok.getSite()['configuration'][str(session)]
380        except KeyError:
381            return None
382
[11451]383    def _isPaymentDisabled(self, p_session, category, student):
384        academic_session = self._getSessionConfiguration(p_session)
[11452]385        if category == 'schoolfee' and \
386            'sf_all' in academic_session.payment_disabled:
[11451]387            return True
388        return False
389
[11641]390    def samePaymentMade(self, student, category, p_item, p_session):
391        for key in student['payments'].keys():
392            ticket = student['payments'][key]
393            if ticket.p_state == 'paid' and\
394               ticket.p_category == category and \
395               ticket.p_item == p_item and \
396               ticket.p_session == p_session:
397                  return True
398        return False
399
[9148]400    def setPaymentDetails(self, category, student,
[9151]401            previous_session, previous_level):
[13124]402        """Create a payment ticket and set the payment data of a
[13040]403        student for the payment category specified.
[7841]404        """
[8595]405        p_item = u''
406        amount = 0.0
[9148]407        if previous_session:
[9517]408            if previous_session < student['studycourse'].entry_session:
409                return _('The previous session must not fall below '
410                         'your entry session.'), None
411            if category == 'schoolfee':
412                # School fee is always paid for the following session
413                if previous_session > student['studycourse'].current_session:
414                    return _('This is not a previous session.'), None
415            else:
416                if previous_session > student['studycourse'].current_session - 1:
417                    return _('This is not a previous session.'), None
[9148]418            p_session = previous_session
419            p_level = previous_level
420            p_current = False
421        else:
422            p_session = student['studycourse'].current_session
423            p_level = student['studycourse'].current_level
424            p_current = True
[9519]425        academic_session = self._getSessionConfiguration(p_session)
426        if academic_session == None:
[8595]427            return _(u'Session configuration object is not available.'), None
[9521]428        # Determine fee.
[7150]429        if category == 'schoolfee':
[8595]430            try:
[8596]431                certificate = student['studycourse'].certificate
432                p_item = certificate.code
[8595]433            except (AttributeError, TypeError):
434                return _('Study course data are incomplete.'), None
[9148]435            if previous_session:
[9916]436                # Students can pay for previous sessions in all
437                # workflow states.  Fresh students are excluded by the
438                # update method of the PreviousPaymentAddFormPage.
[9148]439                if previous_level == 100:
440                    amount = getattr(certificate, 'school_fee_1', 0.0)
441                else:
442                    amount = getattr(certificate, 'school_fee_2', 0.0)
443            else:
444                if student.state == CLEARED:
445                    amount = getattr(certificate, 'school_fee_1', 0.0)
446                elif student.state == RETURNING:
[9916]447                    # In case of returning school fee payment the
448                    # payment session and level contain the values of
449                    # the session the student has paid for. Payment
450                    # session is always next session.
[9148]451                    p_session, p_level = self.getReturningData(student)
[9519]452                    academic_session = self._getSessionConfiguration(p_session)
453                    if academic_session == None:
[9916]454                        return _(
455                            u'Session configuration object is not available.'
456                            ), None
[9148]457                    amount = getattr(certificate, 'school_fee_2', 0.0)
458                elif student.is_postgrad and student.state == PAID:
[9916]459                    # Returning postgraduate students also pay for the
460                    # next session but their level always remains the
461                    # same.
[9148]462                    p_session += 1
[9519]463                    academic_session = self._getSessionConfiguration(p_session)
464                    if academic_session == None:
[9916]465                        return _(
466                            u'Session configuration object is not available.'
467                            ), None
[9148]468                    amount = getattr(certificate, 'school_fee_2', 0.0)
[7150]469        elif category == 'clearance':
[9178]470            try:
471                p_item = student['studycourse'].certificate.code
472            except (AttributeError, TypeError):
473                return _('Study course data are incomplete.'), None
[8595]474            amount = academic_session.clearance_fee
[7150]475        elif category == 'bed_allocation':
[8595]476            p_item = self.getAccommodationDetails(student)['bt']
477            amount = academic_session.booking_fee
[9423]478        elif category == 'hostel_maintenance':
[10681]479            amount = 0.0
[9429]480            bedticket = student['accommodation'].get(
481                str(student.current_session), None)
[13501]482            if bedticket is not None and bedticket.bed is not None:
[9429]483                p_item = bedticket.bed_coordinates
[10681]484                if bedticket.bed.__parent__.maint_fee > 0:
485                    amount = bedticket.bed.__parent__.maint_fee
486                else:
487                    # fallback
488                    amount = academic_session.maint_fee
[9429]489            else:
[13505]490                return _(u'No bed allocated.'), None
[10449]491        elif category == 'transcript':
492            amount = academic_session.transcript_fee
[13574]493        elif category == 'transfer':
494            amount = academic_session.transfer_fee
[13031]495        elif category == 'late_registration':
496            amount = academic_session.late_registration_fee
[8595]497        if amount in (0.0, None):
[9517]498            return _('Amount could not be determined.'), None
[11641]499        if self.samePaymentMade(student, category, p_item, p_session):
500            return _('This type of payment has already been made.'), None
[11451]501        if self._isPaymentDisabled(p_session, category, student):
[13797]502            return _('This category of payments has been disabled.'), None
[8708]503        payment = createObject(u'waeup.StudentOnlinePayment')
[8951]504        timestamp = ("%d" % int(time()*10000))[1:]
[8595]505        payment.p_id = "p%s" % timestamp
506        payment.p_category = category
507        payment.p_item = p_item
508        payment.p_session = p_session
509        payment.p_level = p_level
[9148]510        payment.p_current = p_current
[8595]511        payment.amount_auth = amount
512        return None, payment
[7019]513
[9868]514    def setBalanceDetails(self, category, student,
[9864]515            balance_session, balance_level, balance_amount):
[13124]516        """Create a balance payment ticket and set the payment data
517        as selected by the student.
[9864]518        """
[9868]519        p_item = u'Balance'
[9864]520        p_session = balance_session
521        p_level = balance_level
522        p_current = False
523        amount = balance_amount
524        academic_session = self._getSessionConfiguration(p_session)
525        if academic_session == None:
526            return _(u'Session configuration object is not available.'), None
[9874]527        if amount in (0.0, None) or amount < 0:
528            return _('Amount must be greater than 0.'), None
[9864]529        payment = createObject(u'waeup.StudentOnlinePayment')
530        timestamp = ("%d" % int(time()*10000))[1:]
531        payment.p_id = "p%s" % timestamp
[9868]532        payment.p_category = category
[9864]533        payment.p_item = p_item
534        payment.p_session = p_session
535        payment.p_level = p_level
536        payment.p_current = p_current
537        payment.amount_auth = amount
538        return None, payment
539
[12896]540    def increaseMatricInteger(self, student):
541        """Increase counter for matric numbers.
542        This counter can be a centrally stored attribute or an attribute of
543        faculties, departments or certificates. In the base package the counter
[13124]544        is as an attribute of the site configuration container.
[12896]545        """
546        grok.getSite()['configuration'].next_matric_integer += 1
547        return
548
[11595]549    def constructMatricNumber(self, student):
[12896]550        """Fetch the matric number counter which fits the student and
551        construct the new matric number of the student.
[12902]552        In the base package the counter is returned which is as an attribute
[13124]553        of the site configuration container.
[12896]554        """
[11595]555        next_integer = grok.getSite()['configuration'].next_matric_integer
556        if next_integer == 0:
[11619]557            return _('Matriculation number cannot be set.'), None
558        return None, unicode(next_integer)
[11589]559
560    def setMatricNumber(self, student):
[13124]561        """Set matriculation number of student. If the student's matric number
562        is unset a new matric number is
[12896]563        constructed according to the matriculation number construction rules
[13124]564        defined in the `constructMatricNumber` method. The new matric number is
[12896]565        set, the students catalog updated. The corresponding matric number
566        counter is increased by one.
[11589]567
568        This method is tested but not used in the base package. It can
569        be used in custom packages by adding respective views
[13124]570        and by customizing `increaseMatricInteger` and `constructMatricNumber`
[12896]571        according to the university's matriculation number construction rules.
[11589]572
[12896]573        The method can be disabled by setting the counter to zero.
[11589]574        """
575        if student.matric_number is not None:
576            return _('Matriculation number already set.'), None
[11590]577        if student.certcode is None:
578            return _('No certificate assigned.'), None
[11619]579        error, matric_number = self.constructMatricNumber(student)
580        if error:
581            return error, None
[11589]582        try:
[11592]583            student.matric_number = matric_number
[11589]584        except MatNumNotInSource:
[13224]585            return _('Matriculation number %s exists.' % matric_number), None
[11589]586        notify(grok.ObjectModifiedEvent(student))
[12896]587        self.increaseMatricInteger(student)
[11595]588        return None, matric_number
[11589]589
[7186]590    def getAccommodationDetails(self, student):
[9219]591        """Determine the accommodation data of a student.
[7841]592        """
[7150]593        d = {}
594        d['error'] = u''
[8685]595        hostels = grok.getSite()['hostels']
596        d['booking_session'] = hostels.accommodation_session
597        d['allowed_states'] = hostels.accommodation_states
[8688]598        d['startdate'] = hostels.startdate
599        d['enddate'] = hostels.enddate
600        d['expired'] = hostels.expired
[7150]601        # Determine bed type
602        studycourse = student['studycourse']
[7369]603        certificate = getattr(studycourse,'certificate',None)
[7150]604        entry_session = studycourse.entry_session
605        current_level = studycourse.current_level
[9187]606        if None in (entry_session, current_level, certificate):
607            return d
[7369]608        end_level = certificate.end_level
[9148]609        if current_level == 10:
610            bt = 'pr'
611        elif entry_session == grok.getSite()['hostels'].accommodation_session:
[7150]612            bt = 'fr'
613        elif current_level >= end_level:
614            bt = 'fi'
615        else:
616            bt = 're'
617        if student.sex == 'f':
618            sex = 'female'
619        else:
620            sex = 'male'
621        special_handling = 'regular'
622        d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
623        return d
[7019]624
[13247]625    def checkAccommodationRequirements(self, student, acc_details):
626        if acc_details.get('expired', False):
627            startdate = acc_details.get('startdate')
628            enddate = acc_details.get('enddate')
629            if startdate and enddate:
630                tz = getUtility(IKofaUtils).tzinfo
631                startdate = to_timezone(
632                    startdate, tz).strftime("%d/%m/%Y %H:%M:%S")
633                enddate = to_timezone(
634                    enddate, tz).strftime("%d/%m/%Y %H:%M:%S")
635                return _("Outside booking period: ${a} - ${b}",
636                         mapping = {'a': startdate, 'b': enddate})
637            else:
638                return _("Outside booking period.")
639        if not acc_details.get('bt'):
640            return _("Your data are incomplete.")
641        if not student.state in acc_details['allowed_states']:
642            return _("You are in the wrong registration state.")
643        if student['studycourse'].current_session != acc_details[
644            'booking_session']:
645            return _('Your current session does not '
646                     'match accommodation session.')
[15306]647        bsession = str(acc_details['booking_session'])
648        if bsession in student['accommodation'].keys() \
649            and not 'booking expired' in \
650            student['accommodation'][bsession].bed_coordinates:
[13247]651            return _('You already booked a bed space in '
652                     'current accommodation session.')
653        return
654
[13457]655    def selectBed(self, available_beds, desired_hostel=None):
656        """Select a bed from a filtered list of available beds.
657        In the base configuration beds are sorted by the sort id
658        of the hostel and the bed number. The first bed found in
659        this sorted list is taken.
[7841]660        """
[13457]661        sorted_beds = sorted(available_beds,
662                key=lambda bed: 1000 * bed.__parent__.sort_id + bed.bed_number)
[15312]663        if desired_hostel and desired_hostel != 'no':
[13457]664            # Filter desired hostel beds
665            filtered_beds = [bed for bed in sorted_beds
666                             if bed.bed_id.startswith(desired_hostel)]
667            if not filtered_beds:
668                return
669            return filtered_beds[0]
670        return sorted_beds[0]
[7150]671
[9981]672    def _admissionText(self, student, portal_language):
[9979]673        inst_name = grok.getSite()['configuration'].name
674        text = trans(_(
675            'This is to inform you that you have been provisionally'
676            ' admitted into ${a} as follows:', mapping = {'a': inst_name}),
677            portal_language)
678        return text
679
[10686]680    def renderPDFAdmissionLetter(self, view, student=None, omit_fields=(),
681                                 pre_text=None, post_text=None,):
[9191]682        """Render pdf admission letter.
683        """
684        if student is None:
685            return
686        style = getSampleStyleSheet()
[9949]687        creator = self.getPDFCreator(student)
[9979]688        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
[9191]689        data = []
690        doc_title = view.label
691        author = '%s (%s)' % (view.request.principal.title,
692                              view.request.principal.id)
[9944]693        footer_text = view.label.split('\n')
694        if len(footer_text) > 1:
695            # We can add a department in first line
696            footer_text = footer_text[1]
697        else:
698            # Only the first line is used for the footer
699            footer_text = footer_text[0]
[9191]700        if getattr(student, 'student_id', None) is not None:
701            footer_text = "%s - %s - " % (student.student_id, footer_text)
702
[10702]703        # Text before student data
[10686]704        if pre_text is None:
705            html = format_html(self._admissionText(student, portal_language))
706        else:
707            html = format_html(pre_text)
[11875]708        if html:
709            data.append(Paragraph(html, NOTE_STYLE))
710            data.append(Spacer(1, 20))
[9191]711
712        # Student data
[11550]713        data.append(render_student_data(view, student,
714                    omit_fields, lang=portal_language,
715                    slipname='admission_slip.pdf'))
[9191]716
[10702]717        # Text after student data
[9191]718        data.append(Spacer(1, 20))
[10686]719        if post_text is None:
720            datelist = student.history.messages[0].split()[0].split('-')
721            creation_date = u'%s/%s/%s' % (datelist[2], datelist[1], datelist[0])
[10702]722            post_text = trans(_(
[10686]723                'Your Kofa student record was created on ${a}.',
724                mapping = {'a': creation_date}),
725                portal_language)
[10702]726        #html = format_html(post_text)
727        #data.append(Paragraph(html, NOTE_STYLE))
[9191]728
729        # Create pdf stream
730        view.response.setHeader(
731            'Content-Type', 'application/pdf')
732        pdf_stream = creator.create_pdf(
733            data, None, doc_title, author=author, footer=footer_text,
[10702]734            note=post_text)
[9191]735        return pdf_stream
736
[9949]737    def getPDFCreator(self, context):
738        """Get a pdf creator suitable for `context`.
739        The default implementation always returns the default creator.
740        """
741        return getUtility(IPDFCreator)
742
[8257]743    def renderPDF(self, view, filename='slip.pdf', student=None,
[9906]744                  studentview=None,
[10439]745                  tableheader=[], tabledata=[],
[9555]746                  note=None, signatures=None, sigs_in_footer=(),
[10250]747                  show_scans=True, topMargin=1.5,
748                  omit_fields=()):
[14151]749        """Render pdf slips for various pages (also some pages
750        in the applicants module).
[7841]751        """
[10261]752        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
[9916]753        # XXX: tell what the different parameters mean
[8112]754        style = getSampleStyleSheet()
[9949]755        creator = self.getPDFCreator(student)
[8112]756        data = []
757        doc_title = view.label
758        author = '%s (%s)' % (view.request.principal.title,
759                              view.request.principal.id)
[9913]760        footer_text = view.label.split('\n')
[13304]761        if len(footer_text) > 1:
762            # We can add a department in first line, second line is used
[9913]763            footer_text = footer_text[1]
764        else:
[9917]765            # Only the first line is used for the footer
[9913]766            footer_text = footer_text[0]
[7714]767        if getattr(student, 'student_id', None) is not None:
[7310]768            footer_text = "%s - %s - " % (student.student_id, footer_text)
[7150]769
[7318]770        # Insert student data table
[7310]771        if student is not None:
[8112]772            bd_translation = trans(_('Base Data'), portal_language)
[9910]773            data.append(Paragraph(bd_translation, HEADING_STYLE))
[10261]774            data.append(render_student_data(
[11550]775                studentview, view.context, omit_fields, lang=portal_language,
776                slipname=filename))
[7304]777
[7318]778        # Insert widgets
[9191]779        if view.form_fields:
[9910]780            data.append(Paragraph(view.title, HEADING_STYLE))
[9191]781            separators = getattr(self, 'SEPARATORS_DICT', {})
782            table = creator.getWidgetsTable(
783                view.form_fields, view.context, None, lang=portal_language,
784                separators=separators)
785            data.append(table)
[7318]786
[8112]787        # Insert scanned docs
[9550]788        if show_scans:
789            data.extend(docs_as_flowables(view, portal_language))
[7318]790
[9452]791        # Insert history
[15337]792        if filename == 'clearance_slip.pdf':
[9452]793            hist_translation = trans(_('Workflow History'), portal_language)
[9910]794            data.append(Paragraph(hist_translation, HEADING_STYLE))
[9452]795            data.extend(creator.fromStringList(student.history.messages))
796
[10438]797        # Insert content tables (optionally on second page)
[10439]798        if hasattr(view, 'tabletitle'):
799            for i in range(len(view.tabletitle)):
800                if tabledata[i] and tableheader[i]:
801                    #data.append(PageBreak())
802                    #data.append(Spacer(1, 20))
803                    data.append(Paragraph(view.tabletitle[i], HEADING_STYLE))
804                    data.append(Spacer(1, 8))
805                    contenttable = render_table_data(tableheader[i],tabledata[i])
806                    data.append(contenttable)
[7318]807
[9010]808        # Insert signatures
[9965]809        # XXX: We are using only sigs_in_footer in waeup.kofa, so we
810        # do not have a test for the following lines.
[9555]811        if signatures and not sigs_in_footer:
[9010]812            data.append(Spacer(1, 20))
[9966]813            # Render one signature table per signature to
814            # get date and signature in line.
815            for signature in signatures:
816                signaturetables = get_signature_tables(signature)
817                data.append(signaturetables[0])
[9010]818
[7150]819        view.response.setHeader(
820            'Content-Type', 'application/pdf')
[8112]821        try:
822            pdf_stream = creator.create_pdf(
[8257]823                data, None, doc_title, author=author, footer=footer_text,
[9948]824                note=note, sigs_in_footer=sigs_in_footer, topMargin=topMargin)
[8112]825        except IOError:
826            view.flash('Error in image file.')
827            return view.redirect(view.url(view.context))
[14256]828        except LayoutError, err:
829            view.flash(
830                'PDF file could not be created. Reportlab error message: %s'
831                % escape(err.message),
832                type="danger")
833            return view.redirect(view.url(view.context))
[8112]834        return pdf_stream
[7620]835
[14915]836    def GPABoundaries(self, faccode=None, depcode=None, certcode=None):
[14914]837        return ((1, 'Fail'),
838               (1.5, 'Pass'),
839               (2.4, '3rd Class'),
840               (3.5, '2nd Class Lower'),
841               (4.5, '2nd Class Upper'),
842               (5, '1st Class'))
[10576]843
[14461]844    def getClassFromCGPA(self, gpa, student):
845        """Determine the class of degree. In some custom packages
846        this class depends on e.g. the entry session of the student. In the
847        base package, it does not.
848        """
[14914]849        if gpa < self.GPABoundaries()[0][0]:
850            return 0, self.GPABoundaries()[0][1]
851        if gpa < self.GPABoundaries()[1][0]:
852            return 1, self.GPABoundaries()[1][1]
853        if gpa < self.GPABoundaries()[2][0]:
854            return 2, self.GPABoundaries()[2][1]
855        if gpa < self.GPABoundaries()[3][0]:
856            return 3, self.GPABoundaries()[3][1]
857        if gpa < self.GPABoundaries()[4][0]:
858            return 4, self.GPABoundaries()[4][1]
859        if gpa <= self.GPABoundaries()[5][0]:
860            return 5, self.GPABoundaries()[5][1]
[15102]861        return
[10445]862
[14159]863    def getDegreeClassNumber(self, level_obj):
864        """Get degree class number (used for SessionResultsPresentation
[14157]865        reports).
866        """
[14410]867        if level_obj.gpa_params[1] == 0:
868            # No credits weighted
869            return 6
[14461]870        return self.getClassFromCGPA(
871            level_obj.cumulative_params[0], level_obj.student)[0]
[14157]872
[15163]873    def _saveTranscriptPDF(self, student, transcript):
874        """Create a transcript PDF file and store it in student folder.
875        """
876        file_store = getUtility(IExtFileStore)
877        file_id = IFileStoreNameChooser(student).chooseName(
878            attr="final_transcript.pdf")
879        file_store.createFile(file_id, StringIO(transcript))
880        return
881
[10250]882    def renderPDFTranscript(self, view, filename='transcript.pdf',
883                  student=None,
884                  studentview=None,
[15163]885                  note=None,
886                  signatures=(),
887                  sigs_in_footer=(),
888                  digital_sigs=(),
[10250]889                  show_scans=True, topMargin=1.5,
890                  omit_fields=(),
[14292]891                  tableheader=None,
[15163]892                  no_passport=False,
893                  save_file=False):
[14583]894        """Render pdf slip of a transcripts.
[10250]895        """
[10261]896        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
[10250]897        # XXX: tell what the different parameters mean
898        style = getSampleStyleSheet()
899        creator = self.getPDFCreator(student)
900        data = []
901        doc_title = view.label
902        author = '%s (%s)' % (view.request.principal.title,
903                              view.request.principal.id)
904        footer_text = view.label.split('\n')
905        if len(footer_text) > 2:
906            # We can add a department in first line
907            footer_text = footer_text[1]
908        else:
909            # Only the first line is used for the footer
910            footer_text = footer_text[0]
911        if getattr(student, 'student_id', None) is not None:
912            footer_text = "%s - %s - " % (student.student_id, footer_text)
913
914        # Insert student data table
915        if student is not None:
916            #bd_translation = trans(_('Base Data'), portal_language)
917            #data.append(Paragraph(bd_translation, HEADING_STYLE))
[10261]918            data.append(render_student_data(
[11550]919                studentview, view.context,
920                omit_fields, lang=portal_language,
[14292]921                slipname=filename,
922                no_passport=no_passport))
[10250]923
924        transcript_data = view.context.getTranscriptData()
925        levels_data = transcript_data[0]
926
927        contextdata = []
[10261]928        f_label = trans(_('Course of Study:'), portal_language)
[10250]929        f_label = Paragraph(f_label, ENTRY1_STYLE)
[10650]930        f_text = formatted_text(view.context.certificate.longtitle)
[10250]931        f_text = Paragraph(f_text, ENTRY1_STYLE)
932        contextdata.append([f_label,f_text])
933
[10261]934        f_label = trans(_('Faculty:'), portal_language)
[10250]935        f_label = Paragraph(f_label, ENTRY1_STYLE)
936        f_text = formatted_text(
[10650]937            view.context.certificate.__parent__.__parent__.__parent__.longtitle)
[10250]938        f_text = Paragraph(f_text, ENTRY1_STYLE)
939        contextdata.append([f_label,f_text])
940
[10261]941        f_label = trans(_('Department:'), portal_language)
[10250]942        f_label = Paragraph(f_label, ENTRY1_STYLE)
943        f_text = formatted_text(
[10650]944            view.context.certificate.__parent__.__parent__.longtitle)
[10250]945        f_text = Paragraph(f_text, ENTRY1_STYLE)
946        contextdata.append([f_label,f_text])
947
[10261]948        f_label = trans(_('Entry Session:'), portal_language)
[10250]949        f_label = Paragraph(f_label, ENTRY1_STYLE)
[10256]950        f_text = formatted_text(
951            view.session_dict.get(view.context.entry_session))
[10250]952        f_text = Paragraph(f_text, ENTRY1_STYLE)
953        contextdata.append([f_label,f_text])
954
[10261]955        f_label = trans(_('Entry Mode:'), portal_language)
[10250]956        f_label = Paragraph(f_label, ENTRY1_STYLE)
[10256]957        f_text = formatted_text(view.studymode_dict.get(
958            view.context.entry_mode))
[10250]959        f_text = Paragraph(f_text, ENTRY1_STYLE)
960        contextdata.append([f_label,f_text])
961
[10262]962        f_label = trans(_('Cumulative GPA:'), portal_language)
[10250]963        f_label = Paragraph(f_label, ENTRY1_STYLE)
[14473]964        format_float = getUtility(IKofaUtils).format_float
965        cgpa = format_float(transcript_data[1], 3)
966        f_text = formatted_text('%s (%s)' % (
967            cgpa, self.getClassFromCGPA(transcript_data[1], student)[1]))
[10250]968        f_text = Paragraph(f_text, ENTRY1_STYLE)
969        contextdata.append([f_label,f_text])
970
971        contexttable = Table(contextdata,style=SLIP_STYLE)
972        data.append(contexttable)
973
974        transcripttables = render_transcript_data(
[10261]975            view, tableheader, levels_data, lang=portal_language)
[10250]976        data.extend(transcripttables)
977
978        # Insert signatures
979        # XXX: We are using only sigs_in_footer in waeup.kofa, so we
980        # do not have a test for the following lines.
981        if signatures and not sigs_in_footer:
982            data.append(Spacer(1, 20))
983            # Render one signature table per signature to
984            # get date and signature in line.
985            for signature in signatures:
986                signaturetables = get_signature_tables(signature)
987                data.append(signaturetables[0])
988
[15163]989        # Insert digital signatures
990        if digital_sigs:
991            data.append(Spacer(1, 20))
992            sigs = digital_sigs.split('\n')
993            for sig in sigs:
994                data.append(Paragraph(sig, NOTE_STYLE))
995
[10250]996        view.response.setHeader(
997            'Content-Type', 'application/pdf')
998        try:
999            pdf_stream = creator.create_pdf(
1000                data, None, doc_title, author=author, footer=footer_text,
1001                note=note, sigs_in_footer=sigs_in_footer, topMargin=topMargin)
1002        except IOError:
[10261]1003            view.flash(_('Error in image file.'))
[10250]1004            return view.redirect(view.url(view.context))
[15163]1005        if save_file:
1006            self._saveTranscriptPDF(student, pdf_stream)
1007            return
[10250]1008        return pdf_stream
1009
[13898]1010    def renderPDFCourseticketsOverview(
[15423]1011            self, view, name, session, data, lecturers, orientation,
[15246]1012            title_length, note):
[14583]1013        """Render pdf slip of course tickets for a lecturer.
1014        """
[15423]1015        filename = '%s_%s_%s_%s.pdf' % (
1016            name, view.context.code, session, view.request.principal.id)
[13898]1017        session = academic_sessions_vocab.getTerm(session).title
[14702]1018        creator = getUtility(IPDFCreator, name=orientation)
[13898]1019        style = getSampleStyleSheet()
[15197]1020        pdf_data = []
1021        pdf_data += [Paragraph(
[14151]1022            translate(_('<b>Lecturer(s): ${a}</b>',
1023                      mapping = {'a':lecturers})), style["Normal"]),]
1024        pdf_data += [Paragraph(
1025            translate(_('<b>Credits: ${a}</b>',
1026                      mapping = {'a':view.context.credits})), style["Normal"]),]
[14314]1027        # Not used in base package.
1028        if data[1]:
1029            pdf_data += [Paragraph(
[14709]1030                translate(_('<b>${a}</b>',
[14314]1031                    mapping = {'a':data[1][0]})), style["Normal"]),]
1032            pdf_data += [Paragraph(
[14709]1033                translate(_('<b>${a}</b>',
[14708]1034                    mapping = {'a':data[1][1]})), style["Normal"]),]
1035
1036            pdf_data += [Paragraph(
1037                translate(_('<b>Total Students: ${a}</b>',
1038                    mapping = {'a':data[1][2]})), style["Normal"]),]
1039            pdf_data += [Paragraph(
[14319]1040                translate(_('<b>Total Pass: ${a} (${b}%)</b>',
[14708]1041                mapping = {'a':data[1][3],'b':data[1][4]})), style["Normal"]),]
[14319]1042            pdf_data += [Paragraph(
1043                translate(_('<b>Total Fail: ${a} (${b}%)</b>',
[14708]1044                mapping = {'a':data[1][5],'b':data[1][6]})), style["Normal"]),]
[13899]1045        pdf_data.append(Spacer(1, 20))
[15246]1046        colWidths = [None] * len(data[0][0])
[15528]1047        pdf_data += [Table(data[0], colWidths=colWidths, style=CONTENT_STYLE,
1048                           repeatRows=1)]
[15234]1049        # Process title if too long
1050        title = " ".join(view.context.title.split())
1051        ct = textwrap.fill(title, title_length)
[15526]1052        ft = "" # title
1053        #if len(textwrap.wrap(title, title_length)) > 1:
1054        #    ft = textwrap.wrap(title, title_length)[0] + ' ...'
[15197]1055        doc_title = translate(_('${a} (${b})\nAcademic Session ${d}',
1056            mapping = {'a':ct,
[14151]1057                       'b':view.context.code,
1058                       'd':session}))
[15423]1059        if name == 'attendance':
1060            doc_title += _('\nAttendance Sheet')
1061        if name == 'coursetickets':
1062            doc_title += _('\nCourse Tickets Overview')
[15526]1063        #footer_title = translate(_('${a} (${b}) - ${d}',
1064        #    mapping = {'a':ft,
1065        #               'b':view.context.code,
1066        #               'd':session}))
1067        footer_title = translate(_('${b} - ${d}',
1068            mapping = {'b':view.context.code,
[14705]1069                       'd':session}))
[13898]1070        author = '%s (%s)' % (view.request.principal.title,
1071                              view.request.principal.id)
1072        view.response.setHeader(
1073            'Content-Type', 'application/pdf')
1074        view.response.setHeader(
1075            'Content-Disposition:', 'attachment; filename="%s' % filename)
1076        pdf_stream = creator.create_pdf(
[15246]1077            pdf_data, None, doc_title, author, footer_title + ' -', note
[13898]1078            )
1079        return pdf_stream
1080
[14584]1081    def warnCreditsOOR(self, studylevel, course=None):
1082        """Return message if credits are out of range. In the base
1083        package only maximum credits is set.
[9830]1084        """
[14582]1085        if course and studylevel.total_credits + course.credits > 50:
[14584]1086            return _('Maximum credits exceeded.')
[14582]1087        elif studylevel.total_credits > 50:
[14584]1088            return _('Maximum credits exceeded.')
[14596]1089        return
[9830]1090
[9987]1091    def getBedCoordinates(self, bedticket):
[13132]1092        """Return descriptive bed coordinates.
[13124]1093        This method can be used to customize the `display_coordinates`
[13132]1094        property method in order to  display a
1095        customary description of the bed space.
[9987]1096        """
1097        return bedticket.bed_coordinates
1098
[11772]1099    def clearance_disabled_message(self, student):
[14583]1100        """Render message if clearance is disabled.
1101        """
[11772]1102        try:
1103            session_config = grok.getSite()[
1104                'configuration'][str(student.current_session)]
1105        except KeyError:
1106            return _('Session configuration object is not available.')
1107        if not session_config.clearance_enabled:
1108            return _('Clearance is disabled for this session.')
1109        return None
1110
[13132]1111    #: A dictionary which maps widget names to headlines. The headline
1112    #: is rendered in forms and on pdf slips above the respective
1113    #: display or input widget. There are no separating headlines
1114    #: in the base package.
[13129]1115    SEPARATORS_DICT = {}
[8410]1116
[13132]1117    #: A tuple containing names of file upload viewlets which are not shown
1118    #: on the `StudentClearanceManageFormPage`. Nothing is being skipped
1119    #: in the base package. This attribute makes only sense, if intermediate
1120    #: custom packages are being used, like we do for all Nigerian portals.
[10021]1121    SKIP_UPLOAD_VIEWLETS = ()
1122
[13132]1123    #: A tuple containing the names of registration states in which changing of
1124    #: passport pictures is allowed.
[13129]1125    PORTRAIT_CHANGE_STATES = (ADMITTED,)
[10706]1126
[12104]1127    #: A tuple containing all exporter names referring to students or
1128    #: subobjects thereof.
1129    STUDENT_EXPORTER_NAMES = ('students', 'studentstudycourses',
1130            'studentstudylevels', 'coursetickets',
[12971]1131            'studentpayments', 'studentunpaidpayments',
[15051]1132            'bedtickets', 'sfpaymentsoverview', 'sessionpaymentsoverview',
[15277]1133            'studylevelsoverview', 'combocard', 'bursary',
1134            'accommodationpayments')
[12104]1135
[12971]1136    #: A tuple containing all exporter names needed for backing
1137    #: up student data
1138    STUDENT_BACKUP_EXPORTER_NAMES = ('students', 'studentstudycourses',
1139            'studentstudylevels', 'coursetickets',
1140            'studentpayments', 'bedtickets')
1141
[8410]1142    #: A prefix used when generating new student ids. Each student id will
[13129]1143    #: start with this string. The default is 'K' for Kofa.
[8410]1144    STUDENT_ID_PREFIX = u'K'
Note: See TracBrowser for help on using the repository browser.