Fetch positions (including exec) from ldap

* Position fetching is implemented by csc:positions
* Exec page is now called Positions (positions.html)
* exec.html -> positions.html symlink exists
foo
David Bartley 15 years ago
parent dec967e63c
commit 910001d750
  1. 7
      about/Makefile
  2. 2
      about/directory.xml
  3. 66
      about/exec.xml
  4. 24
      about/positions.xml
  5. 19
      default.css
  6. 2
      media/Makefile
  7. 55
      scripts/xsltproc.py
  8. 37
      xsl/exec.xsl
  9. 2
      xsl/html.xsl
  10. 24
      xsl/positions.xsl

@ -1,6 +1,11 @@
FILES = index.html exec.html members.html constitution.html donations.html \
constitution-change-20020920.html constitution-change-20040205.html
positions.html constitution-change-20020920.html \
constitution-change-20040205.html
RELDIR = about/
include ../common.mk
$(OUTDIR)members.html: force
$(OUTDIR)positions.html: force
$(OUTDIR)exec.html:
ln -s positions.html $@

@ -4,7 +4,7 @@
<directory title="About">
<diritem title="Constitution" href="constitution.html" />
<diritem title="The Executive" href="exec.html" />
<diritem title="Positions" href="positions.html" />
<diritem title="Membership List" href="members.html" />
<diritem title="Donations" href="donations.html" />
</directory>

@ -1,66 +0,0 @@
<?xml version='1.0'?>
<!DOCTYPE cscpage SYSTEM "../csc.dtd">
<cscpage title="The CSC Executive">
<header />
<section title="The Executive">
<execlist>
<exec position="President"
name="Holden Karau"
sex="male"
userid="president" />
<exec position="Vice President"
name="Alex McCausland"
sex="male"
userid="vice-president" />
<exec position="Treasurer"
name="Dominik Chlobowski"
sex="male"
userid="treasurer" />
<exec position="Secretary"
name="Sean Cumming"
sex="male"
userid="secretary" />
<exec position="System Administrator"
type="appointed"
name="David Tenty"
sex="male"
userid="sysadmin" />
<exec position="Librarian"
type="appointed"
name="Various people"
sex="male"
userid="librarian" />
<exec position="Imapd (Individual Making Arrangements for Pop Delivery)"
type="appointed"
name="Nobody"
sex="male"
userid="imapd" />
<!-- Co-op position -->
<exec position="Web Master"
type="appointed"
name="David Bartley and Juti Noppornpitak"
sex="male"
userid="www" />
</execlist>
</section>
<section title="Elections">
<p>
Each term the CSC holds elections to determine the executive
council. To find out when and where the next elections will be
held, check the <a href="../index.html">homepage</a> and the <a
href="http://csclub.uwaterloo.ca/newsgroup/thread.php?group=uw.csc">uw.csc newsgroup</a>. For details on the
election rules, see the <a
href="constitution.html">constitution</a>.
</p>
</section>
<footer/>
</cscpage>

@ -0,0 +1,24 @@
<?xml version='1.0'?>
<!DOCTYPE cscpage SYSTEM "../csc.dtd">
<cscpage title="The CSC Executive">
<header />
<section title="The Executive">
<positions exec="yes" />
</section>
<section title="Other Positions">
<positions exec="no" />
</section>
<section title="Elections">
<p>
Each term the CSC holds elections to determine the executive council. To
find out when and where the next elections will be held, check the
<a href="../index.html">homepage</a> and the
<a href="http://csclub.uwaterloo.ca/newsgroup/thread.php?group=uw.csc">
uw.csc</a> newsgroup. For details on the election rules, see the
<a href="constitution.html">constitution</a>.
</p>
</section>
<footer />
</cscpage>

