utils.utils - Utilities

General helper utilities for Kofa.

waeup.kofa.utils.utils.INT_PHONE_PREFIXES = [(99, u'Germany', '49'), (1, u'Nigeria', '234'), (99, u'U.S.', '1')]

A list of phone prefixes (order num, country, prefix). Items with same order num will be sorted alphabetically. The lower the order num, the higher the precedence.

class waeup.kofa.utils.utils.KofaUtils[source]

Bases: grokcore.component.components.GlobalUtility

A collection of parameters and methods subject to customization.

APPLICANT_BALANCE_PAYMENT_CATEGORIES = {'donation': 'Donation'}
APP_CATS_DICT = {'cest': 'Part-Time, Diploma, Certificate', 'no': 'no application', 'pg': 'Postgraduate', 'sandwich': 'Sandwich', 'basic': 'Basic Application'}
BALANCE_PAYMENT_CATEGORIES = {'schoolfee': 'School Fee'}
COMBI_PAYMENT_CATEGORIES = {'gown': 'Gown Hire Fee', 'transcript': 'Transcript Fee', 'late_registration': 'Late Course Registration Fee'}
COURSE_CATEGORY_DICT = {}
DEGREES_DICT = {'BAGR': 'Bachelor of Agriculture', 'MD': 'Doctor of Medicine', 'MA': 'Master of Arts', 'BA': 'Bachelor of Arts', 'MUSM': 'Master of Music', 'DBA': 'Doctor of Business Administration', 'LLB': 'Bachelor of Laws', 'PHD': 'Doctor of Philosophy', 'MBA': 'Master of Business Administration', 'LLM': 'Master of Laws'}
DISABLE_PAYMENT_GROUP_DICT = {'sf_all': 'School Fee - All Students'}
EXAM_GRADES = (('A', 'Best'), ('B', 'Better'), ('C', 'Good'))

Exam grades. The tuple is sorted as it should be displayed in select boxes.

EXAM_SUBJECTS_DICT = {'computer_science': 'Computer Science', 'math': 'Mathematics'}
INST_TYPES_DICT = {'directorate': 'Directorate of', 'office': 'Office for', 'centre': 'Centre for', 'school': 'School of', 'school_for': 'School for', 'college': 'College of', 'faculty': 'Faculty of', 'centre_of': 'Centre of', 'none': '', 'institute': 'Institute of', 'department': 'Department of'}
MAX_FILES = 100

Maximum number of files listed in finished subfolder

MAX_PASSPORT_SIZE = 51200

Maximum size in Bytes of passport images in the applicants and students section

MODE_GROUPS = {'Postgraduate Full-Time': ('pg_ft',), 'Postgraduate Part-Time': ('pg_pt',), 'All': ('all',), 'Undergraduate Full-Time': ('ug_ft',), 'Undergraduate Part-Time': ('ug_pt',)}
MONTHS_DICT = {'11': u'November', '10': u'October', '12': u'December', '1': u'January', '3': u'March', '2': u'February', '5': u'May', '4': u'April', '7': u'July', '6': u'June', '9': u'September', '8': u'August'}
PAYMENT_CATEGORIES = {'gown': 'Gown Hire Fee', 'app_balance': 'Application Fee Balance', 'donation': 'Donation', 'transcript': 'Transcript Fee', 'schoolfee': 'School Fee', 'application': 'Application Fee', 'transfer': 'Transfer Fee', 'combi': 'Combi Payment', 'hostel_maintenance': 'Hostel Maintenance Fee', 'late_registration': 'Late Course Registration Fee', 'clearance': 'Acceptance Fee', 'bed_allocation': 'Bed Allocation Fee'}
PAYMENT_OPTIONS = {}

If PAYMENT_OPTIONS is empty, payment option fields won’t show up.

PORTAL_LANGUAGE = 'en'

This the only place where we define the portal language which is used for the translation of system messages (e.g. object histories) pdf slips.

