Changeset 8645 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 7 Jun 2012, 18:28:09 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/container.py
r8643 r8645 24 24 from zope.component.factory import Factory 25 25 from zope.component.interfaces import IFactory 26 from zope.catalog.interfaces import ICatalog27 26 from waeup.kofa.interfaces import MessageFactory as _ 28 27 from waeup.kofa.applicants.interfaces import ( 29 IApplicantsContainer, IApplicantsContainerAdd, IApplicant 30 )28 IApplicantsContainer, IApplicantsContainerAdd, IApplicant, 29 IApplicantsUtils) 31 30 from waeup.kofa.utils.helpers import attrs_to_fields 32 from waeup.kofa.applicants.workflow import (INITIALIZED, 33 STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED) 31 34 32 35 33 def generate_applicant_id(container=None): … … 100 98 101 99 @property 102 def unused_statistics(self):103 state_stats = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0,104 ADMITTED:0, NOT_ADMITTED:0, CREATED:0}105 faculty_keys = grok.getSite()['faculties'].keys()106 fac_stats = dict([(i,0) for i in faculty_keys])107 for key in self.keys():108 state = self[key].state109 state_stats[state] += 1110 cert = getattr(self[key],'course1',None)111 if cert is not None and state == SUBMITTED:112 faculty = cert.__parent__.__parent__.__parent__113 fac_stats[faculty.__name__] += 1114 return state_stats, fac_stats115 116 @property117 100 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 101 return getUtility(IApplicantsUtils).getApplicantsStatistics(self) 130 102 131 103 ApplicantsContainer = attrs_to_fields(ApplicantsContainer) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py
r8534 r8645 21 21 from time import time 22 22 import grok 23 from zope.component import getUtility 24 from zope.catalog.interfaces import ICatalog 25 from waeup.kofa.interfaces import MessageFactory as _ 23 26 from waeup.kofa.applicants.interfaces import IApplicantsUtils 24 from waeup.kofa.interfaces import MessageFactory as _ 27 from waeup.kofa.applicants.workflow import (INITIALIZED, 28 STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED) 25 29 26 30 class ApplicantsUtils(grok.GlobalUtility): … … 57 61 payment.p_category = 'application' 58 62 return None 63 64 def getApplicantsStatistics(self,container): 65 state_stats = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0, 66 ADMITTED:0, NOT_ADMITTED:0, CREATED:0} 67 cat = getUtility(ICatalog, name='applicants_catalog') 68 code = container.code 69 year = int(code[-4:]) 70 target = code[:-4] 71 mxcode = target + str(year + 1) 72 for state in state_stats: 73 state_stats[state] = len(cat.searchResults( 74 state=(state, state), 75 applicant_id=(code, mxcode))) 76 return state_stats, None
Note: See TracChangeset for help on using the changeset viewer.