Merge commit 'public/master' into ceod
[public/pyceo-broken.git] / ceo / urwid / info.py
1 import urwid
2 from ceo.urwid.widgets import *
3 from ceo.urwid.window import *
4 from ceo import terms
5
6 class InfoPage(WizardPanel):
7     def init_widgets(self):
8         self.userid = urwid.Text("")
9         self.name = urwid.Text("")
10         self.terms = urwid.Text("")
11         self.nmterms = urwid.Text("")
12         self.program = urwid.Text("")
13
14         self.widgets = [
15             urwid.Text( "Member Details" ),
16             urwid.Divider(),
17             self.name,
18             self.userid,
19             self.program,
20             urwid.Divider(),
21             self.terms,
22             self.nmterms,
23         ]
24     def focusable(self):
25         return False
26     def activate(self):
27         member  = self.state.get('member', {})
28         name    = member.get('cn', [''])[0]
29         userid  = self.state['userid']
30         program = member.get('program', [''])[0]
31         shell   = member.get('loginShell', [''])[0]
32         mterms  = member.get('term', [])
33         nmterms = member.get('nonMemberTerm', [])
34
35         mterms.sort(terms.compare)
36         nmterms.sort(terms.compare)
37
38         self.name.set_text("Name: %s" % name)
39         self.userid.set_text("User: %s" % userid)
40         self.program.set_text("Program: %s" % program)
41         self.program.set_text("Shell: %s" % shell)
42         if terms:
43             self.terms.set_text("Terms: %s" % ", ".join(mterms))
44         if nmterms:
45             self.nmterms.set_text("Rep Terms: %s" % ", ".join(nmterms))
46     def check(self):
47         pop_window()