| 1 | ## $Id: utils.py 18202 2025-10-31 09:19:05Z henrik $ |
|---|
| 2 | ## |
|---|
| 3 | ## Copyright (C) 2012 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 | ## |
|---|
| 18 | """Customize general helper utilities for Kofa. |
|---|
| 19 | """ |
|---|
| 20 | |
|---|
| 21 | import string |
|---|
| 22 | import grok |
|---|
| 23 | from kofacustom.nigeria.utils.utils import NigeriaKofaUtils |
|---|
| 24 | from waeup.kofa.students.workflow import ALUMNI_STATES |
|---|
| 25 | |
|---|
| 26 | class CustomKofaUtils(NigeriaKofaUtils): |
|---|
| 27 | """A collection of methods subject to customization. |
|---|
| 28 | """ |
|---|
| 29 | |
|---|
| 30 | PREFERRED_LANGUAGES_DICT = { |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | COURSE_CATEGORY_DICT = { |
|---|
| 34 | 'C':'Core Course (C)', |
|---|
| 35 | 'R':'Required Courses (R)', |
|---|
| 36 | 'E':'Elective Courses (E)', |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | PAYMENT_CATEGORIES = { |
|---|
| 40 | 'schoolfee': 'School Fees', |
|---|
| 41 | 'schoolfee_1': 'School Fees Plus (1st instalment)', |
|---|
| 42 | 'schoolfee_2': 'School Fees (2nd instalment)', |
|---|
| 43 | 'schoolfee_incl': 'School Fees Plus', |
|---|
| 44 | 'clearance': 'Acceptance Fee', |
|---|
| 45 | 'clearance_incl': 'Acceptance Fee Plus', |
|---|
| 46 | 'hostel_maintenance': 'Hostel Accommodation Fee', |
|---|
| 47 | 'hostel_balance': 'Hostel Balance', |
|---|
| 48 | 'application': 'Application Fee', |
|---|
| 49 | 'app_balance': 'Application Fee Balance', |
|---|
| 50 | 'bed_allocation': 'Bed Allocation Fee', |
|---|
| 51 | 'transfer': 'Transfer Fee', |
|---|
| 52 | 'transcript_local': 'Local Transcript Fee', |
|---|
| 53 | 'transcript_inter': 'International Transcript Fee', |
|---|
| 54 | 'late_registration': 'Late Course Registration Fee', |
|---|
| 55 | 'welfare': 'Student Welfare Assurance Fee', |
|---|
| 56 | 'union': 'Student Union Dues', |
|---|
| 57 | 'lapel': 'Lapel/File Fee', |
|---|
| 58 | 'matric_gown': 'Matriculation Gown Fee', |
|---|
| 59 | 'concessional': 'Concessional Fee', |
|---|
| 60 | 'id_card': 'Student ID Card', |
|---|
| 61 | 'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112', |
|---|
| 62 | 'gst_text_book_1': 'Text Book Fee GST101 GST102', |
|---|
| 63 | 'gst_text_book_2': 'Text Book Fee GST111 GST112', |
|---|
| 64 | 'gst_text_book_3': 'Text Book Fee GST222', |
|---|
| 65 | 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', |
|---|
| 66 | 'gst_registration_2': 'Registration Fee GST222', |
|---|
| 67 | 'ent_text_book_1': 'Text Book Fee ENT201', |
|---|
| 68 | 'ent_text_book_2': 'Text Book Fee ENT211', |
|---|
| 69 | 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', |
|---|
| 70 | 'ent_registration_1': 'Registration Fee ENT201', |
|---|
| 71 | 'ent_registration_2': 'Registration Fee ENT211', |
|---|
| 72 | 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', |
|---|
| 73 | 'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211', |
|---|
| 74 | 'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)', |
|---|
| 75 | 'ict': 'ICT/Affidavit Dues', |
|---|
| 76 | 'affidavit': 'Affidavit Dues', |
|---|
| 77 | 'restitution': 'Restitution Fee', |
|---|
| 78 | 'sports': 'Sports Fee', |
|---|
| 79 | 'library': 'UG Library Fee', |
|---|
| 80 | 'library_pg': 'PG Library Fee', |
|---|
| 81 | 'sports_library': 'Sports Development and Library Fee', |
|---|
| 82 | 'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)', |
|---|
| 83 | 'lab_2': 'Laboratory Due (BIO101/BIO111)', |
|---|
| 84 | 'lms_sund': 'LMS + Sundry Fees', |
|---|
| 85 | 'exam': 'IJMBE Examination Fee', |
|---|
| 86 | 'access_card': 'AAU Access Card Fee', # deprecated |
|---|
| 87 | 'access': 'University Student Identity Card Levy', |
|---|
| 88 | 'lmsplus': 'LMS Plus Fee', |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | SELECTABLE_PAYMENT_CATEGORIES = { |
|---|
| 92 | #'schoolfee': 'School Fees', |
|---|
| 93 | 'schoolfee_1': 'School Fees Plus (1st instalment)', |
|---|
| 94 | 'schoolfee_2': 'School Fees (2nd instalment)', |
|---|
| 95 | 'schoolfee_incl': 'School Fees Plus', |
|---|
| 96 | 'clearance': 'Acceptance Fee', |
|---|
| 97 | 'clearance_incl': 'Acceptance Fee Plus', |
|---|
| 98 | 'hostel_maintenance': 'Hostel Accommodation Fee', |
|---|
| 99 | 'hostel_balance': 'Hostel Balance', |
|---|
| 100 | #'application': 'Application Fee', |
|---|
| 101 | 'bed_allocation': 'Bed Allocation Fee', |
|---|
| 102 | #'transfer': 'Transfer Fee', |
|---|
| 103 | ##'transcript_local': 'Local Transcript Fee', |
|---|
| 104 | ##'transcript_inter': 'International Transcript Fee', |
|---|
| 105 | 'late_registration': 'Late Course Registration Fee', |
|---|
| 106 | #'welfare': 'Student Welfare Assurance Fee', |
|---|
| 107 | #'union': 'Student Union Dues', |
|---|
| 108 | #'lapel': 'Lapel/File Fee', |
|---|
| 109 | #'matric_gown': 'Matriculation Gown Fee', |
|---|
| 110 | ##'concessional': 'Concessional Fee', |
|---|
| 111 | #'id_card': 'Student ID Card', |
|---|
| 112 | 'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112', |
|---|
| 113 | 'gst_text_book_1': 'Text Book Fee GST101 GST102', |
|---|
| 114 | 'gst_text_book_2': 'Text Book Fee GST111 GST112', |
|---|
| 115 | 'gst_text_book_3': 'Text Book Fee GST222', |
|---|
| 116 | 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', |
|---|
| 117 | 'gst_registration_2': 'Registration Fee GST222', |
|---|
| 118 | 'ent_text_book_1': 'Text Book Fee ENT201', |
|---|
| 119 | 'ent_text_book_2': 'Text Book Fee ENT211', |
|---|
| 120 | 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', |
|---|
| 121 | 'ent_registration_1': 'Registration Fee ENT201', |
|---|
| 122 | 'ent_registration_2': 'Registration Fee ENT211', |
|---|
| 123 | 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', |
|---|
| 124 | 'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211', |
|---|
| 125 | ##'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)', |
|---|
| 126 | ##'ict': 'ICT/Affidavit Dues', |
|---|
| 127 | ##'affidavit': 'Affidavit Dues', |
|---|
| 128 | ##'restitution': 'Restitution Fee', |
|---|
| 129 | ##'sports': 'Sports Fee', |
|---|
| 130 | ##'library': 'UG Library Fee', |
|---|
| 131 | ##'library_pg': 'PG Library Fee', |
|---|
| 132 | ##'sports_library': 'Sports Development and Library Fee', |
|---|
| 133 | ##'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)', |
|---|
| 134 | ##'lab_2': 'Laboratory Due (BIO101/BIO111)', |
|---|
| 135 | ##'access_card': 'AAU Access Card Fee', |
|---|
| 136 | 'access': 'University Student Identity Card Levy', |
|---|
| 137 | 'lmsplus': 'LMS Plus Fee', |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | ALUMNI_PAYMENT_CATS = { |
|---|
| 141 | 'transcript_local': 'Transcript Fee Local', |
|---|
| 142 | 'transcript_inter': 'Transcript Fee International', |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | REDUCED_PAYMENT_CATS = { |
|---|
| 146 | 'clearance': 'Acceptance Fee', |
|---|
| 147 | 'schoolfee_incl': 'School Fees Plus', |
|---|
| 148 | 'late_registration': 'Late Course Registration Fee', |
|---|
| 149 | ##'sports': 'Sports Fee', |
|---|
| 150 | ##'library': 'UG Library Fee', |
|---|
| 151 | ##'library_pg': 'PG Library Fee', |
|---|
| 152 | ##'sports_library': 'Sports Development and Library Fee', |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | IJMBE_PAYMENT_CATS = { |
|---|
| 156 | 'clearance': 'Acceptance Fee', |
|---|
| 157 | 'schoolfee': 'School Fees', |
|---|
| 158 | 'schoolfee_1': 'School Fees (1st instalment)', |
|---|
| 159 | 'schoolfee_2': 'School Fees (2nd instalment)', |
|---|
| 160 | ##'sports': 'Sports Fee', |
|---|
| 161 | ##'library': 'UG Library Fee', |
|---|
| 162 | ##'library_pg': 'PG Library Fee', |
|---|
| 163 | ##'sports_library': 'Sports Development and Library Fee', |
|---|
| 164 | 'exam': 'IJMBE Examination Fee', |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | PT_AND_DSH_PAYMENT_CATS = { |
|---|
| 168 | 'clearance_incl': 'Acceptance Fee Plus', |
|---|
| 169 | 'schoolfee_incl': 'School Fees Plus', |
|---|
| 170 | 'schoolfee_1': 'School Fees Plus (1st instalment)', |
|---|
| 171 | 'schoolfee_2': 'School Fees (2nd instalment)', |
|---|
| 172 | 'ent_text_book_1': 'Text Book Fee ENT201', |
|---|
| 173 | 'ent_text_book_2': 'Text Book Fee ENT211', |
|---|
| 174 | 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', |
|---|
| 175 | 'ent_registration_1': 'Registration Fee ENT201', |
|---|
| 176 | 'ent_registration_2': 'Registration Fee ENT211', |
|---|
| 177 | 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', |
|---|
| 178 | 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', |
|---|
| 179 | 'gst_registration_2': 'Registration Fee GST222', |
|---|
| 180 | 'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112', |
|---|
| 181 | 'gst_text_book_1': 'Text Book Fee GST101 GST102', |
|---|
| 182 | 'gst_text_book_2': 'Text Book Fee GST111 GST112', |
|---|
| 183 | 'gst_text_book_3': 'Text Book Fee GST222', |
|---|
| 184 | 'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211', |
|---|
| 185 | 'late_registration': 'Late Course Registration Fee', |
|---|
| 186 | ##'sports': 'Sports Fee', |
|---|
| 187 | ##'library': 'UG Library Fee', |
|---|
| 188 | ##'library_pg': 'PG Library Fee', |
|---|
| 189 | ##'sports_library': 'Sports Development and Library Fee', |
|---|
| 190 | ##'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)', |
|---|
| 191 | ##'lab_2': 'Laboratory Due (BIO101/BIO111)', |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | def selectable_payment_categories(self, student): |
|---|
| 195 | if student.state in ALUMNI_STATES: |
|---|
| 196 | return self.ALUMNI_PAYMENT_CATS |
|---|
| 197 | if student.current_mode in ( |
|---|
| 198 | 'special_pg_ft', 'special_pg_pt', 'found', 'bridge'): |
|---|
| 199 | return self.REDUCED_PAYMENT_CATS |
|---|
| 200 | if student.current_mode in ( |
|---|
| 201 | 'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh'): |
|---|
| 202 | return self.PT_AND_DSH_PAYMENT_CATS |
|---|
| 203 | if student.current_mode == 'ijmbe': |
|---|
| 204 | return self.IJMBE_PAYMENT_CATS |
|---|
| 205 | return self.SELECTABLE_PAYMENT_CATEGORIES |
|---|
| 206 | |
|---|
| 207 | REPORTABLE_PAYMENT_CATEGORIES = { |
|---|
| 208 | 'schoolfee': 'School Fees', |
|---|
| 209 | 'schoolfee_incl': 'School Fees Plus', |
|---|
| 210 | 'schoolfee_1': 'School Fees 1 Plus', |
|---|
| 211 | 'schoolfee_2': 'School Fees 2', |
|---|
| 212 | 'clearance': 'Acceptance Fee', |
|---|
| 213 | 'clearance_incl': 'Acceptance Fee Plus', |
|---|
| 214 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
|---|
| 215 | } |
|---|
| 216 | |
|---|
| 217 | BALANCE_PAYMENT_CATEGORIES = { |
|---|
| 218 | 'schoolfee': 'School Fees', |
|---|
| 219 | 'clearance': 'Acceptance Fee', |
|---|
| 220 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
|---|
| 221 | 'hostel_balance': 'Hostel Balance', |
|---|
| 222 | 'late_registration': 'Late Course Registration Fee', |
|---|
| 223 | #'welfare': 'Student Welfare Assurance Fee', |
|---|
| 224 | #'union': 'Student Union Dues', |
|---|
| 225 | #'lapel': 'Lapel/File Fee', |
|---|
| 226 | #'matric_gown': 'Matriculation Gown Fee', |
|---|
| 227 | #'id_card': 'Student ID Card', |
|---|
| 228 | 'gst_text_book_1': 'Text Book Fee GST101 GST102', |
|---|
| 229 | 'gst_text_book_2': 'Text Book Fee GST111 GST112', |
|---|
| 230 | 'gst_text_book_3': 'Text Book Fee GST222', |
|---|
| 231 | 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', |
|---|
| 232 | 'gst_registration_2': 'Registration Fee GST222', |
|---|
| 233 | 'ent_text_book_1': 'Text Book Fee ENT201', |
|---|
| 234 | 'ent_text_book_2': 'Text Book Fee ENT211', |
|---|
| 235 | 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', |
|---|
| 236 | 'ent_registration_1': 'Registration Fee ENT201', |
|---|
| 237 | 'ent_registration_2': 'Registration Fee ENT211', |
|---|
| 238 | 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', |
|---|
| 239 | #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)', |
|---|
| 240 | #'ict': 'ICT/Affidavit Dues', |
|---|
| 241 | #'affidavit': 'Affidavit Dues', |
|---|
| 242 | #'restitution': 'Restitution Fee', |
|---|
| 243 | } |
|---|
| 244 | |
|---|
| 245 | PREVIOUS_PAYMENT_CATEGORIES = { |
|---|
| 246 | 'schoolfee_incl': 'School Fees Plus', |
|---|
| 247 | 'schoolfee_1': 'School Fees Plus (1st instalment)', |
|---|
| 248 | 'schoolfee_2': 'School Fees (2nd instalment)', |
|---|
| 249 | 'clearance': 'Acceptance Fee', |
|---|
| 250 | 'late_registration': 'Late Course Registration Fee', |
|---|
| 251 | } |
|---|
| 252 | |
|---|
| 253 | APP_CATS_DICT = { |
|---|
| 254 | 'basic': 'PUTME, PUDE, PCE, PRENCE', |
|---|
| 255 | 'no': 'No Application', |
|---|
| 256 | 'pg_ft': 'Postgraduate Full-Time', |
|---|
| 257 | 'pg_pt': 'Postgraduate Part-Time', |
|---|
| 258 | 'cest': 'Part-Time, Diploma, Certificate', |
|---|
| 259 | 'found': 'Foundation', |
|---|
| 260 | 'ptee': 'Part-Time Entrance Examination', |
|---|
| 261 | 'ioe_dp': 'Institute of Education Diploma', |
|---|
| 262 | 'ijmbe': 'IJMBE Preparation', |
|---|
| 263 | 'bridge': 'Bridge', |
|---|
| 264 | 'dsh': 'Science and Humanities', |
|---|
| 265 | |
|---|
| 266 | } |
|---|
| 267 | |
|---|
| 268 | STUDY_MODES_DICT = { |
|---|
| 269 | 'ug_ft': 'Undergraduate Full Time', |
|---|
| 270 | 'ug_pt': 'Undergraduate Part Time', |
|---|
| 271 | 'de_ft': 'Direct Entry Full Time', |
|---|
| 272 | 'de_pt': 'Direct Entry Part Time', |
|---|
| 273 | 'dp_pt': 'Diploma Part Time', |
|---|
| 274 | 'dp_ft': 'Diploma Full Time', |
|---|
| 275 | 'special_pg_ft': 'Postgraduate Full Time', |
|---|
| 276 | 'special_pg_pt': 'Postgraduate Part Time', |
|---|
| 277 | 'found': 'Foundation', |
|---|
| 278 | 'transfer': 'Transfer', |
|---|
| 279 | 'transferred': 'Transferred', |
|---|
| 280 | 'mug_ft': 'Undergraduate Full Time Merit List', |
|---|
| 281 | 'mde_ft': 'Direct Entry Full Time Merit List', |
|---|
| 282 | 'ijmbe': 'IJMBE Preparation', |
|---|
| 283 | 'bridge': 'Bridge', |
|---|
| 284 | 'ug_dsh': 'Undergraduate Science and Humanities', |
|---|
| 285 | 'de_dsh': 'Direct Entry Science and Humanities', |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT |
|---|
| 289 | |
|---|
| 290 | VERDICTS_DICT = { |
|---|
| 291 | '0': 'not yet', |
|---|
| 292 | 'A': 'Successful student', |
|---|
| 293 | 'B': 'Student with carryover courses', |
|---|
| 294 | 'C': 'Student on probation', |
|---|
| 295 | 'D': 'Withdrawn from the faculty', |
|---|
| 296 | #'E': 'Student who were previously on probation', |
|---|
| 297 | #'F': 'Medical case', |
|---|
| 298 | #'G': 'Absent from examination', |
|---|
| 299 | #'H': 'Withheld results', |
|---|
| 300 | #'I': 'Expelled/rusticated/suspended student', |
|---|
| 301 | #'J': 'Temporary withdrawn from the university', |
|---|
| 302 | #'K': 'Unregistered student', |
|---|
| 303 | #'L': 'Referred student', |
|---|
| 304 | #'M': 'Reinstatement', |
|---|
| 305 | #'N': 'Student on transfer', |
|---|
| 306 | #'O': 'NCE-III repeater', |
|---|
| 307 | #'Y': 'No previous verdict', |
|---|
| 308 | #'X': 'New 300 level student', |
|---|
| 309 | 'Z': 'Successful student (provisional)', |
|---|
| 310 | #'A1': 'First Class', |
|---|
| 311 | #'A2': 'Second Class Upper', |
|---|
| 312 | #'A3': 'Second Class Lower', |
|---|
| 313 | #'A4': 'Third Class', |
|---|
| 314 | #'A5': 'Pass', |
|---|
| 315 | #'A6': 'Distinction', |
|---|
| 316 | #'A7': 'Credit', |
|---|
| 317 | #'A8': 'Merit', |
|---|
| 318 | 'NER': 'No evidence of registration', |
|---|
| 319 | 'NYV': 'Not yet verified', |
|---|
| 320 | 'FRNS': 'Faculty requirements not satisfied', |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | DISABLE_PAYMENT_GROUP_DICT = { |
|---|
| 324 | 'sf_all': 'School Fees - All Students', |
|---|
| 325 | 'all_returning': 'All Fees - Returning Students', |
|---|
| 326 | 'sf_pg': 'School Fees - Postgraduate Students', |
|---|
| 327 | 'sf_ug_pt': 'School Fees - Undergraduate Part-Time Students', |
|---|
| 328 | 'sf_found': 'School Fees - Foundation Students', |
|---|
| 329 | 'maint_all': 'Accommodation Fee - All Students', |
|---|
| 330 | 'cl_regular': 'Acceptance Fee - Regular Students', |
|---|
| 331 | } |
|---|
| 332 | |
|---|
| 333 | MODE_GROUPS = { |
|---|
| 334 | 'All': ('all',), |
|---|
| 335 | 'Undergraduate Full-Time': ('ug_ft', 'mde_ft', 'mug_ft', 'de_ft'), |
|---|
| 336 | 'Undergraduate Part-Time': ('ug_pt', 'de_pt'), |
|---|
| 337 | 'Postgraduate': ('pg_ft','special_pg_ft', 'special_pg_pt'), |
|---|
| 338 | 'Foundation Programme': ('found',), |
|---|
| 339 | 'Institute of Education': ('dp_ft'), |
|---|
| 340 | 'IJMBE Preparation': ('ijmbe',), |
|---|
| 341 | 'Bridge': ('bridge',), |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | #: Maximum number of files listed in `finished` subfolder |
|---|
| 345 | MAX_FILES = 5000 |
|---|
| 346 | |
|---|
| 347 | def fullname(self, firstname, lastname, middlename=None): |
|---|
| 348 | """Construct fullname. |
|---|
| 349 | """ |
|---|
| 350 | try: |
|---|
| 351 | lastname = lastname.upper() |
|---|
| 352 | except AttributeError: |
|---|
| 353 | pass |
|---|
| 354 | # We remove single initial |
|---|
| 355 | if firstname and len(firstname) == 1: |
|---|
| 356 | firstname = '' |
|---|
| 357 | if middlename and len(middlename) == 1: |
|---|
| 358 | middlename = '' |
|---|
| 359 | if lastname and len(lastname) == 1: |
|---|
| 360 | lastname = '' |
|---|
| 361 | # We construct givennames |
|---|
| 362 | givennames = '' |
|---|
| 363 | if middlename and firstname: |
|---|
| 364 | givennames = '%s %s' % (firstname, middlename) |
|---|
| 365 | elif firstname: |
|---|
| 366 | givennames = firstname |
|---|
| 367 | elif middlename: |
|---|
| 368 | givennames = middlename |
|---|
| 369 | givennames = string.capwords( |
|---|
| 370 | givennames.replace('-', ' - ')).replace(' - ', '-') |
|---|
| 371 | # We construct fullname |
|---|
| 372 | fullname = '' |
|---|
| 373 | if lastname and givennames: |
|---|
| 374 | fullname = '%s, %s' % (lastname, givennames) |
|---|
| 375 | elif lastname: |
|---|
| 376 | fullname = lastname |
|---|
| 377 | elif givennames: |
|---|
| 378 | fullname = givennames |
|---|
| 379 | if '<' in fullname: |
|---|
| 380 | return 'XXX' |
|---|
| 381 | return fullname |
|---|
| 382 | |
|---|
| 383 | def getUsers(self): |
|---|
| 384 | users = sorted( |
|---|
| 385 | grok.getSite()['users'].items(), key=lambda x: x[0]) |
|---|
| 386 | for key, val in users: |
|---|
| 387 | yield(dict(name=key, val="%s - %s" % (val.name, val.title))) |
|---|
| 388 | |
|---|
| 389 | def getCertTitle(self, context, value): |
|---|
| 390 | """Compose the titles in `CertificateSource`. |
|---|
| 391 | """ |
|---|
| 392 | return "%s - %s" % (value.code.strip('-'), value.title) |
|---|