Changeset 6403 for main/waeup.sirp/branches/accesscodes-with-workflow
- Timestamp:
- 18 Jun 2011, 06:03:36 (14 years ago)
- Location:
- main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/accesscodes.py
r6387 r6403 66 66 self.entry_num = entry_num 67 67 self.num = num 68 self.invalidated_num = 069 self.disabled_num = 068 #self.invalidated_num = 0 69 #self.disabled_num = 0 70 70 self._entries = list() 71 71 self._acids = OIBTree() … … 124 124 return 125 125 126 def invalidate(self, ac_id, student_id=None):127 """Invalidate the AC with ID ``ac_id``.128 """129 num = self._acids[ac_id]130 self.invalidated_num += 1131 132 def disable(self, ac_id, user_id=None):133 """Disable the AC with ID ``ac_id``.134 135 ``user_id`` is the user ID of the user triggering the136 process. Already disabled ACs are left untouched.137 """138 num = self._acids[ac_id]139 ac = self.getAccessCode(ac_id)140 if ac._disabled == True:141 return142 self.disabled_num += 1143 144 def enable(self, ac_id):145 """(Re-)enable the AC with ID ``ac_id``.146 147 This leaves the given AC in state ``unused``. Already enabled148 ACs are left untouched.149 """150 num = self._acids[ac_id]151 self.disabled_num -= 1126 #def invalidate(self, ac_id, student_id=None): 127 # """Invalidate the AC with ID ``ac_id``. 128 # """ 129 # num = self._acids[ac_id] 130 # self.invalidated_num += 1 131 132 #def disable(self, ac_id, user_id=None): 133 # """Disable the AC with ID ``ac_id``. 134 135 # ``user_id`` is the user ID of the user triggering the 136 # process. Already disabled ACs are left untouched. 137 # """ 138 # num = self._acids[ac_id] 139 # ac = self.getAccessCode(ac_id) 140 # if ac._disabled == True: 141 # return 142 # self.disabled_num += 1 143 144 #def enable(self, ac_id): 145 # """(Re-)enable the AC with ID ``ac_id``. 146 147 # This leaves the given AC in state ``unused``. Already enabled 148 # ACs are left untouched. 149 # """ 150 # num = self._acids[ac_id] 151 # self.disabled_num -= 1 152 152 153 153 def createCSVLogFile(self): … … 314 314 return None 315 315 316 def disable(self, ac_id, user_id):317 """Disable the AC with ID ``ac_id``.318 319 ``user_id`` is the user ID of the user triggering the320 process. Already disabled ACs are left untouched.321 """322 ac = self.getAccessCode(ac_id)323 if ac is None:324 return325 ac.__parent__.disable(ac_id, user_id)326 return327 328 def enable(self, ac_id):329 """(Re-)enable the AC with ID ``ac_id``.330 331 This leaves the given AC in state ``unused``. Already enabled332 ACs are left untouched.333 """334 ac = self.getAccessCode(ac_id)335 if ac is None:336 return337 ac.__parent__.enable(ac_id)338 return339 340 def invalidate(self, ac_id):341 """Invalidate the AC with ID ``ac_id``.342 """343 ac = self.getAccessCode(ac_id)344 if ac is None:345 return346 ac.__parent__.invalidate(ac_id)347 return316 #def disable(self, ac_id, user_id): 317 # """Disable the AC with ID ``ac_id``. 318 319 # ``user_id`` is the user ID of the user triggering the 320 # process. Already disabled ACs are left untouched. 321 # """ 322 # ac = self.getAccessCode(ac_id) 323 # if ac is None: 324 # return 325 # ac.__parent__.disable(ac_id, user_id) 326 # return 327 328 #def enable(self, ac_id): 329 # """(Re-)enable the AC with ID ``ac_id``. 330 331 # This leaves the given AC in state ``unused``. Already enabled 332 # ACs are left untouched. 333 # """ 334 # ac = self.getAccessCode(ac_id) 335 # if ac is None: 336 # return 337 # ac.__parent__.enable(ac_id) 338 # return 339 340 #def invalidate(self, ac_id): 341 # """Invalidate the AC with ID ``ac_id``. 342 # """ 343 # ac = self.getAccessCode(ac_id) 344 # if ac is None: 345 # return 346 # ac.__parent__.invalidate(ac_id) 347 # return 348 348 349 349 -
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/browser.py
r6388 r6403 121 121 self.searchresults = [] 122 122 for result in searchresults: 123 status = u'unused'124 if result.disabled is True:125 status = u'disabled by %s on %s' % (126 result.student_id,127 result.invalidation_date.strftime('%c')128 )129 elif result.invalidation_date is not None:130 status = u'invalidated by %s on %s' % (131 result.student_id,132 result.invalidation_date.strftime('%c')133 )123 #status = u'unused' 124 #if result.disabled is True: 125 # status = u'disabled by %s on %s' % ( 126 # result.student_id, 127 # result.invalidation_date.strftime('%c') 128 # ) 129 #elif result.invalidation_date is not None: 130 # status = u'invalidated by %s on %s' % ( 131 # result.student_id, 132 # result.invalidation_date.strftime('%c') 133 # ) 134 134 entry = dict( 135 135 serial = result.batch_serial, 136 code = result.representation ,137 status = status)136 code = result.representation) 137 #status = status) 138 138 self.searchresults.append(entry) 139 139 if entries is None: … … 141 141 if isinstance(entries, basestring): 142 142 entries = [entries] 143 for entry in entries:144 if disable is not None:145 self.context.disable(entry, self.request.principal.id)146 self.flash('disabled %s' % entry)147 elif enable is not None:148 self.context.enable(entry)149 self.flash('(re-)enabled %s' % entry)143 #for entry in entries: 144 # if disable is not None: 145 # self.context.disable(entry, self.request.principal.id) 146 # self.flash('disabled %s' % entry) 147 # elif enable is not None: 148 # self.context.enable(entry) 149 # self.flash('(re-)enabled %s' % entry) 150 150 return 151 151 -
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/browser.txt
r5423 r6403 112 112 ... 113 113 ...5 114 .../115 ...0116 114 ... 117 115 ...12.12... … … 139 137 >>> browser.getControl(name='form.cost').value = '19.12' 140 138 >>> browser.getControl('Create batch').click() 141 142 We also invalidate one entry:143 144 >>> batch = getRootFolder()['myuniversity']['accesscodes']['BLA-1']145 >>> ac = list(batch.entries())[0]146 >>> batch.invalidate(ac.representation)147 139 148 140 Creating Archive Files … … 311 303 ... sorted(os.listdir(ac_storage))[-2]) 312 304 >>> print open(archive_file, 'rb').read() 313 "prefix","serial","ac"," student","date"305 "prefix","serial","ac","date" 314 306 "BLA","19.12","1","3" 315 "BLA","0","BLA-1-<10-DIGITS>" ,"","..."316 "BLA","1","BLA-1-<10-DIGITS>" ,"",""317 "BLA","2","BLA-1-<10-DIGITS>" ,"",""307 "BLA","0","BLA-1-<10-DIGITS>" 308 "BLA","1","BLA-1-<10-DIGITS>" 309 "BLA","2","BLA-1-<10-DIGITS>" 318 310 319 311 Clean up: -
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/browser_templates/batchcontainer.pt
r5931 r6403 10 10 <tr> 11 11 <th> </th> 12 <th>Prefix</th><th>Entries /(invalidated)</th><th>Cost</th>12 <th>Prefix</th><th>Entries</th><th>Cost</th> 13 13 <th>Created</th><th>Creator</th> 14 14 </tr> … … 28 28 <td> 29 29 <span tal:replace="batch/entry_num">1012</span> 30 /31 <span tal:replace="batch/invalidated_num">512</span>32 30 </td> 33 31 <td tal:content="batch/cost">12.12</td> -
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/browser_templates/searchpage.pt
r5918 r6403 20 20 <div tal:condition="view/searchresults"> 21 21 <h3>Search Results</h3> 22 <table >22 <table class = "zebra"> 23 23 <thead> 24 24 <tr> … … 28 28 </thead> 29 29 <tbody> 30 <tr tal:repeat="item view/searchresults" 31 tal:attributes="class python: repeat['item'].odd() and 'even' or 'odd'"> 30 <tr tal:repeat="item view/searchresults"> 32 31 <td><input type="checkbox" name="entries" 33 32 tal:attributes="value item/code" /></td> 34 33 <td tal:content="item/serial">1</td> 35 34 <td tal:content="item/code">APP-1-1234567890</td> 36 <td tal:content="item/status">unused</td>37 35 </tr> 38 36 </tbody> -
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/interfaces.py
r5098 r6403 12 12 ) 13 13 batch_prefix = schema.TextLine( 14 title = u' Prefix inside batch',14 title = u'Batch prefix', 15 15 ) 16 16 batch_num = schema.Int( … … 24 24 default = 0.0, min = 0.0, 25 25 ) 26 invalidation_date = schema.Datetime(27 title = u'Datetime of invalidation',28 required = False,29 default = None,30 )31 student_id = schema.TextLine(32 title = u'Student ID or registration number',33 required = False,34 default = None,35 )26 #invalidation_date = schema.Datetime( 27 # title = u'Datetime of invalidation', 28 # required = False, 29 # default = None, 30 # ) 31 #student_id = schema.TextLine( 32 # title = u'Student ID or registration number', 33 # required = False, 34 # default = None, 35 # ) 36 36 representation = schema.TextLine( 37 37 title = u'Complete title of access code', -
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/accesscodes/workflow.py
r6359 r6403 35 35 DISABLED = 'disabled' 36 36 37 def invalidate_action(wf, context):38 batch = getattr(context, '__parent__', None)39 if batch is None:40 return41 pin = context.representation42 batch.invalidate(pin)43 return37 #def invalidate_action(wf, context): 38 # batch = getattr(context, '__parent__', None) 39 # if batch is None: 40 # return 41 # pin = context.representation 42 # batch.invalidate(pin) 43 # return 44 44 45 def disable_action(wf, context):46 batch = getattr(context, '__parent__', None)47 if batch is None:48 return49 pin = context.representation50 batch.disable(pin)51 return45 #def disable_action(wf, context): 46 # batch = getattr(context, '__parent__', None) 47 # if batch is None: 48 # return 49 # pin = context.representation 50 # batch.disable(pin) 51 # return 52 52 53 def reenable_action(wf, context):54 batch = getattr(context, '__parent__', None)55 if batch is None:56 return57 pin = context.representation58 batch.enable(pin)59 return53 #def reenable_action(wf, context): 54 # batch = getattr(context, '__parent__', None) 55 # if batch is None: 56 # return 57 # pin = context.representation 58 # batch.enable(pin) 59 # return 60 60 61 61 ACCESSCODE_TRANSITIONS = ( … … 71 71 title = 'Use PIN', 72 72 source = INITIALIZED, 73 destination = USED ,74 action = invalidate_action),73 destination = USED), 74 #action = invalidate_action), 75 75 76 76 Transition( … … 78 78 title = 'Disable unused PIN', 79 79 source = INITIALIZED, 80 destination = DISABLED ,81 action = disable_action),80 destination = DISABLED), 81 #action = disable_action), 82 82 83 83 Transition( … … 85 85 title = 'Disable used PIN', 86 86 source = USED, 87 destination = DISABLED ,88 action = disable_action),87 destination = DISABLED), 88 #action = disable_action), 89 89 90 90 Transition( … … 92 92 title = 'Reenable disabled PIN', 93 93 source = DISABLED, 94 destination = INITIALIZED ,95 action = reenable_action),94 destination = INITIALIZED), 95 #action = reenable_action), 96 96 ) 97 97 -
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/applicants/browser.py
r6397 r6403 562 562 code = course_admitted.code 563 563 return '<a href="%s">%s - %s</a>' %(url,code,title) 564 return ' not yet admitted'564 return '' 565 565 566 566 class PDFActionButton(ManageActionButton): -
main/waeup.sirp/branches/accesscodes-with-workflow/src/waeup/sirp/applicants/tests/test_authentication.py
r6179 r6403 51 51 class FakeAccessCode(object): 52 52 def __init__(self, repr, inv_date=None, disabled=False): 53 self.invalidation_date = inv_date53 #self.invalidation_date = inv_date 54 54 self.representation = repr 55 self.disabled = disabled55 #self.disabled = disabled 56 56 57 57 class FakeInvAccessCode(object): … … 82 82 'APP': FakeBatch({ 83 83 'APP-12345': FakeAccessCode('APP-12345'), 84 'APP-54321': FakeAccessCode('APP-54321', True),84 #'APP-54321': FakeAccessCode('APP-54321', True), 85 85 'APP-11111': FakeAccessCode('APP-11111'), 86 86 'APP-22222': FakeAccessCode('APP-22222'), 87 'APP-33333': FakeAccessCode('APP-33333', True),88 'APP-44444': FakeAccessCode('APP-44444', True),89 'APP-55555': FakeAccessCode('APP-55555', True),90 'APP-66666': FakeAccessCode('APP-66666', True, False),91 'APP-77777': FakeAccessCode('APP-77777', False, False),87 #'APP-33333': FakeAccessCode('APP-33333', True), 88 #'APP-44444': FakeAccessCode('APP-44444', True), 89 #'APP-55555': FakeAccessCode('APP-55555', True), 90 #'APP-66666': FakeAccessCode('APP-66666', True, False), 91 #'APP-77777': FakeAccessCode('APP-77777', False, False), 92 92 }) 93 93 } … … 151 151 # Possible cases, where formal correct authentication 152 152 # data is not valid: 153 result = self.plugin.authenticateCredentials(154 dict(accesscode='APP-33333'))155 assert result is None156 157 result = self.plugin.authenticateCredentials(158 159 assert result is None160 161 result = self.plugin.authenticateCredentials(162 dict(accesscode='APP-66666'))163 assert result is None164 165 result = self.plugin.authenticateCredentials(166 dict(accesscode='APP-77777'))167 assert result is None168 return153 #result = self.plugin.authenticateCredentials( 154 # dict(accesscode='APP-33333')) 155 #assert result is None 156 157 #esult = self.plugin.authenticateCredentials( 158 # dict(accesscode='APP-55555')) 159 #assert result is None 160 161 #result = self.plugin.authenticateCredentials( 162 # dict(accesscode='APP-66666')) 163 #assert result is None 164 165 #result = self.plugin.authenticateCredentials( 166 # dict(accesscode='APP-77777')) 167 #assert result is None 168 #return 169 169 170 170 def test_valid_credentials(self): … … 181 181 assert result is not None 182 182 183 result = self.plugin.authenticateCredentials(184 dict(accesscode='APP-54321'))185 assert result is not None183 #result = self.plugin.authenticateCredentials( 184 # dict(accesscode='APP-54321')) 185 #assert result is not None 186 186 187 187 # check the `principalInfo` method of authenticator
Note: See TracChangeset for help on using the changeset viewer.