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