source: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/viewlets.py @ 11964

Last change on this file since 11964 was 11964, checked in by Henrik Bettermann, 10 years ago

Adjust customer workflow.

File size: 3.1 KB
Line 
13## $Id: viewlets.py 11772 2014-07-31 04:38:23Z 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
19import grok
20from waeup.ikoba.interfaces import IIkobaObject
21from waeup.ikoba.interfaces import MessageFactory as _
22from waeup.ikoba.browser.viewlets import (
23    PrimaryNavTab, ManageActionButton, AddActionButton)
24from waeup.ikoba.browser.layout import (
25    default_primary_nav_template, default_filedisplay_template,
26    default_fileupload_template)
27
28grok.context(IIkobaObject) # Make IKofaObject the default context
29grok.templatedir('browser_templates')
30
31class CustomersTab(PrimaryNavTab):
32    """Customers tab in primary navigation.
33    """
34
35    grok.context(IIkobaObject)
36    grok.order(4)
37    grok.require('waeup.viewCustomersTab')
38    grok.name('customerstab')
39
40    pnav = 4
41    tab_title = _(u'Customers')
42
43    @property
44    def link_target(self):
45        return self.view.application_url('customers')
46
47class PrimaryCustomerNavManager(grok.ViewletManager):
48    """Viewlet manager for the primary navigation tab.
49    """
50    grok.name('primary_nav_customer')
51
52class PrimaryCustomerNavTab(grok.Viewlet):
53    """Base for primary customer nav tabs.
54    """
55    grok.baseclass()
56    grok.viewletmanager(PrimaryCustomerNavManager)
57    template = default_primary_nav_template
58    grok.order(1)
59    grok.require('waeup.Authenticated')
60    pnav = 0
61    tab_title = u'Some Text'
62
63    @property
64    def link_target(self):
65        return self.view.application_url()
66
67    @property
68    def active(self):
69        view_pnav = getattr(self.view, 'pnav', 0)
70        if view_pnav == self.pnav:
71            return 'active'
72        return ''
73
74class MyCustomerDataTab(PrimaryCustomerNavTab):
75    """MyData dropdown tab in primary navigation.
76    """
77    grok.order(3)
78    grok.require('waeup.viewMyCustomerDataTab')
79    grok.template('mydatadropdowntabs')
80    grok.name('mycustomerdatatab')
81    pnav = 4
82    tab_title = _(u'My Data')
83
84    @property
85    def active(self):
86        view_pnav = getattr(self.view, 'pnav', 0)
87        if view_pnav == self.pnav:
88            return 'active dropdown'
89        return 'dropdown'
90
91    @property
92    def targets(self):
93        customer = grok.getSite()['customers'][self.request.principal.id]
94        customer_url = self.view.url(customer)
95        targets = []
96        targets += [
97            {'url':customer_url, 'title':'Base Data'},
98            {'url':customer_url + '/history', 'title':_('History')},
99            ]
100        return targets
Note: See TracBrowser for help on using the repository browser.