"""UI components for accesscodes. """ import grok from waeup.sirp.browser import WAeUPPage, WAeUPAddFormPage from waeup.sirp.browser.breadcrumbs import Breadcrumb from waeup.sirp.browser.viewlets import AdminTask, AddActionButton from waeup.sirp.interfaces import IWAeUPObject from waeup.sirp.accesscodes.interfaces import IAccessCodeBatchContainer grok.context(IWAeUPObject) class BatchContainerPage(WAeUPPage): grok.name('index') grok.context(IAccessCodeBatchContainer) grok.template('batchcontainer') title = 'Access Code Batches' pnav = 0 class AddBatchPage(WAeUPAddFormPage): grok.name('add') grok.context(IAccessCodeBatchContainer) title = label = 'Create a WAeUP Scratch Card Batch' pnav = 0 @grok.action('Create batch') def createBatch(self, **data): self.flash('Batch created') self.redirect(self.url(self.context)) class BatchContainerBreadcrumb(Breadcrumb): """A breadcrumb for ac batch containers. """ grok.context(IAccessCodeBatchContainer) title = u'Access Code Batches' parent_viewname = 'administration' class AdminTaskManageACBatches(AdminTask): """Entry on administration page that links to batch container. """ grok.order(5) grok.require('waeup.manageUniversity') grok.template('admintaskacbatches') link_title = 'Manage access-code batches' target_viewname = 'accesscodes' class CreateBatchButton(AddActionButton): """Action button on batch container page which links to batch creation. """ grok.context(IAccessCodeBatchContainer) grok.view(BatchContainerPage) grok.require('waeup.manageUniversity') text = 'Add Scratch Card Batch'