A bundle of minor improvements
[hcoop/portal.git] / apt.mlt
diff --git a/apt.mlt b/apt.mlt
index d51c509..1aef9b1 100644 (file)
--- a/apt.mlt
+++ b/apt.mlt
@@ -2,15 +2,18 @@
 
 val admin = Group.inGroupName "server";
 
+val nodeNum = case $"node" of
+                 "" => 4
+               | node => Web.stoi node;
+
 if $"new" <> "" then
-       val node = Web.stoi ($"node");
        val pkgs = String.tokens Char.isSpace ($"new");
 
        ref ok = true;
        ref infos = [];
 
        foreach pkg in pkgs do
-               switch AptQuery.query {node = node, pkg = pkg} of
+               switch AptQuery.query {node = nodeNum, pkg = pkg} of
                  NONE =>
                        ok := false;
                        %><b>Error</b>: Unknown package "<% Web.html pkg %>."<br><%
@@ -25,7 +28,7 @@ if $"new" <> "" then
        end;
 
        if ok then
-               val debian = Init.nodeDebian node %>
+               val debian = Init.nodeDebian nodeNum %>
 Are you sure these are the packages you wanted?<br><br>
 <table>
 <%             foreach info in infos do %>
@@ -35,18 +38,17 @@ Are you sure these are the packages you wanted?<br><br>
        </table><br>
        <br>
        <b>Reason:</b> <blockquote><% Web.htmlNl ($"msg") %></blockquote><br>
-       <a href="apt?node=<% node %>&req=<% foreach info in infos do %><% #name info %>+<% end %>&msg=<% Web.urlEncode ($"msg") %>">Yes, I want to request these packages.</a>
+       <a href="apt?node=<% nodeNum %>&req=<% foreach info in infos do %><% #name info %>+<% end %>&msg=<% Web.urlEncode ($"msg") %>">Yes, I want to request these packages.</a>
 
 <%     end
 
 elseif $"req" <> "" then
-       val node = Web.stoi ($"node");
        val pkgs = String.tokens Char.isSpace ($"req");
 
        ref ok = true;
 
        foreach pkg in pkgs do
-               switch AptQuery.query {node = node, pkg = pkg} of
+               switch AptQuery.query {node = nodeNum, pkg = pkg} of
                  NONE =>
                        ok := false;
                        %><b>Error</b>: Unknown package "<% Web.html pkg %>."<br><%
@@ -59,7 +61,7 @@ elseif $"req" <> "" then
        end;
 
        if ok then
-               val id = Apt.add {usr = Init.getUserId(), node = node, data = $"req", msg = $"msg"};
+               val id = Apt.add {usr = Init.getUserId(), node = nodeNum, data = $"req", msg = $"msg"};
                if not (Apt.notifyNew id) then
                        %><h3>Error sending e-mail notification</h3><%
                end
@@ -74,7 +76,7 @@ elseif $"cmd" = "open" then
 <br><hr><br>
 <table class="blanks">
 <tr> <td>By:</td> <td colspan="2"><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
-<tr> <td>Time:</td> <td colspan="2"><% #stamp req %></td> </tr>
+<tr> <td>Time:</td> <td colspan="2"><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
 <tr> <td>Node:</td> <td colspan="2"><% Web.html (Init.nodeName (#node req)) %></td> </tr>
 <tr> <td>Packages:</td><%
        ref first = true;
@@ -116,7 +118,7 @@ elseif $"cmd" = "list" then
 <br><hr><br>
 <table class="blanks">
 <tr> <td>By:</td> <td colspan="2"><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
-<tr> <td>Time:</td> <td colspan="2"><% #stamp req %></td> </tr>
+<tr> <td>Time:</td> <td colspan="2"><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
 <tr> <td>Node:</td> <td colspan="2"><% Web.html (Init.nodeName (#node req)) %></td> </tr>
 <tr> <td>Packages:</td><%
        ref first = true;
@@ -161,7 +163,7 @@ elseif $"mod" <> "" then
 <input type="hidden" name="save" value="<% id %>">
 <table class="blanks">
 <tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr>
-<tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
+<tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
 <tr> <td>Node:</td> <td><select name="node">
 <% foreach node in Init.listNodes () do %>
        <option value="<% #id node %>"<% if #id node = #node req then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>; Debian <% Web.html (#debian node) %>)</option>
@@ -186,10 +188,8 @@ elseif $"mod" <> "" then
        val oldStatus = #status req;
        val newStatus = Apt.statusFromInt (Web.stoi ($"status"));
        Apt.modify {req with node = node, data = $"pkgs", msg = $"msg", status = newStatus};
-       if oldStatus <> newStatus then
-               if not (Apt.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then
-                       %><h3>Error sending e-mail notification</h3><%
-               end
+       if not (Apt.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then
+               %><h3>Error sending e-mail notification</h3><%
        end
        %><h3>Request modified</h3>
        Back to: <a href="apt?cmd=open">open requests</a>, <a href="apt?cmd=list">all requests</a>
@@ -213,16 +213,19 @@ elseif $"mod" <> "" then
 
 <h3>Request new installations</h3>
 
-List the package names you'd like, separated by any whitespace characters.
+List the package names you'd like, separated by any whitespace
+characters. If you want the version of a package from <a
+href="http://backports-master.debian.org/">backports</a>, specify that
+in the "Reason" field.
 
 <form action="apt" method="post">
 <table class="blanks">
 <tr> <td>Machine:</td> <td><select name="node">
 <% foreach node in Init.listNodes () do %>
-       <option value="<% #id node %>"><% Web.html (#name node) %> (<% Web.html (#descr node) %>; Debian <% Web.html (#debian node) %>)</option>
+       <option value="<% #id node %>"<% if #id node = nodeNum then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>; Debian <% Web.html (#debian node) %>)</option>
 <% end %>
 </select></td></tr>
-<tr> <td>Packages:</td> <td><textarea name="new" rows="10" cols="40" wrap="soft"></textarea></td> </tr>
+<tr> <td>Packages:</td> <td><textarea name="new" rows="10" cols="40" wrap="soft" required="required"></textarea></td> </tr>
 <tr> <td>Reason:</td> <td><textarea name="msg" rows="5" cols="80" wrap="soft"></textarea></td> </tr>
 <tr> <td><input type="submit" value="Request"></td> </tr>
 </table>