source: main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.py @ 5084

Last change on this file since 5084 was 5084, checked in by uli, 15 years ago

Add action button and add page to create batches (add page not
finished).

File size: 1.7 KB
Line 
1"""UI components for accesscodes.
2"""
3import grok
4from waeup.sirp.browser import WAeUPPage, WAeUPAddFormPage
5from waeup.sirp.browser.breadcrumbs import Breadcrumb
6from waeup.sirp.browser.viewlets import AdminTask, AddActionButton
7from waeup.sirp.interfaces import IWAeUPObject
8
9from waeup.sirp.accesscodes.interfaces import IAccessCodeBatchContainer
10
11grok.context(IWAeUPObject)
12
13class BatchContainerPage(WAeUPPage):
14    grok.name('index')
15    grok.context(IAccessCodeBatchContainer)
16    grok.template('batchcontainer')
17
18    title = 'Access Code Batches'
19    pnav = 0
20
21class 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
33class 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
40class 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'
49
50class 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'
Note: See TracBrowser for help on using the repository browser.