Ignore:
Timestamp:
30 Aug 2026, 11:16:40 (3 months ago)
Author:
Henrik Bettermann
Message:

Cange fullname convention.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/utils/utils.py

    r18313 r18317  
    1818"""Customize general helper utilities for Kofa.
    1919"""
     20import string
    2021from copy import deepcopy
    2122from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
    … …  
    151152        'alero': 'Owa-Alero Campus Hostel',
    152153        }
     154
     155    def fullname(self, firstname, lastname, middlename=None):
     156        """Construct fullname.
     157        """
     158        try:
     159            lastname = lastname.upper()
     160        except AttributeError:
     161            pass
     162        # We remove single initial
     163        if firstname and len(firstname) == 1:
     164            firstname = ''
     165        if middlename and len(middlename) == 1:
     166            middlename = ''
     167        if lastname and len(lastname) == 1:
     168            lastname = ''
     169        # We construct givennames
     170        givennames = ''
     171        if middlename and firstname:
     172            givennames = '%s %s' % (firstname, middlename)
     173        elif firstname:
     174            givennames = firstname
     175        elif middlename:
     176            givennames = middlename
     177        givennames = string.capwords(
     178            givennames.replace('-', ' - ')).replace(' - ', '-')
     179        # We construct fullname
     180        fullname = ''
     181        if lastname and givennames:
     182            fullname = '%s, %s' % (lastname, givennames)
     183        elif lastname:
     184            fullname = lastname
     185        elif givennames:
     186            fullname = givennames
     187        if '<' in fullname:
     188            return 'XXX'
     189        return fullname
Note: See TracChangeset for help on using the changeset viewer.