source: main/waeup.fceokene/trunk/src/waeup/fceokene/students/utils.py @ 18364

Last change on this file since 18364 was 18364, checked in by Henrik Bettermann, 4 days ago

New NCE school fees.

  • Property svn:keywords set to Id
File size: 28.6 KB
Line 
1## $Id: utils.py 18364 2026-11-18 15:10:11Z 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##
18import grok
19import random
20import textwrap
21from time import time
22from zope.i18n import translate
23from zope.component import createObject, getUtility
24from reportlab.lib.styles import getSampleStyleSheet
25from reportlab.platypus import Paragraph, Image, Table, Spacer
26from waeup.kofa.interfaces import (
27    CLEARED, RETURNING, PAID, ADMITTED, CLEARANCE, REQUESTED)
28from kofacustom.nigeria.students.utils import NigeriaStudentsUtils
29from waeup.kofa.accesscodes import create_accesscode
30from waeup.kofa.interfaces import CLEARED, RETURNING, academic_sessions_vocab
31from waeup.fceokene.interfaces import MessageFactory as _
32from waeup.kofa.browser.interfaces import IPDFCreator
33from waeup.kofa.students.utils import trans, CONTENT_STYLE
34from waeup.kofa.browser.pdf import (
35    ENTRY1_STYLE, format_html, NOTE_STYLE, HEADING_STYLE,
36    get_signature_tables, get_qrcode)
37
38# Very special school fee configuration, should be moved to
39# a seperate file.
40
41ARTS = ('CRS','ISS','HIS','MUS','ECO','GEO','POL','SOS','CCA','ECU',
42        'THA','GED','GSE','PES','SPC','ENG','FRE','ARB','HAU','IGB',
43        'YOR','NCRS','NISS','NHIS','NMUS','NECO','NGEO','NPOL',
44        'NCCA','NECU','NTHA','NGED','NGSE','NPES','NSPC','NENG',
45        'NFRE','NARB','NHAU','NIGB','NYOR','NSOS')
46
47GATEWAY_AMT = 0.0
48
49class CustomStudentsUtils(NigeriaStudentsUtils):
50    """A collection of customized methods.
51
52    """
53
54    def selectBed(self, available_beds):
55        """Randomly select a bed from the list of available beds.
56        """
57        return random.choice(available_beds)
58
59    def getReturningData(self, student):
60        """ This method defines what happens after school fee payment
61        of returning students depending on the student's senate verdict.
62        """
63        prev_level = student['studycourse'].current_level
64        cur_verdict = student['studycourse'].current_verdict
65        if cur_verdict in ('A','B','L','M','N','Z',):
66            # Successful student
67            new_level = divmod(int(prev_level),100)[0]*100 + 100
68        elif cur_verdict in ('C','O'):
69            # Student on probation
70            new_level = int(prev_level) + 10
71        else:
72            # Student is somehow in an undefined state.
73            # Level has to be set manually.
74            new_level = prev_level
75        if cur_verdict == 'O':
76            new_session = student['studycourse'].current_session
77        else:
78            new_session = student['studycourse'].current_session + 1
79        return new_session, new_level
80
81    #def _nce3PaymentMade(self, student, p_level):
82    #    if len(student['payments']):
83    #        for ticket in student['payments'].values():
84    #            if ticket.p_state in ('paid', 'scholarship', 'waived') and \
85    #                ticket.p_level == p_level and \
86    #                ticket.p_category == 'schoolfee':
87    #                return True
88    #    return False
89
90    def setPaymentDetails(self, category, student,
91            previous_session=None, previous_level=None, combi=[]):
92        """Create Payment object and set the payment data of a student for
93        the payment category specified.
94
95        """
96        details = {}
97        p_item = u''
98        amount = 0.0
99        error = u''
100        if previous_session:
101            return _('Previous session payment not yet implemented.'), None
102        p_session = student['studycourse'].current_session
103        p_level = student['studycourse'].current_level
104        p_current = True
105        academic_session = self._getSessionConfiguration(p_session)
106        if academic_session == None:
107            return _(u'Session configuration object is not available.'), None
108        # Determine fee.
109        if category == 'transfer':
110            amount = academic_session.transfer_fee
111        elif category == 'gown':
112            amount = academic_session.gown_fee
113        elif category == 'bed_allocation':
114            acco_details = self.getAccommodationDetails(student)
115            p_session = acco_details['booking_session']
116            p_item = acco_details['bt']
117            amount = academic_session.booking_fee
118        elif category == 'hostel_maintenance':
119            amount = 0.0
120            booking_session = grok.getSite()['hostels'].accommodation_session
121            bedticket = student['accommodation'].get(str(booking_session), None)
122            if bedticket is not None and bedticket.bed is not None:
123                p_session = booking_session
124                p_item = bedticket.bed_coordinates
125                if bedticket.bed.__parent__.maint_fee > 0:
126                    amount = bedticket.bed.__parent__.maint_fee
127                #if student['studycourse'].current_session < 2022:
128                #    amount = 6100.0
129                #else:
130                #    amount = 10090.0
131            else:
132                return _(u'No bed space allocated.'), None
133            if student.current_mode.endswith('_sw') \
134                or student.current_mode == 'pd_ft':
135                amount *= 0.625
136        elif category == 'clearance':
137            amount = academic_session.clearance_fee
138            try:
139                p_item = student['studycourse'].certificate.code
140            except (AttributeError, TypeError):
141                return _('Study course data are incomplete.'), None
142            if student.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED):
143                return _(u'Acceptance Fee payments not allowed.'), None
144        #elif category == 'third_semester' and student.current_mode == 'nce_ft' \
145        #    and p_level in (300, 310, 320, 400, 410, 420):
146        #    #if not self._nce3PaymentMade(student, p_level):
147        #    #    return _(u'Make NCE 3 school fee payment first.'), None
148        #    no_additional_courses = 0
149        #    courses_level = student['studycourse'].get(str(p_level))
150        #    if courses_level and len(courses_level)> 6:
151        #        no_additional_courses = len(courses_level)-6
152        #        amount = 2000.0 * no_additional_courses
153        elif category == 'reg2sandwich':
154            amount = 40000.0
155        elif category.startswith('schoolfee'):
156            if category == 'schoolfee_pde1':
157                if not student.current_mode.startswith('pd'):
158                    return _('You are not a PDE student.'), None
159                if student.state != CLEARED:
160                        return _('You are not a fresh student.'), None
161            if category == 'schoolfee_ug_new':
162                if not student.current_mode.startswith('ug'):
163                    return _('You are not a UG student.'), None
164                if student.state != CLEARED:
165                        return _('You are not a fresh student.'), None
166            if category == 'schoolfee_ug_ret':
167                if not student.current_mode.startswith('ug'):
168                    return _('You are not a UG student.'), None
169                if student.state != RETURNING:
170                        return _('You are not a returning student.'), None
171            if category == 'schoolfee_third':
172                if not student.current_mode == 'nce_ft' \
173                    or not p_level in (300, 310, 320, 400, 410, 420):
174                    return _('You are not an NCE 3 student.'), None
175            p_item =  student.certcode
176            if not p_item:
177                return _('Study course data are incomplete.'), None
178            if student.state not in (CLEARED, RETURNING):
179                return _('Wrong state.'), None
180            # PDE repeater
181            if student.current_verdict == 'OPDE':
182                amount = 30000
183            # PDE new
184            elif student.current_mode == 'pd_ft' and student.state == CLEARED:
185                amount = 90000
186                if category == 'schoolfee_pde1':
187                    amount = 40000
188            # PDE
189            elif student.current_mode == 'pd_ft':
190                amount = 35300
191
192            #Short Duration ICT Programs
193            elif p_item in ('CCO','DPMTS','DTPGD') and \
194                 student.state == CLEARED:
195                amount = 15000
196            elif p_item in ('ADTPGD','ADPMTS') and \
197                 student.state == CLEARED:
198                amount = 16000
199            elif p_item in ('ADPMTSI','ADTPGDI','DPMTSI','DTPGDI') and \
200                 student.state == CLEARED:
201                amount = 25000
202            elif p_item in ('ADPMTSA','ADTPGDA') and \
203               student.state == CLEARED:
204                amount = 35000
205
206            # new degree programme
207            elif student.faccode == 'SUP':
208                amount = 85500
209
210            # UG
211            elif student.current_mode == 'ug_ft':
212                if category == 'schoolfee_ug_new':
213                    # conditions checked above
214                    amount = 80000
215                elif category == 'schoolfee_ug_ret':
216                    # conditions checked above
217                    amount = 60000
218                elif student.state == CLEARED:
219                    amount = 140000
220                # Introducing repeater fee for 'ug_ft' for 1st time
221                # on 15/03/2016
222                #elif student.current_verdict == 'O':
223                #    amount = 96700
224                else:
225                    amount = 110000
226
227            # NCE
228            elif not student.current_mode.endswith('_sw'):
229                # PRENCE
230                if student.current_level == 10 and student.state == CLEARED:
231                    amount = 25000
232                # NCE I fresh
233                elif student.current_level == 100 and student.state == CLEARED:
234                    amount = 42000
235                    # SIWES Fee
236                    if student.depcode in ('AGE', 'BED', 'FAA', 'HEC', 'CSC', 'MUS') \
237                       or student.certcode in ('NCECHECSC',
238                                               'NCEBIOCSC',
239                                               'NCEPHYCSC',
240                                               'NCEPHECSC',
241                                               'NCETHAMUS',
242                                               'NCEANFMUS',
243                                               'NCEHISMUS',
244                                               'NCEIGBMUS',
245                                               'NCESPCCSC',
246                                               ):
247                        amount += 3000
248                # NCE II
249                elif student.current_level in (100, 110, 120) and \
250                    student.state == RETURNING:
251                    amount = 31500
252                # NCE III third semester
253                elif category == 'schoolfee_third':
254                    amount = 18000
255                # NCE III
256                elif student.current_level in (200, 210, 220):
257                    amount = 29000
258                # NCE III repeater
259                elif student.current_level in (300, 310, 320) and \
260                    student.current_verdict == 'O':
261                    amount = 45000
262                # NCE III spillover
263                elif student.current_level in (300, 310, 320) and \
264                    student.current_verdict == 'B':
265                    amount = 45000
266                # NCE III second spillover
267                elif student.current_level in (400, 410, 420) and \
268                    student.current_verdict == 'B':
269                    amount = 45000
270            else:
271                # NCE I fresh sw
272                if student.current_level == 100 and student.state == CLEARED:
273                    if student.depcode in ARTS:
274                        amount = 23100
275                    else:
276                        amount = 23600
277                # NCE II fresh sw
278                elif student.current_level == 200 and student.state == CLEARED:
279                    if student.depcode in ARTS:
280                        amount = 19000
281                    else:
282                        amount = 19500
283                # NCE II sw
284                elif student.current_level in (100, 110, 120) and \
285                    student.state == RETURNING:
286                    if student.depcode in ARTS:
287                        amount = 19000
288                    else:
289                        amount = 19500
290                # NCE III sw
291                elif student.current_level in (200, 210, 220):
292                    if student.depcode in ARTS:
293                        amount = 21000
294                    else:
295                        amount = 21500
296                # NCE IV sw
297                elif student.current_level in (300, 310, 320):
298                    if student.depcode in ARTS:
299                        amount = 19000
300                    else:
301                        amount = 19500
302                # NCE V sw
303                elif student.current_level in (400, 410, 420):
304                    if student.depcode in ARTS:
305                        amount = 19000
306                    else:
307                        amount = 19500
308                # NCE V spillover sw
309                elif student.current_level in (500, 510, 520) and \
310                    student.current_verdict == 'B':
311                    if student.depcode in ARTS:
312                        amount = 17500
313                    else:
314                        amount = 18000
315                # NCE V second spillover sw
316                elif student.current_level in (600, 610, 620) and \
317                    student.current_verdict == 'B':
318                    if student.depcode in ARTS:
319                        amount = 17500
320                    else:
321                        amount = 18000
322            # NCE student payment can be disabled by
323            # setting the base school fee to -1
324            if academic_session.school_fee_base == -1 and \
325                student.current_mode.startswith('nce'):
326                return _(u'School fee payment is disabled.'), None
327            if student.state == RETURNING:
328                # Override p_session and p_level
329                p_session, p_level = self.getReturningData(student)
330                academic_session = self._getSessionConfiguration(p_session)
331                if academic_session == None:
332                    return _(u'Session configuration object is not available.'), None
333        else:
334            fee_name = category + '_fee'
335            amount = getattr(academic_session, fee_name, 0.0)
336           
337        if amount in (0.0, None):
338            return _(u'Amount could not be determined.'), None
339
340        # Add session and level specific penalty fee.
341        if category == 'schoolfee' and student.current_mode in (
342            'ug_ft', 'de_ft') and student.state != CLEARED:
343            amount += academic_session.penalty_ug_ft
344        elif category == 'schoolfee' and student.current_mode in (
345            'nce_ft',) and student['studycourse'].previous_verdict != 'O':
346            # NCE I fresh
347            if student.current_level == 100 and student.state == CLEARED:
348                amount += academic_session.penalty_nce1_ft
349            # NCE II
350            elif student.current_level in (100, 110, 120) and \
351                student.state == RETURNING:
352                amount += academic_session.penalty_nce2_ft
353            # NCE III (except repeaters and spillovers)
354            elif student.current_level in (200, 210, 220):
355                amount += academic_session.penalty_nce3_ft
356        elif category == 'schoolfee' and student.current_mode in ('nce_sw',
357            'nce_pt') and student['studycourse'].previous_verdict != 'O':
358            # NCE I fresh
359            if student.current_level == 100 and student.state == CLEARED:
360                amount += academic_session.penalty_nce1_pt
361            # NCE II
362            elif student.current_level in (100, 110, 120) and \
363                student.state == RETURNING:
364                amount += academic_session.penalty_nce2_pt
365            # NCE III (except repeaters and spillovers)
366            elif student.current_level in (200, 210, 220):
367                amount += academic_session.penalty_nce3_pt
368        elif category == 'schoolfee' and student.current_mode in ('prence',):
369            amount += academic_session.penalty_prence
370        if self.samePaymentMade(student, category, p_item, p_session):
371            return _('This type of payment has already been made.'), None
372        if self._isPaymentDisabled(p_session, category, student):
373            return _('This category of payments has been disabled.'), None
374        payment = createObject(u'waeup.StudentOnlinePayment')
375        timestamp = ("%d" % int(time()*10000))[1:]
376        payment.p_id = "p%s" % timestamp
377        payment.p_category = category
378        payment.p_item = p_item
379        payment.p_session = p_session
380        payment.p_level = p_level
381        payment.p_current = p_current
382        payment.amount_auth = float(amount) + GATEWAY_AMT
383        return None, payment
384
385    def getAccommodationDetails(self, student):
386        """Determine the accommodation data of a student.
387        """
388        d = {}
389        d['error'] = u''
390        hostels = grok.getSite()['hostels']
391        d['booking_session'] = hostels.accommodation_session
392        d['allowed_states'] = hostels.accommodation_states
393        d['startdate'] = hostels.startdate
394        d['enddate'] = hostels.enddate
395        d['expired'] = hostels.expired
396        # Determine bed type
397        studycourse = student['studycourse']
398        certificate = getattr(studycourse,'certificate',None)
399        current_level = studycourse.current_level
400        if None in (current_level, certificate):
401            return d
402        end_level = certificate.end_level
403        if current_level == 10:
404            bt = 'pr'
405        elif current_level == 100:
406            bt = 'fr'
407        elif current_level >= 300:
408            bt = 'fi'
409        else:
410            bt = 're'
411        if student.sex == 'f':
412            sex = 'female'
413        else:
414            sex = 'male'
415        special_handling = 'regular'
416        if certificate.study_mode == 'ug_ft':
417            special_handling = 'ugft'
418        d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
419        return d
420
421    #def warnCreditsOOR(self, studylevel, course=None):
422    #    """Return message if credits are out of range.
423    #    """
424    #    # adding a course ticket
425    #    if course:
426    #        if course.semester == 1:
427    #            if studylevel.total_credits_s1 + course.credits > 24:
428    #                return _('Maximum credits in 1st semester exceeded.')
429    #        if course.semester == 2:
430    #            if studylevel.total_credits_s2 + course.credits > 24:
431    #                return _('Maximum credits in 2nd semester exceeded.')
432    #    # registering course list
433    #    else:
434    #        if studylevel.total_credits_s1 > 24:
435    #            return _('Maximum credits in 1st semester exceeded.')
436    #        if studylevel.total_credits_s1 < 18:
437    #            return _('Minimum credits in 1st semester not reached.')
438    #        if studylevel.total_credits_s2 > 24:
439    #            return _('Maximum credits in 2nd semester exceeded.')
440    #        if studylevel.total_credits_s2 < 18:
441    #            return _('Minimum credits in 2nd semester not reached.')
442    #    return
443
444    def warnCreditsOOR(self, studylevel, course=None):
445        """Return message if credits are out of range.
446        """
447        # adding a course ticket
448        if course:
449            if studylevel.total_credits + course.credits > 52:
450                return _('Maximum credits exceeded.')
451        # registering course list
452        else:
453            if studylevel.total_credits > 52:
454                return _('Maximum credits exceeded.')
455            if studylevel.__parent__.previous_verdict == 'O':
456                return
457            if studylevel.total_credits_s1 < 18:
458                return _('Minimum credits in 1st semester not reached.')
459            if studylevel.total_credits_s2 < 18:
460                return _('Minimum credits in 2nd semester not reached.')
461        return
462
463    def getPDFCreator(self, context):
464        """Get a pdf creator suitable for `context`.
465
466        The default implementation always returns the default creator.
467        """
468        mode = getattr(context, 'current_mode', None)
469        faccode = getattr(context, 'faccode', None)
470        if (mode and faccode) and mode.startswith('ug') and faccode != 'SUP':
471            return getUtility(IPDFCreator, name='ibadan_pdfcreator')
472        return getUtility(IPDFCreator)
473
474    def _admissionText(self, student, portal_language):
475        if student.current_mode.startswith('ug') and student.faccode != 'SUP':
476            text = trans(_(
477                'With reference to your application for admission into '
478                'Bachelor Degree Programme of the University of Ibadan, '
479                'you have been provisionally admitted into Federal College '
480                'of Education Okene as follows: '),
481                portal_language)
482        #elif student.current_mode.startswith('ug'):
483        #    text = trans(_(
484        #        'With reference to your application for admission into '
485        #        'Bachelor Degree Programme, '
486        #        'you have been provisionally admitted to a full-time '
487        #        'Bachelor of Arts in Education Degree Programme as follows: '),
488        #        portal_language)
489        else:
490            inst_name = grok.getSite()['configuration'].name
491            text = trans(_(
492                'You have been provisionally admitted into Federal College '
493                'of Education Okene as follows: '
494                ),
495                portal_language)
496        return text
497
498    def getBedCoordinates(self, bedticket):
499        """Return bed coordinates.
500
501        Bed coordinates are invisible in FCEOkene.
502        """
503        return _('(see payment slip)')
504
505    def _isPaymentDisabled(self, p_session, category, student):
506        academic_session = self._getSessionConfiguration(p_session)
507        if category == 'schoolfee':
508            if 'sf_all' in academic_session.payment_disabled:
509                return True
510            if 'sf_nce1' in academic_session.payment_disabled and \
511                student.current_level == 100 and student.state == CLEARED and \
512                student.current_mode == 'nce_ft':
513                return True
514        if category == 'clearance':
515            if 'cl_except_ug' in academic_session.payment_disabled and \
516                student.current_mode != 'ug_ft':
517                return True
518        return False
519
520    SEPARATORS_DICT = {
521        'form.fst_sit_fname': _(u'First Sitting Record'),
522        'form.scd_sit_fname': _(u'Second Sitting Record'),
523        #'form.alr_fname': _(u'Advanced Level Record'),
524        'form.hq_type': _(u'Advanced Level Record'),
525        'form.hq2_type': _(u'Second Higher Education Record'),
526        'form.nysc_year': _(u'NYSC Information'),
527        'form.employer': _(u'Employment History'),
528        'form.former_matric': _(u'Former Student'),
529        }
530
531    SKIP_UPLOAD_VIEWLETS = (
532        'higherqualificationresultupload',
533        'secondHigherqualificationresultupload',
534        'certificateupload',
535        'secondcertificateupload',
536        'thirdcertificateupload',
537        'resultstatementupload',
538        'secondrefereeletterupload',
539        'thirdrefereeletterupload',)
540
541    ACCOMMODATION_SPAN = 1
542
543    # FCEOkene prefix
544    STUDENT_ID_PREFIX = u'K'
545
546    def renderPDFCourseticketsOverview(
547            self, view, name, session, data, lecturers, orientation,
548            title_length, note,
549            signatures=(),
550            sigs_in_footer=(),):
551        """Render pdf slip of course tickets for a lecturer.
552        """
553        filename = '%s_%s_%s_%s.pdf' % (
554            name, view.context.code, session, view.request.principal.id)
555        try:
556            session = academic_sessions_vocab.getTerm(session).title
557        except LookupError:
558            session = _('void')
559        creator = getUtility(IPDFCreator, name=orientation)
560        style = getSampleStyleSheet()
561        pdf_data = []
562        pdf_data += [Paragraph(
563            translate(_('<b>Lecturer(s): ${a}</b>',
564                      mapping = {'a':lecturers})), style["Normal"]),]
565        pdf_data += [Paragraph(
566            translate(_('<br /><b>Department: ${a}</b>',
567                      mapping = {'a':view.context.__parent__.__parent__.longtitle})), style["Normal"]),]
568        pdf_data += [Paragraph(
569            translate(_('<br /><b>Credits: ${a}</b>',
570                      mapping = {'a':view.context.credits})), style["Normal"]),]
571        pdf_data += [Paragraph(
572            translate(_('<br /><b>Venue:</b>')), style["Normal"]),]
573        pdf_data += [Paragraph(
574            translate(_('<br /><b>Time:</b>')), style["Normal"]),]
575        # Not used in base package. Requested by AAUE.
576        if data[1]:
577            pdf_data += [Paragraph(
578                translate(_('<b>${a}</b>',
579                    mapping = {'a':data[1][0]})), style["Normal"]),]
580            pdf_data += [Paragraph(
581                translate(_('<b>${a}</b>',
582                    mapping = {'a':data[1][1]})), style["Normal"]),]
583            pdf_data += [Paragraph(
584                translate(_('<b>Total Students: ${a}</b>',
585                    mapping = {'a':data[1][2]})), style["Normal"]),]
586            pdf_data += [Paragraph(
587                translate(_('<b>Total Pass: ${a} (${b}%)</b>',
588                mapping = {'a':data[1][3],'b':data[1][4]})), style["Normal"]),]
589            pdf_data += [Paragraph(
590                translate(_('<b>Total Fail: ${a} (${b}%)</b>',
591                mapping = {'a':data[1][5],'b':data[1][6]})), style["Normal"]),]
592            grade_stats = []
593            for item in sorted(data[1][7].items()):
594                grade_stats.append(('%s=%s' % (item[0], item[1])))
595            grade_stats_string = ', '.join(grade_stats)
596            pdf_data += [Paragraph(
597                translate(_('<b>${a}</b>',
598                mapping = {'a':grade_stats_string})), style["Normal"]),]
599        pdf_data.append(Spacer(1, 20))
600        colWidths = [None] * len(data[0][0])
601        pdf_data += [Table(data[0], colWidths=colWidths, style=CONTENT_STYLE,
602                           repeatRows=1)]
603        # Process title if too long
604        title = " ".join(view.context.title.split())
605        ct = textwrap.fill(title, title_length)
606        ft = "" # title
607        #if len(textwrap.wrap(title, title_length)) > 1:
608        #    ft = textwrap.wrap(title, title_length)[0] + ' ...'
609        doc_title = translate(_('${a} (${b})\nAcademic Session ${d}',
610            mapping = {'a':ct,
611                       'b':view.context.code,
612                       'd':session}))
613        if name == 'attendance':
614            doc_title += '\n' + translate(_('Attendance Sheet'))
615        if name == 'coursetickets':
616            doc_title += '\n' + translate(_('Course Tickets Overview'))
617        if name == 'marksheet':
618            # requested by Uniben
619            dt = view.context.__parent__.__parent__.longtitle
620            #doc_title = '%s\n%s (%s)\nMid-Semester Continuous Assessment\nAcademic Session %s' % (dt, ct, view.context.code, session)
621            doc_title = '%s\n%s (%s)\nAcademic Session %s' % (dt, ct, view.context.code, session)
622        #footer_title = translate(_('${a} (${b}) - ${d}',
623        #    mapping = {'a':ft,
624        #               'b':view.context.code,
625        #               'd':session}))
626        footer_title = translate(_('${b} - ${d}',
627            mapping = {'b':view.context.code,
628                       'd':session}))
629        author = '%s (%s)' % (view.request.principal.title,
630                              view.request.principal.id)
631
632        # Insert signatures
633        # XXX: Not used in waeup.kofa, so we
634        # do not have a test for the following lines.
635        if signatures and not sigs_in_footer:
636            pdf_data.append(Spacer(1, 20))
637            # Render one signature table per signature to
638            # get date and signature in line.
639            for signature in signatures:
640                signaturetables = get_signature_tables(signature)
641                pdf_data.append(signaturetables[0])
642
643        view.response.setHeader(
644            'Content-Type', 'application/pdf')
645        view.response.setHeader(
646            'Content-Disposition:', 'attachment; filename="%s' % filename)
647        pdf_stream = creator.create_pdf(
648            pdf_data, None, doc_title, author, footer_title + ' -', note,
649            sigs_in_footer=sigs_in_footer,
650            )
651        return pdf_stream
Note: See TracBrowser for help on using the repository browser.