1 | ## $Id: pages.py 16508 2021-06-16 11:54:39Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2015 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 | """ Viewing components for Kofa objects. |
---|
19 | """ |
---|
20 | |
---|
21 | import grok |
---|
22 | from zope.component import getUtility |
---|
23 | from waeup.kofa.interfaces import IKofaUtils |
---|
24 | from waeup.kofa.browser.pages import ( |
---|
25 | SessionConfigurationAddFormPage, |
---|
26 | SessionConfigurationManageFormPage, |
---|
27 | ConfigurationContainerManageFormPage, |
---|
28 | SourcesOverview) |
---|
29 | from waeup.kofa.browser.layout import KofaPage |
---|
30 | from kofacustom.nigeria.interfaces import ( |
---|
31 | high_qual, high_grade, exam_types, LGASource, |
---|
32 | ICustomSessionConfiguration, |
---|
33 | ICustomSessionConfigurationAdd) |
---|
34 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
35 | |
---|
36 | class NigeriaSourcesOverview(SourcesOverview): |
---|
37 | |
---|
38 | def _set_high_qual(self): |
---|
39 | vocab_terms = high_qual.by_value.values() |
---|
40 | self.high_qual = sorted([(x.token, x.title,) for x in vocab_terms]) |
---|
41 | return |
---|
42 | |
---|
43 | def _set_high_grade(self): |
---|
44 | vocab_terms = high_grade.by_value.values() |
---|
45 | self.high_grade = sorted([(x.token, x.title,) for x in vocab_terms]) |
---|
46 | return |
---|
47 | |
---|
48 | def _set_exam_types(self): |
---|
49 | vocab_terms = exam_types.by_value.values() |
---|
50 | self.exam_types = sorted([(x.token, x.title,) for x in vocab_terms]) |
---|
51 | return |
---|
52 | |
---|
53 | def _set_lgas(self): |
---|
54 | lgasource = LGASource().factory |
---|
55 | self.lgas = [] |
---|
56 | for key in lgasource.getValues(): |
---|
57 | title = lgasource.getTitle(key) |
---|
58 | self.lgas.append((key, title)) |
---|
59 | return |
---|
60 | |
---|
61 | def _set_grading_sys(self): |
---|
62 | grading_sys = getUtility(IKofaUtils).GRADING_SYSTEM_DICT |
---|
63 | self.grading_sys = sorted(grading_sys.items()) |
---|
64 | return |
---|
65 | |
---|
66 | def update(self): |
---|
67 | super(NigeriaSourcesOverview, self).update() |
---|
68 | self._set_high_qual() |
---|
69 | self._set_high_grade() |
---|
70 | self._set_exam_types() |
---|
71 | self._set_lgas() |
---|
72 | self._set_grading_sys() |
---|
73 | return |
---|
74 | |
---|
75 | class NigeriaSourcesOverviewPage(KofaPage, NigeriaSourcesOverview): |
---|
76 | grok.name('sources') |
---|
77 | grok.require('waeup.Public') |
---|
78 | label = _(u'Sources & Vocabularies') |
---|
79 | pnav = 0 |
---|
80 | |
---|
81 | class CustomSessionConfigurationAddFormPage(SessionConfigurationAddFormPage): |
---|
82 | """Add a session configuration object to configuration container. |
---|
83 | """ |
---|
84 | form_fields = grok.AutoFields(ICustomSessionConfigurationAdd) |
---|
85 | |
---|
86 | class CustomSessionConfigurationManageFormPage( |
---|
87 | SessionConfigurationManageFormPage): |
---|
88 | """Manage session configuration object. |
---|
89 | """ |
---|
90 | form_fields = grok.AutoFields(ICustomSessionConfiguration) |
---|