made a simple member profile thing

master
Jacob Parker 11 years ago
parent 075fc075c2
commit c49e0d942a
  1. 40
      bin/member_info.py
  2. 2
      bin/members.py

@ -1,4 +1,38 @@
#!/usr/bin/python
import sys, os.path
print "this is a test!<br>"
print "got this as an argument: " + os.path.basename(sys.argv[1])
import sys, os.path, ldap, time
uid = os.path.basename(sys.argv[1])
cscUri = "http://csclub.uwaterloo.ca/xsltproc"
cscTerms = ["Winter", "Spring", "Fall"]
cscShortTerms = ['w', 's', 'f']
cscLdapUri = "ldap://ldap1.csclub.uwaterloo.ca ldap://ldap2.csclub.uwaterloo.ca"
cscLdap = None
cscPeopleBase = 'ou=People,dc=csclub,dc=uwaterloo,dc=ca'
def cscLdapConnect():
global cscLdap
cscLdap = ldap.initialize(cscLdapUri)
cscLdap.simple_bind_s("", "")
cscLdapConnect()
curDate = time.strftime('%d-%m-%Y')
members = cscLdap.search_s(cscPeopleBase, ldap.SCOPE_SUBTREE,
'(&(objectClass=member)(uid=%s))' % uid)
if len(members) == 0:
print "<p>No such user <code>" + uid + "</code></p>"
sys.exit()
(_, user) = members[0]
print "<h1>Profile for " + user['cn'][0] + "</h1>"
print "<p>"
print "<ul>"
print "<li>Terms: "
for t in sorted(user['term']):
print t + " "
print "<br></li>"
print "<li>Website: <a href=\"http://csclub.uwaterloo.ca/~" + uid + "\">http://csclub.uwaterloo.ca/~" + uid + "</a></li>"
print "</ul>"
print "</p>"

@ -23,7 +23,7 @@ term = cscShortTerms[int(time.localtime().tm_mon - 1) / 4]
term2 = cscTerms[int(time.localtime().tm_mon - 1) / 4]
members = cscLdap.search_s(cscPeopleBase, ldap.SCOPE_SUBTREE,
'(&(objectClass=member)(term=%s%d))' % (term, year))
members.sort()
members.sort(key=lambda (_, y): y['cn'][0])
print "<p>The members for " + term2 + " " + str(year) + " are listed here. We currently have " + str(len(members)) + " members.<br>"
print "Use of this list for solicitation of any form is prohibited. If you wish to get in touch with the membership as a whole please contact <a href=\"mailto:exec@csclub.uwaterloo.ca\">the Executive</a>.</p>"
print "<center>"

Loading…
Cancel
Save