- Timestamp:
- 24 Aug 2015, 05:56:39 (9 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/applicant.py
r13213 r13216 83 83 84 84 @property 85 def record_used(self): 85 def container_code(self): 86 try: 87 code = self.__parent__.code 88 except AttributeError: # in unit tests 89 return 86 90 if (self.password, 87 91 self.firstname, 88 92 self.lastname, 89 self.email) != (None, None, None, None): 90 return True 91 return False 92 93 @property 94 def container_code(self): 95 try: 96 code = self.__parent__.code 97 except AttributeError: # in unit tests 98 return 99 return code 93 self.email) == (None, None, None, None): 94 return code + '-' 95 return code + '+' 100 96 101 97 @property … … 236 232 email = index.Field(attribute='email') 237 233 state = index.Field(attribute='state') 238 record_used = index.Field(attribute='record_used')234 container_code = index.Field(attribute='container_code') 239 235 240 236 class ApplicantFactory(grok.GlobalUtility): -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/export.py
r13080 r13216 101 101 # unwanted excel automatic 102 102 value = str('%s#' % value) 103 elif name == 'container_code': 104 value = value.strip('+') 103 105 return super( 104 106 ApplicantExporter, self).mangle_value( … … 117 119 """Export all applicants into filepath as CSV data. 118 120 If `filepath` is ``None``, a raw string with CSV data is returned. 121 Only used records are being exported. 119 122 """ 120 123 catalog = queryUtility( … … 126 129 # We therefore search for applicant_id. 127 130 applicant_id=(None, None)) 128 return self.export(applicants, filepath) 131 used = [value for value in applicants if value.container_code.endswith('+')] 132 return self.export(used, filepath=filepath) 129 133 130 134 def export_filtered(self, site, filepath=None, **kw): 131 135 """Export filtered applicants in container denoted by keywords (`kw`). 132 136 If `filepath` is ``None``, a raw string with CSV data should 133 be returned. 137 be returned. Only used records are being exported. 134 138 """ 135 139 container = grok.getSite()['applicants'][kw['container']] 136 return self.export(container.values(), filepath=filepath) 140 container_values = container.values() 141 used = [value for value in container_values if value.container_code.endswith('+')] 142 return self.export(used, filepath=filepath) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py
r13213 r13216 327 327 """ 328 328 state = Attribute('Application state of an applicant') 329 record_used = Attribute('True if password or any required field has been set')330 329 history = Attribute('Object history, a list of messages') 331 330 display_fullname = Attribute('The fullname of an applicant') 332 331 application_number = Attribute('The key under which the record is stored') 333 container_code = Attribute('Code of the parent container ')332 container_code = Attribute('Code of the parent container plus additional information if record is used or not') 334 333 translated_state = Attribute('Real name of the application state') 335 334 special = Attribute('True if special application') -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/root.py
r13214 r13216 94 94 try: 95 95 cat = getUtility(ICatalog, name='applicants_catalog') 96 if ' record_used' not in cat.keys():96 if 'container_code' not in cat.keys(): 97 97 nothing_to_do = False 98 cat[u' record_used'] = FieldIndex(field_name=u'record_used')98 cat[u'container_code'] = FieldIndex(field_name=u'container_code') 99 99 cat.updateIndexes() 100 100 logger.info( 101 '%s: record_usedindex added to applicants_catalog.'101 '%s: container_code index added to applicants_catalog.' 102 102 % self.log_prefix) 103 103 except ComponentLookupError: # in unit tests -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicant.py
r13213 r13216 191 191 return 192 192 193 def test_record_used(self): 194 self.applicant.password is None 195 self.applicant.firstname is None 196 self.applicant.lastname is None 197 self.applicant.email is None 198 self.applicant.record_used is False 199 self.applicant.firstname is 'Anna' 200 self.applicant.record_used is True 193 def test_container_code(self): 194 fake_container = grok.Container() 195 fake_container.__name__ = 'folder' 196 fake_container.code = 'folder' 197 appl = Applicant() 198 appl.password is None 199 appl.firstname is None 200 appl.lastname is None 201 appl.email is None 202 appl.container_code is 'folder-' 203 appl.firstname is 'Anna' 204 appl.container_code is 'folder+' 205 return 201 206 202 207 class ApplicantFactoryTest(FunctionalTestCase): -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py
r13133 r13216 88 88 cat = getUtility(ICatalog, name='applicants_catalog') 89 89 code = container.code 90 year = int(code[-4:])91 target = code[:-4]92 mxcode = target + str(year + 1)93 90 for state in state_stats: 94 state_stats[state] = len(cat.searchResults( 95 state=(state, state), 96 applicant_id=(code, mxcode))) 91 if state == 'initialized': 92 results = cat.searchResults( 93 state=(state, state), 94 container_code=(code + '+', code + '+')) 95 state_stats[state] = len(results) 96 else: 97 results = cat.searchResults( 98 state=(state, state), 99 container_code=(code + '+', code + '-')) 100 state_stats[state] = len(results) 97 101 return state_stats, None 98 102
Note: See TracChangeset for help on using the changeset viewer.