[bknr-cvs] hans changed deployed/bos/projects/bos/

BKNR Commits bknr at bknr.net
Tue Mar 23 10:54:58 UTC 2010


Revision: 4520
Author: hans
URL: http://bknr.net/trac/changeset/4520

Make /reports-xml/all-contracts-m2s into a HTML table by default, requested
by the SL team in Indonesia.

A   deployed/bos/projects/bos/payment-website/static/contracts.xsl
U   deployed/bos/projects/bos/web/reports-xml-handler.lisp

Added: deployed/bos/projects/bos/payment-website/static/contracts.xsl
===================================================================
--- deployed/bos/projects/bos/payment-website/static/contracts.xsl	                        (rev 0)
+++ deployed/bos/projects/bos/payment-website/static/contracts.xsl	2010-03-23 10:54:57 UTC (rev 4520)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version="1.0">
+  <xsl:output method="html"/>
+  
+  <xsl:template match="/">
+    <html xmlns="http://www.w3.org/1999/xhtml">
+      <head>        
+        <title>Samboja Lestari Donor List</title></head>
+      <body>
+        <table border="1">
+          <thead>
+            <tr><th>Name</th><th>ID</th><th>Country</th><th>Coordinate (x/y)</th><th>qm</th></tr>
+          </thead>
+          <tbody>
+            <xsl:apply-templates/>
+          </tbody>
+        </table>
+      </body>
+    </html>
+  </xsl:template>
+  
+  <xsl:template match="contract">
+    <tr>
+      <td><xsl:value-of select="@sponsor-name" /></td>
+      <td><xsl:value-of select="@sponsor-id" /></td>
+      <td><xsl:value-of select="@country" /></td>
+      <td><xsl:value-of select="@utm-x" />/<xsl:value-of select="@utm-y" /></td>
+      <td><xsl:value-of select="@sqm-count" /></td>
+    </tr>
+  </xsl:template>
+</xsl:stylesheet>
+
+      

Modified: deployed/bos/projects/bos/web/reports-xml-handler.lisp
===================================================================
--- deployed/bos/projects/bos/web/reports-xml-handler.lisp	2010-03-09 16:47:23 UTC (rev 4519)
+++ deployed/bos/projects/bos/web/reports-xml-handler.lisp	2010-03-23 10:54:57 UTC (rev 4520)
@@ -41,17 +41,19 @@
 
 (defun all-contracts/internal (&key include-coords)
   (dolist (contract *contracts-to-process*)
-    (with-element "contract"
-      (attribute "id" (store-object-id contract))
-      (attribute "sponsor-id" (store-object-id (contract-sponsor contract)))
-      (attribute "universal-time" (contract-date contract))
-      (attribute "paid" (contract-paidp contract))
-      (attribute "date-time" (format-date-time (contract-date contract) :xml-style t))
-      (attribute "country" (sponsor-country (contract-sponsor contract)))
-      (attribute "sqm-count" (length (contract-m2s contract)))
-      (when include-coords
-        (dolist (m2 (contract-m2s contract))
-          (with-element "m2"
+    (let ((sponsor (contract-sponsor contract)))
+      (with-element "contract"
+        (attribute "id" (store-object-id contract))
+        (attribute "sponsor-id" (store-object-id sponsor))
+        (when (user-full-name sponsor)
+          (attribute "sponsor-name" (user-full-name sponsor)))
+        (attribute "universal-time" (contract-date contract))
+        (attribute "paid" (contract-paidp contract))
+        (attribute "date-time" (format-date-time (contract-date contract) :xml-style t))
+        (attribute "country" (sponsor-country sponsor))
+        (attribute "sqm-count" (length (contract-m2s contract)))
+        (when include-coords
+          (let ((m2 (first (contract-m2s contract))))
             (attribute "utm-x" (m2-x m2))
             (attribute "utm-y" (m2-y m2))))))))
 
@@ -59,6 +61,7 @@
   (all-contracts/internal))
 
 (defreport all-contracts-m2s ()
+  (sax:processing-instruction cxml::*sink* "xml-stylesheet" "href=\"/static/contracts.xsl\" type=\"text/xsl\"")
   (all-contracts/internal :include-coords t))
 
 (defun week-of-contract (contract)





More information about the Bknr-cvs mailing list