Don't show pending approved applications older than 1 month
[hcoop/zz_old/portal.git] / users.mlt
index cd7582b..1cd37f0 100644 (file)
--- a/users.mlt
+++ b/users.mlt
@@ -17,7 +17,7 @@ if $"cmd" = "Create" then
                                          "" => Balance.addBalance ($"name")
                                        | s => Web.stoi s);
 
-                       val id = Init.addUser ($"name", $"rname", bal, ap);
+                       val id = Init.addUser ($"name", $"rname", bal, ap, 1);
                        Group.addToGroups (id, map Web.stoi (Web.getMultiParam "grp"));
 
                        if $"amount" <> "" then
@@ -74,9 +74,8 @@ elseif $"mod" <> "" then
        Init.grandfatherUsers()
        %><h3>Grandfathered</h3>
 
-<% end %>
-
-<% if showNormal then %>
+<% elseif $"cmd" = "addform" then
+        showNormal := false %>        
 <h3>New member</h3>
 
 <form action="users" method="post">
@@ -101,6 +100,61 @@ elseif $"mod" <> "" then
 </table>
 </form>
 
+<% elseif $"cmd" = "unmigrated" then
+   showNormal := false;
+   ref negative = 0;
+   val users = Init.unmigratedUsers () %>
+
+<h3>Unmigrated members (<% length users %>)</h3>
+
+<table>
+<% foreach user in users do %>
+       <tr> <td><a href="user?id=<% #id user %>"><% Web.html (#name user) %></a></td>
+<% val bal = Balance.lookupBalance (#bal user);
+if Balance.isNegative bal then
+   negative := negative + 1
+end %>
+<td><% #amount bal %></td><td>
+<%if #name bal <> #name user then %>
+ <i><% Web.html (#name bal) %></i>
+<% end %>
+</td> </tr>
+<% end %>
+</table>
+
+<p><% negative %> have negative balances.</p>
+
+<% elseif $"cmd" = "diff" then
+   showNormal := false;
+
+   val against = (case $"against" of
+                              "" => Init.usersInAfs ()
+                    | x => String.tokens Char.isSpace x);
+
+   val diff = Init.usersDiff (Init.listUsernames (), against) %>
+
+<h3>User diff</h3>
+
+<h4>Only on the portal:</h4>
+<ul>
+<% foreach user in #onlyInFirst diff do %>
+   <li> <a href="user?id=<% valOf (Init.userNameToId user) %>"><% Web.html user %></a></li>
+<% end %>
+</ul>
+
+<h4>Only in AFS:</h4>
+<ul>
+<% foreach user in #onlyInSecond diff do %>
+   <li> <% Web.html user %></li>
+<% end %>
+</ul>
+
+<% end %>
+
+<% if showNormal then %>
+
+<a href="users?cmd=addform">Add a user manually</a><br>
+
 <h3>Manage current members</h3>
 
 <table>
@@ -115,6 +169,8 @@ if #name bal <> #name user then %>
 </table>
 
 <br><a href="users?cmd=grandfather">Grandfather old users to have applications</a><br>
+<a href="users?cmd=unmigrated">Who hasn't migrated yet?</a><br>
+<a href="users?cmd=diff">How does the set of users in AFS compare with the set of active portal users?</a><br>
 
 <% end %>