Changeset 15427 for main/waeup.fceokene/trunk/src/waeup/fceokene/utils
- Timestamp:
- 26 May 2019, 08:30:42 (6 years ago)
- Location:
- main/waeup.fceokene/trunk/src/waeup/fceokene/utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.fceokene/trunk/src/waeup/fceokene/utils/tests.py
r8460 r15427 18 18 from waeup.kofa.testing import FunctionalTestCase 19 19 from waeup.fceokene.testing import FunctionalLayer 20 from waeup.fceokene.utils.utils import CustomKofaUtils 20 21 21 22 … … 24 25 layer = FunctionalLayer 25 26 26 def test_foo(self): 27 '''Test method foo. 28 ''' 29 return 27 def test_fullname(self): 28 util = CustomKofaUtils() 29 firstname = 'John' 30 middlename = 'Z' 31 lastname = 'Streep' 32 self.assertEqual( 33 util.fullname(firstname, lastname, middlename), 'John STREEP') 34 firstname = 'J' 35 self.assertEqual( 36 util.fullname(firstname, lastname, middlename), 'STREEP') 37 lastname = None 38 self.assertEqual( 39 util.fullname(firstname, lastname, middlename), '') 40 firstname = 'John' 41 self.assertEqual( 42 util.fullname(firstname, lastname, middlename), 'John') 43 firstname = 'J' 44 middlename = 'Babatunde' 45 lastname = 'Iron' 46 self.assertEqual( 47 util.fullname(firstname, lastname, middlename), 'Babatunde IRON') -
main/waeup.fceokene/trunk/src/waeup/fceokene/utils/utils.py
r14936 r15427 18 18 """Customize general helper utilities for Kofa. 19 19 """ 20 import string 20 21 from copy import deepcopy 21 22 from kofacustom.nigeria.utils.utils import NigeriaKofaUtils … … 141 142 return _('(visible after successful payment)') 142 143 return payment.p_item 144 145 def fullname(self, firstname, lastname, middlename=None): 146 """Construct fullname. 147 """ 148 try: 149 lastname = lastname.upper() 150 except AttributeError: 151 pass 152 # We remove single initial 153 if firstname and len(firstname) == 1: 154 firstname = '' 155 if middlename and len(middlename) == 1: 156 middlename = '' 157 if lastname and len(lastname) == 1: 158 lastname = '' 159 # We construct givennames 160 givennames = '' 161 if middlename and firstname: 162 givennames = '%s %s' % (firstname, middlename) 163 elif firstname: 164 givennames = firstname 165 elif middlename: 166 givennames = middlename 167 givennames = string.capwords( 168 givennames.replace('-', ' - ')).replace(' - ', '-') 169 # We construct fullname 170 fullname = '' 171 if lastname and givennames: 172 fullname = '%s %s' % (givennames, lastname) 173 elif lastname: 174 fullname = lastname 175 elif givennames: 176 fullname = givennames 177 if '<' in fullname: 178 return 'XXX' 179 return fullname
Note: See TracChangeset for help on using the changeset viewer.