@ -1,7 +1,7 @@
body {
background: white;
color: black;
font-family: serif;
font-family: 'Lucida Grande', Sans, Sans-serif;
font-size: 12px;
width: 760px;
margin: 0 auto;
@ -20,7 +20,6 @@ h1 {
}
h2 {
font-size: large;
font-family: 'Lucida Grande', Sans, Sans-serif;
text-transform: uppercase;
border-left: 10px solid #ff9900;
padding-left: 10px;
@ -55,7 +54,6 @@ td.button {
}
td.newsdate {
background: #eeeeff;
font-family: sans-serif;
font-size: x-small;
text-align: center;
font-weight: bold;
@ -66,13 +64,11 @@ td.newsitem {
}
td.newsauthor {
background: #eeeeff;
font-family: sans-serif;
font-size: x-small;
text-align: center;
}
td.eventdate {
background: #eeffee;
font-family: sans-serif;
font-size: x-small;
text-align: center;
font-weight: bold;
@ -83,14 +79,12 @@ td.eventitem {
}
td.eventroom {
background: #eeffee;
font-family: sans-serif;
font-size: x-small;
text-align: center;
}
th.news {
background: #222255;
color: white;
font-family: sans-serif;
font-size: x-small;
text-align: left;
}
@ -109,15 +103,15 @@ img {
border-width: 0;
}
div.position {
font-weight: bold;
}
div.footerlogo {
float: right;
padding-left: 5px;
}
p {
font-family: 'Lucida Grande', Sans, Sans-serif;
}
div.webcam {
text-align: center;
}
@ -168,7 +162,6 @@ div.menuitem a {
margin: 0;
text-decoration: none;
font-weight: 400;
font-family: 'Lucida Grande', Sans, Sans-serif;
}
div.menuitem a:hover {
@ -198,7 +191,6 @@ div.webtitle div {
}
a.diritem, a.diritem:link, a.diritem:visited, a.diritem:active {
font-family: 'Lucida Grande', Sans, Sans-serif;
font-size: 14px;
border-left: 4px solid #ccc;
padding: 0 15px 0 5px;
@ -214,7 +206,6 @@ a.homedir {
}
a.pagetop, a.pagetop:link, a.pagetop:visited, a.pagetop:hover {
font-family: 'Lucida Grande',sans, sans-serif;
display: block;
padding: 5px 10px 5px 10px;
border: 1px solid #ccc;

@ -3,4 +3,4 @@ RELDIR = media/
include ../common.mk
$(OUTDIR)flash:
ln -s ../flash $(OUTDIR)flash
ln -s ../flash $@

@ -10,6 +10,18 @@ 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'
cscPositions = {
# position # name # exec # elected # order
'president' : ( 'President', True, True, 1, ),
'vice-president' : ( 'Vice-president', True, True, 2, ),
'treasurer' : ( 'Treasurer', True, True, 3, ),
'secretary' : ( 'Secretary', True, True, 4, ),
'sysadmin' : ( 'System Administrator', True, False, 5, ),
'librarian' : ( 'Librarian', False, False, 6, ),
'imapd' : ( 'Imapd', False, False, 7, ),
'webmaster' : ( 'Web Master', False, False, 8, ),
}
cscYesNo = { True : 'yes', False : 'no' }
#
# cscLdapConnect
@ -39,6 +51,7 @@ def cscTerm(ctx, arg):
return cscTerms[term] + " " + year
except:
print "Invalid term '%s'" % arg
raise
#
# csc:member-list
@ -53,7 +66,7 @@ def cscMemberList(ctx, arg):
members = cscLdap.search_s(cscPeopleBase, ldap.SCOPE_SUBTREE,
'(&(objectClass=member)(term=%s%d))' % (term, year))
doc = libxml2.newDoc("1.0")
root = doc.newChild(None, "memberlist", None)
root = doc.newChild(None, "root", None)
for (_, member) in members:
node = root.newChild(None, "member", None)
node.setProp("userid", member['uid'][0])
@ -66,6 +79,45 @@ def cscMemberList(ctx, arg):
print e
raise
#
# csc:position-list
#
def cscPositionList(ctx, arg):
try:
if cscLdap == None:
cscLdapConnect()
members = cscLdap.search_s(cscPeopleBase, ldap.SCOPE_SUBTREE,
'(&(objectClass=member)(position=*))')
doc = libxml2.newDoc("1.0")
root = doc.newChild(None, "root", None)
positions = {}
for (_, member) in members:
for position in member['position']:
if not position in positions:
positions[position] = []
positions[position].append(member)
for position in cscPositions.keys():
if not position in positions:
positions[position] = []
for (position, members) in positions.iteritems():
node = root.newChild(None, "position", None)
node.setProp("position", position)
if not position in cscPositions:
raise Exception("Position '%s' not known" % position)
position = cscPositions[position]
node.setProp("name", position[0])
node.setProp("exec", cscYesNo[position[1]])
node.setProp("elected", cscYesNo[position[2]])
node.setProp("order", str(position[3]))
for member in members:
child = node.newChild(None, "holder", None)
child.setProp("userid", member['uid'][0])
child.setProp("name", member['cn'][0])
return [root]
except Exception, e:
print e
raise
#
# csc:email
#
@ -102,6 +154,7 @@ try:
libxslt.registerExtModuleFunction("encode-for-uri", cscUri, cscEncodeForUri)
libxslt.registerExtModuleFunction("term", cscUri, cscTerm)
libxslt.registerExtModuleFunction("member-list", cscUri, cscMemberList)
libxslt.registerExtModuleFunction("position-list", cscUri, cscPositionList)
libxslt.registerExtModuleFunction("email", cscUri, cscEmail)
# parse xml/xslt and apply style-sheet

@ -1,37 +0,0 @@
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:csc="http://csclub.uwaterloo.ca/xsltproc">
<xsl:template match="execlist">
<h3>Elected positions</h3>
<ul>
<xsl:apply-templates select="exec[@type='elected']" />
</ul>
<h3>Appointed positions</h3>
<ul>
<xsl:apply-templates select="exec[@type='appointed']" />
</ul>
</xsl:template>
<xsl:template match="exec">
<li>
<xsl:value-of select="@name" /> is this term's <b>
<xsl:value-of select="@position" /></b>. You can <a
href="mailto:{@userid}@csclub.uwaterloo.ca">e-mail the
<xsl:value-of select="@position" /></a>
<xsl:if test="not(@href='')">
or <a href="{@href}">visit
<xsl:choose>
<xsl:when test="@sex='male'"> his </xsl:when>
<xsl:when test="@sex='female'"> her </xsl:when>
<xsl:otherwise> his or her </xsl:otherwise>
</xsl:choose>
homepage</a>
</xsl:if>.
</li>
</xsl:template>
</xsl:stylesheet>

@ -38,7 +38,7 @@
<xsl:include href="common.xsl" />
<xsl:include href="directory.xsl" />
<xsl:include href="menu.xsl" />
<xsl:include href="exec.xsl" />
<xsl:include href="positions.xsl" />
<xsl:include href="members.xsl" />
<xsl:include href="events.xsl" />
<xsl:include href="news.xsl" />

@ -0,0 +1,24 @@
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:csc="http://csclub.uwaterloo.ca/xsltproc">
<xsl:template match="positions">
<xsl:variable name="exec" select="@exec" />
<xsl:for-each select="csc:position-list('')/position[@exec=$exec]">
<xsl:sort select="@order" order="ascending" />
<p>
<div class="position">
<a href="mailto:{@position}@csclub.uwaterloo.ca"><xsl:value-of select="@name" /></a>
</div>
<xsl:if test="not(holder)">Vacant</xsl:if>
<xsl:for-each select="holder">
<xsl:value-of select="@name" /><br />
</xsl:for-each>
</p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Loading…
Cancel
Save