1 | ## $Id: viewlets.py 12438 2015-01-11 08:27:37Z 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.kofa.browser.viewlets import ( |
---|
23 | PrimaryNavTab, ManageActionButton, AddActionButton) |
---|
24 | from waeup.kofa.interfaces import IKofaObject |
---|
25 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
26 | from waeup.kofa.browser.viewlets import PrimaryNavTab |
---|
27 | |
---|
28 | from waeup.kofa.documents.interfaces import ( |
---|
29 | IDocumentsContainer, IPublicDocument) |
---|
30 | from waeup.kofa.documents.browser import ( |
---|
31 | DocumentsContainerManageFormPage, DocumentsContainerPage, |
---|
32 | DocumentManageFormPage, DocumentDisplayFormPage) |
---|
33 | |
---|
34 | |
---|
35 | grok.context(IKofaObject) # Make IKofaObject 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(IKofaObject) |
---|
44 | grok.order(10) |
---|
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(IPublicDocument) |
---|
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(IPublicDocument) |
---|
77 | grok.view(DocumentDisplayFormPage) |
---|
78 | grok.require('waeup.manageDocuments') |
---|
79 | text = _('Manage') |
---|
80 | target = 'manage' |
---|
81 | |
---|
82 | |
---|
83 | class DocumentTrigTransActionButton(ManageActionButton): |
---|
84 | grok.order(2) |
---|
85 | grok.context(IPublicDocument) |
---|
86 | grok.view(DocumentDisplayFormPage) |
---|
87 | grok.require('waeup.manageDocuments') |
---|
88 | icon = 'actionicon_trigtrans.png' |
---|
89 | text = _(u'Transition') |
---|
90 | target = 'trigtrans' |
---|
91 | |
---|
92 | |
---|