1 | ## $Id: viewlets.py 12206 2014-12-13 07:28:59Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann |
---|
4 | ## This program is free software; you can redistribute it and/or modify |
---|
5 | ## it under the terms of the GNU General Public License as published by |
---|
6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
7 | ## (at your option) any later version. |
---|
8 | ## |
---|
9 | ## This program is distributed in the hope that it will be useful, |
---|
10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | ## GNU General Public License for more details. |
---|
13 | ## |
---|
14 | ## You should have received a copy of the GNU General Public License |
---|
15 | ## along with this program; if not, write to the Free Software |
---|
16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | ## |
---|
18 | """Viewlet components for documents offered for download by the company. |
---|
19 | """ |
---|
20 | |
---|
21 | import grok |
---|
22 | from waeup.ikoba.browser.viewlets import ( |
---|
23 | PrimaryNavTab, ManageActionButton, AddActionButton) |
---|
24 | from waeup.ikoba.interfaces import IIkobaObject |
---|
25 | from waeup.ikoba.interfaces import MessageFactory as _ |
---|
26 | from waeup.ikoba.browser.viewlets import PrimaryNavTab |
---|
27 | |
---|
28 | from waeup.ikoba.documents.interfaces import ( |
---|
29 | IDocumentsContainer, IDocument) |
---|
30 | from waeup.ikoba.documents.browser import ( |
---|
31 | DocumentsContainerManageFormPage, DocumentsContainerPage, |
---|
32 | DocumentManageFormPage, DocumentDisplayFormPage) |
---|
33 | |
---|
34 | |
---|
35 | grok.context(IIkobaObject) # Make IIkobaObject the default context |
---|
36 | grok.templatedir('browser_templates') |
---|
37 | |
---|
38 | |
---|
39 | class DocumentsTab(PrimaryNavTab): |
---|
40 | """Documents tab in primary navigation. |
---|
41 | """ |
---|
42 | |
---|
43 | grok.context(IIkobaObject) |
---|
44 | grok.order(1) |
---|
45 | grok.require('waeup.viewDocuments') |
---|
46 | grok.name('documentstab') |
---|
47 | |
---|
48 | pnav = 2 |
---|
49 | tab_title = _(u'Documents') |
---|
50 | |
---|
51 | @property |
---|
52 | def link_target(self): |
---|
53 | return self.view.application_url('documents') |
---|
54 | |
---|
55 | class DocumentsContainerManageActionButton(ManageActionButton): |
---|
56 | grok.order(1) |
---|
57 | grok.context(IDocumentsContainer) |
---|
58 | grok.view(DocumentsContainerPage) |
---|
59 | grok.require('waeup.manageDocuments') |
---|
60 | text = _('Manage') |
---|
61 | target = 'manage' |
---|
62 | |
---|
63 | |
---|
64 | class DocumentViewActionButton(ManageActionButton): |
---|
65 | grok.order(1) |
---|
66 | grok.context(IDocument) |
---|
67 | grok.view(DocumentManageFormPage) |
---|
68 | grok.require('waeup.manageDocuments') |
---|
69 | text = _('View') |
---|
70 | target = 'index' |
---|
71 | icon = 'actionicon_view.png' |
---|
72 | |
---|
73 | |
---|
74 | class DocumentManageActionButton(ManageActionButton): |
---|
75 | grok.order(1) |
---|
76 | grok.context(IDocument) |
---|
77 | grok.view(DocumentDisplayFormPage) |
---|
78 | grok.require('waeup.manageDocuments') |
---|
79 | text = _('Manage') |
---|
80 | target = 'manage' |
---|