Ignore:
Timestamp:
7 Jun 2012, 13:02:56 (13 years ago)
Author:
Henrik Bettermann
Message:

Use applicants_catalog for 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

    r8601 r8643  
    1717    </tbody>
    1818  </table>
    19   <table class="span8">
     19  <table class="span8" tal:condition="python: stats[1]">
    2020    <thead>
    2121      <tr>
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/container.py

    r8601 r8643  
    2121from random import SystemRandom as r
    2222import grok
     23from zope.component import getUtility
    2324from zope.component.factory import Factory
    2425from zope.component.interfaces import IFactory
     26from zope.catalog.interfaces import ICatalog
    2527from waeup.kofa.interfaces import MessageFactory as _
    2628from waeup.kofa.applicants.interfaces import (
     
    98100
    99101    @property
    100     def statistics(self):
     102    def unused_statistics(self):
    101103        state_stats = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0,
    102104            ADMITTED:0, NOT_ADMITTED:0, CREATED:0}
     
    111113                fac_stats[faculty.__name__] += 1
    112114        return state_stats, fac_stats
     115
     116    @property
     117    def statistics(self):
     118        state_stats = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0,
     119            ADMITTED:0, NOT_ADMITTED:0, CREATED:0}
     120        cat = getUtility(ICatalog, name='applicants_catalog')
     121        code = self.code
     122        year = int(code[-4:])
     123        target = code[:-4]
     124        mxcode = target + str(year + 1)
     125        for state in state_stats:
     126            state_stats[state] = len(cat.searchResults(
     127                state=(state, state),
     128                applicant_id=(code, mxcode)))
     129        return state_stats, None
    113130
    114131ApplicantsContainer = attrs_to_fields(ApplicantsContainer)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r8637 r8643  
    381381            {'not admitted': 0, 'started': 0, 'created': 0,
    382382            'admitted': 0, 'submitted': 0, 'initialized': 1, 'paid': 0})
    383         self.assertEqual(self.applicantscontainer.statistics[1],
    384             {u'fac1': 0})
     383        #self.assertEqual(self.applicantscontainer.statistics[1],
     384        #    {u'fac1': 0})
    385385        IWorkflowState(self.applicant).setState('submitted')
     386        notify(grok.ObjectModifiedEvent(self.applicant))
    386387        self.assertEqual(self.applicantscontainer.statistics[0],
    387388            {'not admitted': 0, 'started': 0, 'created': 0,
    388389            'admitted': 0, 'submitted': 1, 'initialized': 0, 'paid': 0})
    389         self.assertEqual(self.applicantscontainer.statistics[1],
    390             {u'fac1': 1})
     390        #self.assertEqual(self.applicantscontainer.statistics[1],
     391        #    {u'fac1': 1})
    391392        return
    392393
Note: See TracChangeset for help on using the changeset viewer.