[Da-tools-commits] ./da-tools/userdir-ldap-cgi-python r16: sorting is now intergrated in machines template

Robin Wittler real at geek-at-work.org
Mon Jan 26 20:20:36 UTC 2009


------------------------------------------------------------
revno: 16
committer: Robin Wittler <real at geek-at-work.org>
branch nick: userdir-ldap-cgi-python
timestamp: Mon 2009-01-26 21:20:36 +0100
message:
  sorting is now intergrated in machines template
  changing var names in udldapng controller
modified:
  ud_ldap_ng/controllers/udldapng.py
  ud_ldap_ng/templates/machines.html
-------------- next part --------------
=== modified file 'ud_ldap_ng/controllers/udldapng.py'
--- a/ud_ldap_ng/controllers/udldapng.py	2009-01-25 19:50:15 +0000
+++ b/ud_ldap_ng/controllers/udldapng.py	2009-01-26 20:20:36 +0000
@@ -24,11 +24,11 @@
 		c.result = con.getDebianHosts(attrlist=c.attributes, adjust=True, default_value='')
 		c.sortorder = request.params.get('sortorder', None)
 		if not c.sortorder or c.sortorder not in c.sortorders:
-			c.sortorder = c.sortorders.get('asc')
+			sortorder = c.sortorders.get('asc')
 		else:
-			c.sortorder = c.sortorders.get(c.sortorder)
+			sortorder = c.sortorders.get(c.sortorder)
 		c.sortby = request.params.get('sortby', None)
 		if not c.sortby or c.sortby not in c.attributes:
 			c.sortby = 'hostname'
-		c.results = c.result.sortResults(c.sortby, reverse=c.sortorder)
+		c.results = c.result.sortResults(c.sortby, reverse=sortorder)
 		return render('/machines.html')

=== modified file 'ud_ldap_ng/templates/machines.html'
--- a/ud_ldap_ng/templates/machines.html	2009-01-25 19:50:15 +0000
+++ b/ud_ldap_ng/templates/machines.html	2009-01-26 20:20:36 +0000
@@ -42,11 +42,14 @@
 				<div id="text">
 				<table border="1">
                     <tr>
-						<th>Hostname</th>
-						<th>Architecture</th>
-						<th>Purpose</th>
-						<th>Sponsor</th>
-						<th>Status</th>
+						% for value in c.attributes:
+							% if value == c.sortby:
+							<% new_sortorder = (i for i in c.sortorders if i != c.sortorder).next() %>
+								<th><a href="/?sortby=${value}&sortorder=${new_sortorder}">${value.capitalize()}</a></th>
+							% else:
+								<th><a href="/?sortby=${value}&sortorder=asc">${value.capitalize()}</a></th>
+							% endif
+						% endfor
 					</tr>
 					<%! from ud_ldap_ng.lib.libformat import is_markup_string, is_public, map_chars %>
 					% for result in c.results:



More information about the Da-tools-commits mailing list