Changeset 6452 for main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
- Timestamp:
- 22 Jun 2011, 13:51:55 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py
r6450 r6452 56 56 57 57 @property 58 def disabled(self):59 return IWorkflowState(self).getState() == DISABLED60 61 @property62 def used(self):63 return IWorkflowState(self).getState() == USED64 65 @property66 58 def history(self): 67 59 history = IObjectHistory(self) … … 174 166 ) 175 167 writer = csv.writer(open(csv_path, 'w'), quoting=csv.QUOTE_ALL) 176 writer.writerow(['prefix', 'serial', 'ac', 'used', 177 'disabled', 'history']) 168 writer.writerow(['prefix', 'serial', 'ac', 'status', 'history']) 178 169 writer.writerow([self.prefix, '%0.2f' % self.cost, str(self.num), 179 170 str(self.entry_num)]) … … 184 175 writer.writerow([ 185 176 self.prefix, value.batch_serial, value.representation, 186 value.used and '1' or '0', value.disabled and '1' or '0', 187 value.history 177 value.status, value.history 188 178 ]) 189 179 return os.path.basename(csv_path) … … 292 282 return 293 283 294 #def search(self, searchterm, searchtype):295 # """Look for access-codes that comply with the given params.296 # """297 # results = []298 # return results299 300 284 def getAccessCode(self, ac_id): 301 285 """Get the AccessCode with ID ``ac_id`` or ``KeyError``. … … 332 316 reenable_accesscode(ac_id, user_id) 333 317 return 334 335 #def invalidate(self, ac_id):336 # """Invalidate the AC with ID ``ac_id``.337 # """338 # ac = self.getAccessCode(ac_id)339 # if ac is None:340 # return341 # ac.__parent__.invalidate(ac_id)342 # return343 344 318 345 319 class AccessCodePlugin(grok.GlobalUtility): -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.txt
r6450 r6452 306 306 ... sorted(os.listdir(ac_storage))[-2]) 307 307 >>> print open(archive_file, 'rb').read() 308 "prefix","serial","ac"," used","disabled","history"308 "prefix","serial","ac","status","history" 309 309 "BLA","19.12","1","3" 310 "BLA","0","BLA-1-<10-DIGITS>"," 0","0","..."311 "BLA","1","BLA-1-<10-DIGITS>"," 0","0","..."312 "BLA","2","BLA-1-<10-DIGITS>"," 0","0","..."310 "BLA","0","BLA-1-<10-DIGITS>","initialized","..." 311 "BLA","1","BLA-1-<10-DIGITS>","initialized","..." 312 "BLA","2","BLA-1-<10-DIGITS>","initialized","..." 313 313 314 314 Clean up: -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/reimportbatchpage.pt
r5132 r6452 1 <h3>Reimport Access -Code Batches</h3>1 <h3>Reimport Access Code Batches</h3> 2 2 <p> 3 3 Please select the files to reimport. Please note, that batches with -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/catalog.py
r6450 r6452 17 17 code = grok.index.Field(attribute='representation') 18 18 history = grok.index.Text(attribute='history') 19 disabled = grok.index.Field(attribute='disabled')20 used = grok.index.Field(attribute='used')21 19 batch_serial = grok.index.Field(attribute='batch_serial') 22 20 status = grok.index.Field(attribute='status') -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/interfaces.py
r6450 r6452 26 26 status = schema.TextLine( 27 27 title = u'Workflow status', 28 )29 disabled = schema.Bool(30 title = u'Access code is disabled',31 default = False,32 readonly = True,33 )34 used = schema.Bool(35 title = u'Access code is already in use.',36 default = False,37 readonly = True,38 28 ) 39 29 representation = schema.TextLine( -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_accesscodes.py
r6423 r6452 106 106 107 107 def test_invalidate_accesscode(self): 108 assert self.ac1. used is False108 assert self.ac1.status != USED 109 109 result = invalidate_accesscode('APP-1-11111111') 110 assert self.ac1. used is True110 assert self.ac1.status == USED 111 111 assert result is True 112 112 113 113 def test_disable_accesscode_unused(self): 114 114 # we can disable initialized acs 115 assert self.ac1. disabled is False115 assert self.ac1.status != USED 116 116 disable_accesscode('APP-1-11111111') 117 assert self.ac1. disabled is True117 assert self.ac1.status == DISABLED 118 118 119 119 def test_disable_accesscode_used(self): 120 120 # we can disable already used acs 121 assert self.ac1. disabled is False121 assert self.ac1.status != DISABLED 122 122 invalidate_accesscode('APP-1-11111111') 123 123 disable_accesscode('APP-1-11111111') 124 assert self.ac1. disabled is True124 assert self.ac1.status == DISABLED 125 125 126 126 def test_reenable_accesscode(self): … … 129 129 result = reenable_accesscode('APP-1-11111111') 130 130 assert result is True 131 assert self.ac1. disabled is False131 assert self.ac1.status != USED 132 132 133 133 def test_fire_transition(self): -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_catalog.py
r6438 r6452 110 110 # Now we want to find the disabled access code 111 111 cat = queryUtility(ICatalog, name='accesscodes_catalog') 112 results1 = cat.searchResults( disabled=(True, True))113 results2 = cat.searchResults( disabled=(False, False))112 results1 = cat.searchResults(status=('disabled', 'disabled')) 113 results2 = cat.searchResults(status=('initialized', 'initialized')) 114 114 results1 = [x for x in results1] # Turn results generator into list 115 115 # We found 1 accescode disabled … … 125 125 # Now we want to find the invalidated access code 126 126 cat = queryUtility(ICatalog, name='accesscodes_catalog') 127 results1 = cat.searchResults( used=(True, True))128 results2 = cat.searchResults( used=(False, False))127 results1 = cat.searchResults(status=('used', 'used')) 128 results2 = cat.searchResults(status=('initialized', 'initialized')) 129 129 results1 = [x for x in results1] # Turn results generator into list 130 130 # We found 1 accescode used … … 145 145 # exactly one access code. 146 146 results = cat.searchResults(history='Tester', 147 used=(True, True),147 status=('used', 'used'), 148 148 code=('APP-1-11111111', 'APP-1-22222222')) 149 149 assert len(results) == 1 … … 154 154 # immediately in catalog 155 155 cat = queryUtility(ICatalog, name='accesscodes_catalog') 156 result = cat.searchResults( used=(True, True))156 result = cat.searchResults(status=('used', 'used')) 157 157 assert len(result) == 0 158 158 invalidate_accesscode('APP-1-11111111') 159 result = cat.searchResults( used=(True, True))159 result = cat.searchResults(status=('used', 'used')) 160 160 assert len(result) == 1
Note: See TracChangeset for help on using the changeset viewer.