[5082] | 1 | """UI components for accesscodes. |
---|
| 2 | """ |
---|
| 3 | import grok |
---|
[5084] | 4 | from waeup.sirp.browser import WAeUPPage, WAeUPAddFormPage |
---|
[5082] | 5 | from waeup.sirp.browser.breadcrumbs import Breadcrumb |
---|
[5084] | 6 | from waeup.sirp.browser.viewlets import AdminTask, AddActionButton |
---|
[5082] | 7 | from waeup.sirp.interfaces import IWAeUPObject |
---|
| 8 | |
---|
| 9 | from waeup.sirp.accesscodes.interfaces import IAccessCodeBatchContainer |
---|
| 10 | |
---|
| 11 | grok.context(IWAeUPObject) |
---|
| 12 | |
---|
| 13 | class BatchContainerPage(WAeUPPage): |
---|
| 14 | grok.name('index') |
---|
| 15 | grok.context(IAccessCodeBatchContainer) |
---|
| 16 | grok.template('batchcontainer') |
---|
| 17 | |
---|
| 18 | title = 'Access Code Batches' |
---|
| 19 | pnav = 0 |
---|
| 20 | |
---|
[5084] | 21 | class AddBatchPage(WAeUPAddFormPage): |
---|
| 22 | grok.name('add') |
---|
| 23 | grok.context(IAccessCodeBatchContainer) |
---|
| 24 | |
---|
| 25 | title = label = 'Create a WAeUP Scratch Card Batch' |
---|
| 26 | pnav = 0 |
---|
| 27 | |
---|
| 28 | @grok.action('Create batch') |
---|
| 29 | def createBatch(self, **data): |
---|
| 30 | self.flash('Batch created') |
---|
| 31 | self.redirect(self.url(self.context)) |
---|
| 32 | |
---|
[5082] | 33 | class BatchContainerBreadcrumb(Breadcrumb): |
---|
| 34 | """A breadcrumb for ac batch containers. |
---|
| 35 | """ |
---|
| 36 | grok.context(IAccessCodeBatchContainer) |
---|
| 37 | title = u'Access Code Batches' |
---|
| 38 | parent_viewname = 'administration' |
---|
| 39 | |
---|
| 40 | class AdminTaskManageACBatches(AdminTask): |
---|
| 41 | """Entry on administration page that links to batch container. |
---|
| 42 | """ |
---|
| 43 | grok.order(5) |
---|
| 44 | grok.require('waeup.manageUniversity') |
---|
| 45 | grok.template('admintaskacbatches') |
---|
| 46 | |
---|
| 47 | link_title = 'Manage access-code batches' |
---|
| 48 | target_viewname = 'accesscodes' |
---|
[5084] | 49 | |
---|
| 50 | class CreateBatchButton(AddActionButton): |
---|
| 51 | """Action button on batch container page which links to batch creation. |
---|
| 52 | """ |
---|
| 53 | grok.context(IAccessCodeBatchContainer) |
---|
| 54 | grok.view(BatchContainerPage) |
---|
| 55 | grok.require('waeup.manageUniversity') |
---|
| 56 | text = 'Add Scratch Card Batch' |
---|