Ignore:
Timestamp:
17 Dec 2011, 12:54:39 (13 years ago)
Author:
Henrik Bettermann
Message:

Define two different (convenience?) methods: fullname and display_fullname. The first one is a hyphen-separated string of all name parts and is meant for indexing only. The second one uses the SIRPUtils fullname method and is meant for displaying the fullname in the UI. It can be easily customized according to the requirements of the school.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py

    r7359 r7364  
    7171
    7272    @property
    73     def fullname(self):
     73    def display_fullname(self):
    7474        middlename = getattr(self, 'middlename', None)
    7575        sirp_utils = getUtility(ISIRPUtils)
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/authentication.py

    r7255 r7364  
    3838    @property
    3939    def title(self):
    40         return self.context.fullname
     40        return self.context.display_fullname
    4141
    4242    @property
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r7363 r7364  
    563563    def label(self):
    564564        return '%s: Online Payment Ticket %s' % (
    565             self.context.__parent__.fullname,self.context.p_id)
     565            self.context.__parent__.display_fullname,self.context.p_id)
    566566
    567567class PaymentReceiptActionButton(ManageActionButton):
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantscontainermanagepage.pt

    r7246 r7364  
    8484            </td>
    8585            <td>
    86               <span tal:replace="appl/fullname">Fullname
     86              <span tal:replace="appl/display_fullname">Fullname
    8787              </span>
    8888            </td>
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r7356 r7364  
    384384    history = Attribute('Object history, a list of messages.')
    385385    state = Attribute('The application state of an applicant')
    386     fullname = Attribute('The fullname of an applicant')
     386    display_fullname = Attribute('The fullname of an applicant')
    387387    application_date = Attribute('Date of submission, used for export only')
    388388    password = Attribute('Encrypted password of a applicant')
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_authentication.py

    r7255 r7364  
    6060class FakeApplicant(object):
    6161    applicant_id = 'test_appl'
    62     fullname = 'Tilman Gause'
     62    display_fullname = 'Tilman Gause'
    6363    password = None
    6464    email = None
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py

    r7328 r7364  
    231231        """
    232232        if IStudentNavigation.providedBy(self.context):
    233             return self.context.getStudent().fullname
     233            return self.context.getStudent().display_fullname
    234234        return
    235235
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/showstudentspage.pt

    r7216 r7364  
    1919      <span tal:content="item/student_id">A123456</span></a>
    2020    </td>
    21           <td tal:content="item/fullname">FULLNAME</td>
     21          <td tal:content="item/display_fullname">FULLNAME</td>
    2222    <td tal:content="item/state">STATE</td>
    2323    <td>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/authentication.py

    r7316 r7364  
    5050    @property
    5151    def title(self):
    52         return self.context.fullname
     52        return self.context.display_fullname
    5353
    5454    @property
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7358 r7364  
    100100
    101101    def title(self):
    102         return self.context.fullname
     102        return self.context.display_fullname
    103103
    104104class SudyCourseBreadcrumb(Breadcrumb):
     
    347347    @property
    348348    def label(self):
    349         return '%s: Base Data' % self.context.fullname
     349        return '%s: Base Data' % self.context.display_fullname
    350350
    351351    @property
     
    378378
    379379    def label(self):
    380         return u'Send message to %s' % self.context.fullname
     380        return u'Send message to %s' % self.context.display_fullname
    381381
    382382    @grok.action('Send message now')
     
    484484    @property
    485485    def label(self):
    486         return '%s: Clearance Data' % self.context.fullname
     486        return '%s: Clearance Data' % self.context.display_fullname
    487487
    488488class StudentClearanceManageActionButton(ManageActionButton):
     
    546546    @property
    547547    def label(self):
    548         return 'Clearance Slip of %s' % self.context.fullname
     548        return 'Clearance Slip of %s' % self.context.display_fullname
    549549
    550550    def render(self):
     
    638638    @property
    639639    def label(self):
    640         return '%s: Personal Data' % self.context.fullname
     640        return '%s: Personal Data' % self.context.display_fullname
    641641
    642642class StudentPersonalManageActionButton(ManageActionButton):
     
    677677    @property
    678678    def label(self):
    679         return '%s: Study Course' % self.context.__parent__.fullname
     679        return '%s: Study Course' % self.context.__parent__.display_fullname
    680680
    681681    @property
     
    800800    def label(self):
    801801        return '%s: Study Level %s' % (
    802             self.context.getStudent().fullname,self.context.level_title)
     802            self.context.getStudent().display_fullname,self.context.level_title)
    803803
    804804    @property
     
    10641064    def label(self):
    10651065        return '%s: Course Ticket %s' % (
    1066             self.context.getStudent().fullname,self.context.code)
     1066            self.context.getStudent().display_fullname,self.context.code)
    10671067
    10681068class CourseTicketManageActionButton(ManageActionButton):
     
    11111111#    @property
    11121112#    def label(self):
    1113 #        return '%s: Payments' % self.context.__parent__.fullname
     1113#        return '%s: Payments' % self.context.__parent__.display_fullname
    11141114
    11151115#    def update(self):
     
    11381138    @property
    11391139    def label(self):
    1140         return '%s: Payments' % self.context.__parent__.fullname
     1140        return '%s: Payments' % self.context.__parent__.display_fullname
    11411141
    11421142    def update(self):
     
    12621262    def label(self):
    12631263        return '%s: Online Payment Ticket %s' % (
    1264             self.context.getStudent().fullname,self.context.p_id)
     1264            self.context.getStudent().display_fullname,self.context.p_id)
    12651265
    12661266class PaymentReceiptActionButton(ManageActionButton):
     
    13841384#    @property
    13851385#    def label(self):
    1386 #        return '%s: Accommodation Data' % self.context.__parent__.fullname
     1386#        return '%s: Accommodation Data' % self.context.__parent__.display_fullname
    13871387
    13881388# This manage form page is for both students and students officers.
     
    14011401    @property
    14021402    def label(self):
    1403         return '%s: Accommodation' % self.context.__parent__.fullname
     1403        return '%s: Accommodation' % self.context.__parent__.display_fullname
    14041404
    14051405    def update(self):
     
    16811681    @property
    16821682    def label(self):
    1683         return '%s: History' % self.context.fullname
     1683        return '%s: History' % self.context.display_fullname
    16841684
    16851685# Pages for students only
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/containermanagepage.pt

    r7329 r7364  
    4343          <span tal:content="item/student_id">A123456</span></a>
    4444        </td>
    45           <td tal:content="item/fullname">Bob</td>
     45          <td tal:content="item/display_fullname">Bob</td>
    4646        </tr>
    4747      </tbody>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/containerpage.pt

    r7205 r7364  
    4545          <span tal:content="item/matric_number">9999999</span></a>
    4646        </td>
    47         <td tal:content="item/fullname">Bob</td>
     47        <td tal:content="item/display_fullname">Bob</td>
    4848      </tr>
    4949      </tbody>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/catalog.py

    r7215 r7364  
    5656        self.url = view.url(context)
    5757        self.student_id = context.student_id
    58         self.fullname = context.fullname
     58        self.display_fullname = context.display_fullname
    5959        self.reg_number = context.reg_number
    6060        self.matric_number = context.matric_number
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r7357 r7364  
    115115    faccode = Attribute('The faculty code of any chosen study course')
    116116    current_session = Attribute('The current session of the student')
    117     fullname = Attribute('The fullname of an applicant')
     117    fullname = Attribute('All name parts separated by hyphens')
     118    display_fullname = Attribute('The fullname of an applicant')
    118119
    119120    def loggerInfo(ob_class, comment):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r7359 r7364  
    6464
    6565    @property
    66     def fullname(self):
     66    def display_fullname(self):
    6767        middlename = getattr(self, 'middlename', None)
    6868        sirp_utils = getUtility(ISIRPUtils)
    6969        return sirp_utils.fullname(self.firstname, self.lastname, middlename)
     70
     71    @property
     72    def fullname(self):
     73        middlename = getattr(self, 'middlename', None)
     74        if middlename:
     75            return '%s-%s-%s' % (self.firstname.lower(),
     76                middlename.lower(), self.lastname.lower())
     77        else:
     78            return '%s-%s' % (self.firstname.lower(), self.lastname.lower())
    7079
    7180    @property
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_authentication.py

    r7233 r7364  
    6161class FakeStudent(object):
    6262    student_id = 'test_stud'
    63     fullname = 'Test User'
     63    display_fullname = 'Test User'
    6464    password = None
    6565    email = None
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7357 r7364  
    279279        self.assertTrue('Anna Tester' in self.browser.contents)
    280280
    281         # We can find a student with a certain fullname
     281        # We can find a student by searching for all kind of name parts
    282282        self.browser.open(self.manage_container_path)
    283283        self.browser.getControl("Search").click()
     
    285285        self.browser.getControl(name="searchtype").value = ['fullname']
    286286        self.browser.getControl(name="searchterm").value = 'Anna Tester'
     287        self.browser.getControl("Search").click()
     288        self.assertTrue('Anna Tester' in self.browser.contents)
     289        self.browser.open(self.manage_container_path)
     290        self.browser.getControl(name="searchtype").value = ['fullname']
     291        self.browser.getControl(name="searchterm").value = 'Anna'
     292        self.browser.getControl("Search").click()
     293        self.assertTrue('Anna Tester' in self.browser.contents)
     294        self.browser.open(self.manage_container_path)
     295        self.browser.getControl(name="searchtype").value = ['fullname']
     296        self.browser.getControl(name="searchterm").value = 'Tester'
     297        self.browser.getControl("Search").click()
     298        self.assertTrue('Anna Tester' in self.browser.contents)
     299        self.browser.open(self.manage_container_path)
     300        self.browser.getControl(name="searchtype").value = ['fullname']
     301        self.browser.getControl(name="searchterm").value = 'An'
     302        self.browser.getControl("Search").click()
     303        self.assertFalse('Anna Tester' in self.browser.contents)
     304        self.browser.open(self.manage_container_path)
     305        self.browser.getControl(name="searchtype").value = ['fullname']
     306        self.browser.getControl(name="searchterm").value = 'An*'
     307        self.browser.getControl("Search").click()
     308        self.assertTrue('Anna Tester' in self.browser.contents)
     309        self.browser.open(self.manage_container_path)
     310        self.browser.getControl(name="searchtype").value = ['fullname']
     311        self.browser.getControl(name="searchterm").value = 'tester'
     312        self.browser.getControl("Search").click()
     313        self.assertTrue('Anna Tester' in self.browser.contents)
     314        self.browser.open(self.manage_container_path)
     315        self.browser.getControl(name="searchtype").value = ['fullname']
     316        self.browser.getControl(name="searchterm").value = 'Tester Ana'
     317        self.browser.getControl("Search").click()
     318        self.assertFalse('Anna Tester' in self.browser.contents)
     319        self.browser.open(self.manage_container_path)
     320        self.browser.getControl(name="searchtype").value = ['fullname']
     321        self.browser.getControl(name="searchterm").value = 'Tester Anna'
    287322        self.browser.getControl("Search").click()
    288323        self.assertTrue('Anna Tester' in self.browser.contents)
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_student.py

    r7351 r7364  
    3939        super(StudentTest, self).setUp()
    4040        self.student = Student()
     41        self.student.firstname = u'Anna'
     42        self.student.lastname = u'Tester'
    4143        self.studycourse = StudentStudyCourse()
    4244        self.studylevel = StudentStudyLevel()
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py

    r7359 r7364  
    2020import grok
    2121import smtplib
     22from string import capwords
    2223from email.mime.text import MIMEText
    2324from waeup.sirp.interfaces import ISIRPUtils
     
    5758        # We do not necessarily have the middlename attribute
    5859        if middlename:
    59             return '%s %s %s' % (firstname, middlename, lastname)
     60            return capwords('%s %s %s' % (firstname, middlename, lastname))
    6061        else:
    61             return '%s %s' % (firstname, lastname)
     62            return capwords('%s %s' % (firstname, lastname))
Note: See TracChangeset for help on using the changeset viewer.