PREFERRED_LANGUAGES_DICT = {'fr': (2, u'Français'), 'en': (1, u'English'), 'yo': (5, u'Yoruba'), 'de': (3, u'Deutsch'), 'ha': (4, u'Hausa'), 'ig': (6, u'Igbo')}
PREVIOUS_PAYMENT_CATEGORIES = {'gown': 'Gown Hire Fee', 'combi': 'Combi Payment', 'transfer': 'Transfer Fee', 'app_balance': 'Application Fee Balance', 'application': 'Application Fee', 'donation': 'Donation', 'hostel_maintenance': 'Hostel Maintenance Fee', 'late_registration': 'Late Course Registration Fee', 'clearance': 'Acceptance Fee', 'transcript': 'Transcript Fee', 'schoolfee': 'School Fee', 'bed_allocation': 'Bed Allocation Fee'}
REPORTABLE_PAYMENT_CATEGORIES = {'hostel_maintenance': 'Hostel Maintenance Fee', 'clearance': 'Acceptance Fee', 'schoolfee': 'School Fee', 'gown': 'Gown Hire Fee'}
SEMESTER_DICT = {1: '1st Semester', 2: '2nd Semester', 3: 'Combined', 4: '1st Term', 5: '2nd Term', 6: '3rd Term', 9: 'N/A', 11: 'Module I', 12: 'Module II', 13: 'Module III'}
SPECIAL_APP_DICT = {'clearance': 'Acceptance Fee', 'transcript': 'Transcript Fee Payment'}
SPECIAL_HANDLING_DICT = {'regular': 'Regular Hostel', 'pg': 'Postgraduate Hostel', 'blocked': 'Blocked Hostel'}
STUDY_MODES_DICT = {'transfer': 'Transfer', 'pg_pt': 'Postgraduate Part-Time', 'transferred': 'Transferred', 'ug_pt': 'Undergraduate Part-Time', 'pg_ft': 'Postgraduate Full-Time', 'ug_ft': 'Undergraduate Full-Time'}
SYSTEM_MAX_LOAD = {'virt-mem': None, 'cpu-load': 100.0, 'swap-mem': None}

Set positive number for allowed max, negative for required min avail. Use integer for bytes value, float for percent value. cpu-load, of course, accepts float values only. swap-mem = Swap Memory, virt-mem = Virtual Memory, cpu-load = CPU load in percent.

TEMP_PASSWORD_MINUTES = 10

Temporary passwords and parents password validity period

VERDICTS_DICT = {'A': 'Successful student', '0': u'(not yet)', 'C': 'Student on probation', 'B': 'Student with carryover courses'}
__doc__ = 'A collection of parameters and methods subject to customization.\n '
__implemented__ = <implementedBy waeup.kofa.utils.utils.KofaUtils>
__module__ = 'waeup.kofa.utils.utils'
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
expensive_actions_allowed(type=None, request=None)[source]

Tell, whether expensive actions are currently allowed. Check system load/health (or other external circumstances) and locally set values to see, whether expensive actions should be allowed (True) or better avoided (False). Use this to allow or forbid exports, report generations, or similar actions.

export_disabled_message()[source]
format_float(value, prec)[source]
fullname(firstname, lastname, middlename=None)[source]

Construct fullname.

genPassword(length=4, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')[source]

Generate a random password.

getPaymentItem(payment)[source]

Return payment item. This method can be used to customize the display_item property attribute, e.g. in order to hide bed coordinates if maintenance fee is not paid.

getUsers()[source]
informApplicant(applicant)[source]

Inform applicant that the application form was successfully submitted.

informNewStudent(user, pw, login_url, rpw_url)[source]

Inform student that a new student account has been created.

inviteReferee(referee, applicant, url_info=None)[source]

Send invitation email to referee.

selectable_payment_categories(student)[source]
selectable_payment_options(student)[source]
sendContactForm(from_name, from_addr, rcpt_name, rcpt_addr, from_username, usertype, portal, body, subject, bcc_to=None)[source]

Send an email with data provided by forms.

sendCredentials(user, password=None, url_info=None, msg=None)[source]

Send credentials as email. Input is the user for which credentials are sent and the password. Method returns True or False to indicate successful operation.

classmethod sorted_phone_prefixes(data=[(99, u'Germany', '49'), (1, u'Nigeria', '234'), (99, u'U.S.', '1')], request=None)[source]
tzinfo

Time zone of the university.

waeup.kofa.utils.utils.send_mail(from_name, from_addr, rcpt_name, rcpt_addr, subject, body, config, cc=None, bcc=None)[source]

Wrapper for the real SMTP functionality in waeup.kofa.smtp.

Merely here to stay compatible with lots of calls to this place.

waeup.kofa.utils.utils.sorted_phone_prefixes(data=[(99, u'Germany', '49'), (1, u'Nigeria', '234'), (99, u'U.S.', '1')], request=None)[source]

Sorted tuples of phone prefixes.

Ordered as shown above and formatted for use in select boxes.

If request is given, we’ll try to translate all country names in order to sort alphabetically correctly.

XXX: This is a function (and not a constant) as different languages might give different orders. This is not tested yet.

XXX: If we really want to use alphabetic ordering here, we might think about caching results of translations.