1 | import grok |
---|
2 | from zope.interface import Interface |
---|
3 | from waeup.sirp.interfaces import IWAeUPObject |
---|
4 | |
---|
5 | grok.context(IWAeUPObject) # Make IWAeUPObject the default context |
---|
6 | grok.templatedir('browser_templates') |
---|
7 | |
---|
8 | class StudentManageSidebar(grok.ViewletManager): |
---|
9 | grok.name('left_studentmanage') |
---|
10 | |
---|
11 | class StudentManageLink(grok.Viewlet): |
---|
12 | """A link displayed in the student box which shows up for StudentNavigation |
---|
13 | objects. |
---|
14 | |
---|
15 | """ |
---|
16 | grok.baseclass() |
---|
17 | grok.viewletmanager(StudentManageSidebar) |
---|
18 | grok.context(IWAeUPObject) |
---|
19 | grok.view(Interface) |
---|
20 | grok.order(5) |
---|
21 | grok.require('waeup.viewStudent') |
---|
22 | |
---|
23 | link = 'index' |
---|
24 | text = u'Base Data' |
---|
25 | |
---|
26 | def render(self): |
---|
27 | url = self.view.url(self.context.getStudent(), self.link) |
---|
28 | return u'<div class="portlet"><a href="%s">%s</a></div>' % ( |
---|
29 | url, self.text) |
---|
30 | |
---|
31 | class StudentManageBaseLink(StudentManageLink): |
---|
32 | grok.order(1) |
---|
33 | link = 'index' |
---|
34 | text = u'Base Data' |
---|
35 | |
---|
36 | class StudentManageClearanceLink(StudentManageLink): |
---|
37 | grok.order(2) |
---|
38 | link = 'view_clearance' |
---|
39 | text = u'Clearance Data' |
---|
40 | |
---|
41 | class StudentManagePersonalLink(StudentManageLink): |
---|
42 | grok.order(2) |
---|
43 | link = 'view_personal' |
---|
44 | text = u'Personal Data' |
---|
45 | |
---|
46 | class StudentManageStudyCourseLink(StudentManageLink): |
---|
47 | grok.order(3) |
---|
48 | link = 'studycourse' |
---|
49 | text = u'Study Course' |
---|
50 | |
---|
51 | class StudentManagePaymentsLink(StudentManageLink): |
---|
52 | grok.order(4) |
---|
53 | link = 'payments' |
---|
54 | text = u'Payments' |
---|
55 | |
---|
56 | class StudentManageAccommodationLink(StudentManageLink): |
---|
57 | grok.order(5) |
---|
58 | link = 'accommodation' |
---|
59 | text = u'Accommodation Data' |
---|
60 | |
---|
61 | class StudentManageHistoryLink(StudentManageLink): |
---|
62 | grok.order(6) |
---|
63 | link = 'history' |
---|
64 | text = u'History' |
---|
65 | |
---|
66 | |
---|
67 | class StudentMenu(grok.ViewletManager): |
---|
68 | grok.name('top_student') |
---|
69 | |
---|
70 | class StudentLink(grok.Viewlet): |
---|
71 | """A link displayed in the student box which shows up for StudentNavigation |
---|
72 | objects. |
---|
73 | |
---|
74 | """ |
---|
75 | grok.baseclass() |
---|
76 | grok.viewletmanager(StudentMenu) |
---|
77 | grok.context(IWAeUPObject) |
---|
78 | grok.view(Interface) |
---|
79 | grok.order(5) |
---|
80 | grok.require('waeup.viewStudent') |
---|
81 | template = grok.PageTemplateFile('browser_templates/plainactionbutton.pt') |
---|
82 | |
---|
83 | link = 'index' |
---|
84 | text = u'Base Data' |
---|
85 | |
---|
86 | @property |
---|
87 | def alt(self): |
---|
88 | """Alternative text for icon. |
---|
89 | """ |
---|
90 | return self.text |
---|
91 | |
---|
92 | @property |
---|
93 | def target_url(self): |
---|
94 | """Get a URL to the target... |
---|
95 | """ |
---|
96 | return self.view.url(self.context.getStudent(), self.link) |
---|
97 | |
---|
98 | class StudentBaseLink(StudentLink): |
---|
99 | grok.order(1) |
---|
100 | link = 'index' |
---|
101 | text = u'Base Data' |
---|
102 | |
---|
103 | class StudentClearanceLink(StudentLink): |
---|
104 | grok.order(2) |
---|
105 | link = 'view_clearance' |
---|
106 | text = u'Clearance Data' |
---|
107 | |
---|
108 | class StudentPersonalLink(StudentLink): |
---|
109 | grok.order(2) |
---|
110 | link = 'view_personal' |
---|
111 | text = u'Personal Data' |
---|
112 | |
---|
113 | class StudentStudyCourseLink(StudentLink): |
---|
114 | grok.order(3) |
---|
115 | link = 'studycourse' |
---|
116 | text = u'Study Course' |
---|
117 | |
---|
118 | class StudentPaymentsLink(StudentLink): |
---|
119 | grok.order(4) |
---|
120 | link = 'payments' |
---|
121 | text = u'Payments' |
---|
122 | |
---|
123 | class StudentAccommodationLink(StudentLink): |
---|
124 | grok.order(5) |
---|
125 | link = 'accommodation' |
---|
126 | text = u'Accommodation' |
---|
127 | |
---|
128 | class StudentHistoryLink(StudentLink): |
---|
129 | grok.order(6) |
---|
130 | link = 'history' |
---|
131 | text = u'History' |
---|
132 | |
---|
133 | class PrimaryStudentNavManager(grok.ViewletManager): |
---|
134 | """Viewlet manager for the primary navigation tab. |
---|
135 | """ |
---|
136 | grok.name('primary_nav_student') |
---|
137 | |
---|
138 | class PrimaryStudentNavTab(grok.Viewlet): |
---|
139 | """Base for primary student nav tabs. |
---|
140 | """ |
---|
141 | grok.baseclass() |
---|
142 | grok.viewletmanager(PrimaryStudentNavManager) |
---|
143 | grok.template('primarynavtab') |
---|
144 | grok.order(1) |
---|
145 | grok.require('waeup.View') |
---|
146 | pnav = 0 |
---|
147 | tab_title = u'Some Text' |
---|
148 | |
---|
149 | @property |
---|
150 | def link_target(self): |
---|
151 | return self.view.application_url() |
---|
152 | |
---|
153 | @property |
---|
154 | def active(self): |
---|
155 | view_pnav = getattr(self.view, 'pnav', 0) |
---|
156 | if view_pnav == self.pnav: |
---|
157 | return 'active' |
---|
158 | return '' |
---|
159 | |
---|
160 | class HomeTab(PrimaryStudentNavTab): |
---|
161 | """Home-tab in primary navigation. |
---|
162 | """ |
---|
163 | grok.order(1) |
---|
164 | grok.require('waeup.Public') |
---|
165 | pnav = 0 |
---|
166 | tab_title = u'Home' |
---|
167 | |
---|
168 | class ProspectusTab(PrimaryStudentNavTab): |
---|
169 | """Faculties-tab in primary navigation. |
---|
170 | """ |
---|
171 | grok.order(2) |
---|
172 | grok.require('waeup.View') |
---|
173 | pnav = 1 |
---|
174 | tab_title = u'Prospectus' |
---|
175 | |
---|
176 | @property |
---|
177 | def link_target(self): |
---|
178 | return self.view.application_url('faculties') |
---|
179 | |
---|
180 | class MyDataTab(PrimaryStudentNavTab): |
---|
181 | """MyData-tab in primary navigation. |
---|
182 | """ |
---|
183 | grok.order(3) |
---|
184 | grok.require('waeup.Public') |
---|
185 | pnav = 4 |
---|
186 | tab_title = u'My Data' |
---|
187 | |
---|
188 | @property |
---|
189 | def link_target(self): |
---|
190 | rel_link = '/students/%s' % self.request.principal.id |
---|
191 | return self.view.application_url() + rel_link |
---|