tidying some stuff up, added elections page
[public/www-new.git] / bin / member_info.py
1 #!/usr/bin/python
2 import sys, os.path, ldap, time
3 uid = os.path.basename(sys.argv[1])
4
5 cscUri = "http://csclub.uwaterloo.ca/xsltproc"
6 cscTerms = ["Winter", "Spring", "Fall"]
7 cscShortTerms = ['w', 's', 'f']
8 cscLdapUri = "ldap://ldap1.csclub.uwaterloo.ca ldap://ldap2.csclub.uwaterloo.ca"
9 cscLdap = None
10 cscPeopleBase = 'ou=People,dc=csclub,dc=uwaterloo,dc=ca'
11
12 def cscLdapConnect():
13     global cscLdap
14     cscLdap = ldap.initialize(cscLdapUri)
15     cscLdap.simple_bind_s("", "")
16
17 cscLdapConnect()
18 curDate = time.strftime('%d-%m-%Y')
19 members = cscLdap.search_s(cscPeopleBase, ldap.SCOPE_SUBTREE,
20           '(&(objectClass=member)(uid=%s))' % uid)
21 if len(members) == 0:
22     print "<p>No such user <code>" + uid + "</code></p>"
23     sys.exit()   
24
25 (_, user) = members[0]
26
27 print "<h1>Profile for " + user['cn'][0] + "</h1>"
28
29 print "<p>"
30 print "<ul>"
31 if "position" in user:
32     print "<li>Executive Position: "
33     for x in user['position']:
34         print x # edge case - could hold multiple positions!
35     print "</li>"
36 print "<li>Terms: "
37 for t in sorted(user['term']):
38     print t + " "
39 print "<br></li>"
40 print "<li>Website: <a href=\"http://csclub.uwaterloo.ca/~" + uid + "\">http://csclub.uwaterloo.ca/~" + uid + "</a></li>"
41 print "</ul>"
42 print "</p>"
43