Changeset 7719 for main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
- Timestamp:
- 28 Feb 2012, 20:52:18 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.py
r7649 r7719 27 27 AdminTask, AddActionButton, SearchActionButton, BatchOpButton, ManageLink) 28 28 from waeup.sirp.interfaces import ISIRPObject 29 29 from waeup.sirp.interfaces import MessageFactory as _ 30 30 from waeup.sirp.accesscodes.interfaces import ( 31 31 IAccessCodeBatchContainer, IAccessCodeBatch, … … 41 41 grok.template('batchcontainer') 42 42 grok.require('waeup.manageACBatches') 43 44 label = 'Access Code Batches' 43 archive_button = _('Archive') 44 delete_button = _('Archive and delete') 45 46 label = _('Access Code Batches') 45 47 pnav = 0 46 48 … … 49 51 return 50 52 if not batches: 51 self.flash( 'No batch selected.')53 self.flash(_('No batch selected.')) 52 54 return 53 55 if isinstance(batches, basestring): … … 56 58 batch = self.context[name] 57 59 csv_file = batch.archive() 58 self.flash('Archived %s (%s)' % (name, csv_file)) 60 self.flash(_('Archived ${a} (${b})', 61 mapping = {'a':name, 'b':csv_file})) 59 62 if delete is None: 60 63 continue 61 64 del self.context[name] 62 self.flash( 'Deleted batch %s' % name)65 self.flash(_('Deleted batch ${a}', mapping = {'a':name})) 63 66 64 67 class AddBatchPage(SIRPAddFormPage): … … 67 70 grok.require('waeup.manageACBatches') 68 71 69 label = 'Create Access Code Batch'72 label = _('Create Access Code Batch') 70 73 pnav = 0 71 74 … … 73 76 'prefix', 'entry_num', 'cost') 74 77 75 @action( 'Create batch', style='primary')78 @action(_('Create batch'), style='primary') 76 79 def createBatch(self, **data): 77 80 creator = self.request.principal.id … … 85 88 self.redirect(self.url(self.context)) 86 89 87 @action( 'Cancel', validator=NullValidator)90 @action(_('Cancel'), validator=NullValidator) 88 91 def cancel(self, *args, **kw): 89 self.flash( 'Batch creation cancelled.')92 self.flash(_('Batch creation cancelled.')) 90 93 self.redirect(self.url(self.context)) 91 94 … … 97 100 grok.template('reimportbatchpage') 98 101 grok.require('waeup.manageACBatches') 99 100 label = 'Reimport Access Code Batches' 102 reimport_button = _('Reimport') 103 cancel_button = _('Cancel') 104 105 label = _('Reimport Access Code Batches') 101 106 pnav = 0 102 107 103 108 def update(self, filenames=None, reimport=None, cancel=None): 104 109 if cancel is not None: 105 self.flash( 'Reimport cancelled.')110 self.flash(_('Reimport cancelled.')) 106 111 self.redirect(self.url(self.context)) 107 112 return … … 109 114 return 110 115 if not filenames: 111 self.flash( 'No file chosen. Action cancelled.')116 self.flash(_('No file chosen. Action cancelled.')) 112 117 self.redirect(self.url(self.context)) 113 118 return … … 119 124 self.context.reimport(filename, userid) 120 125 except KeyError: 121 self.flash('This batch already exists: %s' % filename) 126 self.flash(_('This batch already exists: ${a}', 127 mapping = {'a':filename})) 122 128 continue 123 self.flash('Successfully reimported: %s' % filename) 129 self.flash(_('Successfully reimported: ${a}', 130 mapping = {'a':filename})) 124 131 self.redirect(self.url(self.context)) 125 132 … … 130 137 grok.require('waeup.manageACBatches') 131 138 pnav = 0 132 label = 'Search and Manage Access Codes' 139 label = _('Search and Manage Access Codes') 140 search_button = _('Search') 141 disable_button = _('Disable ACs') 142 enable_button = _('Enable ACs') 133 143 134 144 def update(self, *args, **kw): … … 154 164 if 'disable' in form: 155 165 try: 156 comment = u"AC disabled"166 comment = _(u"AC disabled") 157 167 self.context.disable(entry, comment) 158 self.flash( '%s disabled.' % entry)168 self.flash(_('${a} disabled.', mapping = {'a':entry})) 159 169 except InvalidTransitionError: 160 self.flash('%s: Disable transition not allowed.' % entry) 170 self.flash(_('${a}: Disable transition not allowed.', 171 mapping = {'a':entry})) 161 172 elif 'enable' in form: 162 173 try: 163 comment = u"AC re-enabled"174 comment = _(u"AC re-enabled") 164 175 self.context.enable(entry, comment) 165 self.flash( '%s (re-)enabled.' % entry)176 self.flash(_('${a} (re-)enabled.', mapping = {'a':entry})) 166 177 except InvalidTransitionError: 167 self.flash( '%s: Re-enable transition not allowed.' % entry)178 self.flash(_('${a}: Re-enable transition not allowed.', mapping = {'a':entry})) 168 179 self.hitlist = search(query=self.searchterm, 169 180 searchtype=self.searchtype, view=self) … … 175 186 grok.require('waeup.manageACBatches') 176 187 grok.context(IAccessCodeBatchContainer) 177 title = u'Access Code Batches'188 title = _(u'Access Code Batches') 178 189 parent_viewname = 'administration' 179 190 … … 195 206 grok.template('admintaskacbatches') 196 207 197 link_title = 'Access Code Batches'208 link_title = _('Access Code Batches') 198 209 target_viewname = 'accesscodes' 199 210 … … 204 215 grok.view(BatchContainerPage) 205 216 grok.require('waeup.manageACBatches') 206 text = 'Add Access Code Batch'217 text = _('Add Access Code Batch') 207 218 208 219 class ReimportBatchButton(BatchOpButton): … … 213 224 grok.require('waeup.manageACBatches') 214 225 target = 'reimport' 215 text = 'Reimport Access Code Batch'226 text = _('Reimport Access Code Batch') 216 227 217 228 class SearchAccessCodeButton(SearchActionButton): … … 221 232 grok.view(BatchContainerPage) 222 233 grok.require('waeup.manageACBatches') 223 text = 'Search Access Codes'234 text = _('Search Access Codes') 224 235 225 236 class ManageAccessCodes(ManageLink): … … 230 241 231 242 link = u'accesscodes' 232 text = u'Access Codes'243 text = _(u'Access Codes') -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.txt
r7631 r7719 175 175 >>> ctrl = browser.getControl(name='batches') 176 176 >>> ctrl.getControl(value='BLA-1').selected = True 177 >>> browser.getControl('Archive and Delete').click()177 >>> browser.getControl('Archive and delete').click() 178 178 >>> print browser.contents 179 179 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" … … 284 284 <td>APP-1-...</td> 285 285 <td>initialized</td> 286 <td>... - ACinitialized by Manager</td>286 <td>... - initialized by Manager</td> 287 287 ... 288 288 … … 303 303 <td>APP-1-...</td> 304 304 <td>initialized</td> 305 <td>... - ACinitialized by Manager</td>305 <td>... - initialized by Manager</td> 306 306 ... 307 307 308 308 And we can search for text in history messages of access 309 codes. Looking for the string `` ACinitialized`` we get nearly all309 codes. Looking for the string ``initialized`` we get nearly all 310 310 entries: 311 311 … … 313 313 >>> ctrl = browser.getControl(name='searchtype') 314 314 >>> ctrl.getControl(value='history').selected = True 315 >>> browser.getControl(name='searchterm').value = ' ACinitialized'315 >>> browser.getControl(name='searchterm').value = 'initialized' 316 316 >>> browser.getControl('Search').click() 317 317 >>> print browser.contents … … 322 322 <td>APP-1-<10-DIGITS></td> 323 323 <td>initialized</td> 324 <td>... - ACinitialized by Manager</td>324 <td>... - initialized by Manager</td> 325 325 ... 326 326 … … 334 334 >>> ctrl = browser.getControl(name='searchtype') 335 335 >>> ctrl.getControl(value='history').selected = True 336 >>> browser.getControl(name='searchterm').value = ' ACinitialized'336 >>> browser.getControl(name='searchterm').value = 'initialized' 337 337 >>> browser.getControl('Search').click() 338 338 -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/admintaskacbatches.pt
r7459 r7719 2 2 <a href="" 3 3 tal:attributes="href viewlet/link_target" 4 tal:content="viewlet/link_title">M anage</a>4 tal:content="viewlet/link_title">MANAGE</a> 5 5 </p> -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/batchcontainer.pt
r7467 r7719 1 <form method="POST">2 <p >1 <form i18n:domain="waeup.sirp" method="POST"> 2 <p i18n:translate=""> 3 3 The following batches are available: 4 4 </p> 5 6 5 <table> 7 6 <thead> 8 7 <tr> 9 8 <th> </th> 10 <th>Prefix</th><th>Entries/(invalidated)</th><th>Cost</th> 11 <th>Created</th><th>Creator</th> 9 <th i18n:translate="">Prefix</th> 10 <th i18n:translate="">Entries/(invalidated)</th> 11 <th i18n:translate="">Cost</th> 12 <th i18n:translate="">Date of Creation</th> 13 <th i18n:translate="">Creator</th> 12 14 </tr> 13 15 </thead> … … 32 34 2011-11-22 18:04:55 33 35 </td> 34 <td tal:content="batch/creator"> some user</td>36 <td tal:content="batch/creator">SOMEUSER</td> 35 37 </tr> 36 38 <tr tal:condition="not: context/values"> 37 <td colspan="5"><b>No batches yet</b></td>39 <td colspan="5"><b i18n:translate="">No batches yet</b></td> 38 40 </tr> 39 41 </tbody> 40 42 </table> 41 <input type="submit" class="btn" name="archive" value="Archive" /> 42 <input type="submit" class="btn" name="delete" value="Archive and Delete" /> 43 <input type="submit" class="btn" name="archive" 44 tal:attributes="value view/archive_button" /> 45 <input type="submit" class="btn" name="delete" 46 tal:attributes="value view/delete_button" /> 43 47 </form> -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/reimportbatchpage.pt
r7467 r7719 1 <p> Please select the files to reimport. Please note, that batches with same name have to be deleted before. 1 <p i18n:domain="waeup.sirp"> 2 Please select the files to reimport. Please note, that batches with 3 same name have to be deleted before. 2 4 </p> 3 <form method="POST" >5 <form method="POST" i18n:domain="waeup.sirp"> 4 6 <table> 5 7 <thead> … … 7 9 <th> 8 10 </th> 9 <th >File11 <th i18n:translate="">File 10 12 </th> 11 13 </tr> 12 14 </thead> 13 15 <tbody> 14 <tr tal:repeat="filename context/getImportFiles" tal:attributes="class python: repeat['filename'].odd() and 'even' or 'odd'"> <td> 15 <input type="checkbox" name="filenames" value="filename" tal:attributes="value filename" /> </td> 16 <td tal:content="filename">file.name</td> 16 <tr tal:repeat="filename context/getImportFiles" 17 tal:attributes="class python: repeat['filename'].odd() and 'even' or 'odd'"> <td> 18 <input type="checkbox" name="filenames" value="filename" 19 tal:attributes="value filename" /> </td> 20 <td tal:content="filename">FILENAME</td> 17 21 </tr> 18 22 <tr tal:condition="python: len(list(context.getImportFiles())) == 0"> 19 <td colspan="5"><b >No import batches available</b></td>23 <td colspan="5"><b i18n:translate="">No import batches available</b></td> 20 24 </tr> 21 25 </tbody> 22 26 </table> 23 <input type="submit" class="btn primary" name="reimport" value="Reimport" /> 24 <input type="submit" class="btn" name="cancel" value="Cancel" /> 27 <input type="submit" class="btn primary" name="reimport" 28 tal:attributes="value view/reimport_button" /> 29 <input type="submit" class="btn" name="cancel" 30 tal:attributes="value view/cancel_button" /> 25 31 </form> -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser_templates/searchpage.pt
r7459 r7719 1 <form method="POST"> 2 1 <form method="POST" i18n:domain="waeup.sirp"> 3 2 <br /> 4 5 <input type="submit" class="btn primary" name="search" value="Search" /> 6 for access codes 7 3 <input type="submit" class="btn primary" name="search" 4 tal:attributes="value view/search_button" /> 5 <span i18n:translate="">for access codes</span> 8 6 <select name="searchtype"> 9 <option value="code">with PIN</option>10 <option value="batch_serial">with serial</option>11 <option value="history">with message term</option>7 <option i18n:translate="" value="code">with PIN</option> 8 <option i18n:translate="" value="batch_serial">with serial</option> 9 <option i18n:translate="" value="history">with message term</option> 12 10 </select> 13 14 11 <input type="text" name="searchterm" /> 15 16 12 <p> </p> 17 13 <div tal:condition="view/hitlist"> … … 25 21 <tr> 26 22 <th> </th> 27 <th width="50px" >Serial</th>28 <th >AC</th>29 <th >State</th>30 <th >Owner</th>31 <th >History</th>23 <th width="50px" i18n:translate="">Serial</th> 24 <th i18n:translate="">AC</th> 25 <th i18n:translate="">State</th> 26 <th i18n:translate="">Owner</th> 27 <th i18n:translate="">History</th> 32 28 </tr> 33 29 </thead> … … 47 43 </table> 48 44 <div> 49 <input type="submit" class="btn" name="disable" value="Disable ACs" /> 50 <input type="submit" class="btn" name="enable" value="Enable ACs" /> 45 <input type="submit" class="btn" name="disable" 46 tal:attributes="value view/disable_button" /> 47 <input type="submit" class="btn" name="enable" 48 tal:attributes="value view/enable_button" /> 51 49 </div> 52 50 -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/interfaces.py
r7321 r7719 21 21 from zope.interface import Interface 22 22 from waeup.sirp.interfaces import ISIRPObject 23 from waeup.sirp.interfaces import MessageFactory as _ 23 24 24 25 class IAccessCode(ISIRPObject): … … 26 27 """ 27 28 batch_serial = schema.Int( 28 title = u'Serial number inside batch',29 title = _(u'Serial number inside batch'), 29 30 ) 30 31 batch_prefix = schema.TextLine( 31 title = u'Prefix inside batch',32 title = _(u'Prefix inside batch'), 32 33 ) 33 34 batch_num = schema.Int( 34 title = u'Batch number',35 title = _(u'Batch number'), 35 36 ) 36 37 random_num = schema.TextLine( 37 title = u'Random part of access code.',38 title = _(u'Random part of access code.'), 38 39 ) 39 40 cost = schema.Float( 40 title = u'Cost of access code',41 title = _(u'Cost of access code'), 41 42 default = 0.0, min = 0.0, 42 43 ) 43 44 state = schema.TextLine( 44 title = u'Workflow state',45 title = _(u'Workflow state'), 45 46 ) 46 47 representation = schema.TextLine( 47 title = u'Complete title of access code',48 title = _(u'Complete title of access code'), 48 49 ) 49 50 owner = schema.TextLine( 50 title = u'Purchaser',51 title = _(u'Purchaser'), 51 52 ) 52 53 history = schema.Text( 53 title = u'The history of access code as lines',54 title = _(u'The history of access code as lines'), 54 55 default = u'', 55 56 readonly = True, … … 60 61 """ 61 62 creation_date = schema.Date( 62 title = u'Creation date',63 title = _(u'Creation date'), 63 64 ) 64 65 creator = schema.TextLine( 65 title = u'Batch creator',66 title = _(u'Batch creator'), 66 67 ) 67 68 prefix = schema.TextLine( 68 title = u'Batch prefix',69 title = _(u'Batch prefix'), 69 70 ) 70 71 num = schema.Int( 71 title = u'Batch number (1-3 digits)',72 title = _(u'Batch number (1-3 digits)'), 72 73 min = 0, max = 999, 73 74 ) 74 75 entry_num = schema.Int( 75 title = u'Number of access codes',76 title = _(u'Number of access codes'), 76 77 default = 1000, min = 0, 77 78 ) 78 79 cost = schema.Float( 79 title = u'Cost of access code',80 title = _(u'Cost of access code'), 80 81 default = 0.0, min = 0.0, 81 82 ) 82 83 disabled_num = schema.Int( 83 title = u'Number of disabled access codes inside the batch',84 title = _(u'Number of disabled access codes inside the batch'), 84 85 default = 0, 85 86 readonly = True, 86 87 ) 87 88 used_num = schema.Int( 88 title = u'Number of used access codes inside the batch',89 title = _(u'Number of used access codes inside the batch'), 89 90 default = 0, 90 91 readonly = True, -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_accesscode.py
r7321 r7719 188 188 history = IObjectHistory(self.ac1) 189 189 msgs = history.messages 190 assert msgs[-1].endswith(' ACused by system')190 assert msgs[-1].endswith('used by system') 191 191 192 192 class AccessCodeTests(FunctionalTestCase): … … 232 232 # Access codes have a history. 233 233 match = re.match( 234 '^....-..-.. ..:..:.. - ACinitialized by system',234 '^....-..-.. ..:..:.. - initialized by system', 235 235 self.ac1.history) 236 236 assert match is not None -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/workflow.py
r7689 r7719 20 20 """ 21 21 import grok 22 from zope.i18n import translate 23 from zope.component import getUtility 22 24 from datetime import datetime 23 25 from hurry.workflow.workflow import Transition, WorkflowState, NullCondition 24 26 from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent 25 27 from waeup.sirp.accesscodes.interfaces import IAccessCode 26 from waeup.sirp.interfaces import IObjectHistory, ISIRPWorkflowInfo 28 from waeup.sirp.interfaces import IObjectHistory, ISIRPWorkflowInfo, ISIRPUtils 27 29 from waeup.sirp.interfaces import MessageFactory as _ 28 30 from waeup.sirp.workflow import SIRPWorkflow, SIRPWorkflowInfo … … 131 133 def handle_accesscode_transition_event(obj, event): 132 134 # append message to history 135 portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE 133 136 if event.comment is not None: 134 msg = '%s' %event.comment137 msg = event.comment 135 138 else: 136 msg = 'AC %s' % event.destination 137 139 msg = ac_states_dict[event.destination] 138 140 history = IObjectHistory(obj) 139 141 history.addMessage(msg)
Note: See TracChangeset for help on using the changeset viewer.