Changeset 8591 for main/waeup.kofa/trunk


Ignore:
Timestamp:
1 Jun 2012, 11:25:22 (13 years ago)
Author:
Henrik Bettermann
Message:

Extend applicants statistics.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/applicants
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantcontainerstatistics.pt

    r8570 r8591  
    1 <h2 i18n:domain="waeup.kofa">Container Statistics</h2>
    2 
    3 <table i18n:domain="waeup.kofa">
    4   <thead>
    5     <tr>
    6       <th i18n:translate="">Application State</th>
    7       <th i18n:translate="">Number of Applicants</th>
    8     </tr>
    9   </thead>
    10   <tbody tal:define="stats context/statistics">
    11     <tr tal:repeat="state python:('initialized',
    12         'started','paid','submitted','admitted','not admitted',
    13         'created')">
    14       <td tal:content="state">STATE</td>
    15       <td tal:content="python: stats[state] ">NUMBER</td>
    16     </tr>
    17   </tbody>
    18 </table>
     1<tal:statistics define="stats context/statistics" i18n:domain="waeup.kofa">
     2  <h2 i18n:translate="">Container Statistics</h2>
     3  <table class="span8">
     4    <thead>
     5      <tr>
     6        <th i18n:translate="" width="40%">Application State</th>
     7        <th i18n:translate="">Number of Applicants</th>
     8      </tr>
     9    </thead>
     10    <tbody>
     11      <tr tal:repeat="state python:('initialized',
     12          'started','paid','submitted','admitted','not admitted',
     13          'created')">
     14        <td tal:content="state">STATE</td>
     15        <td tal:content="python: stats[0][state] ">NUMBER</td>
     16      </tr>
     17    </tbody>
     18  </table>
     19  <table class="span8">
     20    <thead>
     21      <tr>
     22        <th i18n:translate="" width="40%">Faculty</th>
     23        <th>&nbsp;</th>
     24      </tr>
     25    </thead>
     26    <tbody>
     27      <tr tal:repeat="fac python:stats[1].keys()">
     28        <td tal:content="fac">FAC</td>
     29        <td tal:content="python: stats[1][fac] ">NUMBER</td>
     30      </tr>
     31    </tbody>
     32  </table>
     33</tal:statistics>
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/container.py

    r8563 r8591  
    9999    @property
    100100    def statistics(self):
    101         statistics = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0,
     101        state_stats = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0,
    102102            ADMITTED:0, NOT_ADMITTED:0, CREATED:0}
     103        faculty_keys = grok.getSite()['faculties'].keys()
     104        fac_stats = dict([(i,0) for i in faculty_keys])
    103105        for key in self.keys():
    104             statistics[self[key].state] += 1
    105         return statistics
     106            state_stats[self[key].state] += 1
     107            cert = getattr(self[key],'course1',None)
     108            if  cert is not None:
     109                faculty = cert.__parent__.__parent__.__parent__
     110                fac_stats[faculty.__name__] += 1
     111        return state_stats, fac_stats
    106112
    107113ApplicantsContainer = attrs_to_fields(ApplicantsContainer)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r8590 r8591  
    131131        # because managers are allowed to edit this required field
    132132        self.applicant.reg_number = u'1234'
     133        self.applicant.course1 = certificate
    133134        app['applicants']['app2009'].addApplicant(self.applicant)
    134135        IUserAccount(
     
    376377        self.assertTrue('<td>initialized</td>' in self.browser.contents)
    377378        self.assertTrue('<td>1</td>' in self.browser.contents)
    378         self.assertEqual(self.applicantscontainer.statistics,
     379        self.assertEqual(self.applicantscontainer.statistics[0],
    379380            {'not admitted': 0, 'started': 0, 'created': 0,
    380381            'admitted': 0, 'submitted': 0, 'initialized': 1, 'paid': 0})
     382        self.assertEqual(self.applicantscontainer.statistics[1],
     383            {u'fac1': 1})
    381384        return
    382385
Note: See TracChangeset for help on using the changeset viewer.