Reports for figuring out which accounts to freeze or boot; most of new SSL request...
[bpt/portal.git] / quota.mlt
CommitLineData
6704531c
AC
1<% @header [("title", ["Disk quota change requests"])];
2
3val admin = Group.inGroupName "server";
4
5if $"new" <> "" then
6 ref url = "?cmd=request&msg=" ^ Web.urlEncode ($"msg");
7 ref changed = false;
8 val uname = Init.getUserName ();
9
10 %>Are you sure you want to request these quota changes?
11 <ul><%
12
13 foreach vol in Quotas.getQuotas uname do
14 val requested = Web.stoi ($(#vol vol));
15 url := url ^ "&" ^ #vol vol ^ "=" ^ Int.toString requested;
16 if requested <> #quota vol then
17 changed := true;
18 %><li> Change quota for <% #vol vol %> from <% #quota vol %> to <% requested %>.</li><%
19 end
20 end;
21
22 %></ul><%
23 if changed then %>
24 <a href="<% url %>">Yes, I'm sure!</a>
25 <% else %>
26 Hm, no changes!
27 <% end
28elseif $"cmd" = "request" then
29 ref cmds = "";
30 val uname = Init.getUserName ();
31
32 foreach vol in Quotas.getQuotas uname do
33 val requested = Web.stoi ($(#vol vol));
34 if requested <> #quota vol then
35 cmds := cmds ^ "fs sq " ^ Quotas.path (#vol vol) ^ " " ^ Int.toString requested
36 ^ "\n# Current quota: " ^ Int.toString (#quota vol) ^ "\n"
37 end
38 end;
39
40 val id = Quota.add (Init.getUserId (), cmds, $"msg");
41 if not (Quota.notifyNew id) then
42 %><h3>Error sending e-mail notification</h3><%
43 end
44 %><h3>Request added</h3><%
45
46elseif $"cmd" = "open" then
47 %><h3>Open requests</h3>
48 <a href="?cmd=list">List all requests</a><%
49
50 foreach (name, req) in Quota.listOpen () do %>
51<br><hr><br>
52<table class="blanks">
53<tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
6b8b767b 54<tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
6704531c
AC
55<tr> <td>Request:</td> <td><% Web.htmlNl (#data req) %></td> </tr>
56<tr> <td>Reason:</td> <td><% Web.html (#msg req) %></td> </tr>
57</table>
58
59<% if admin then %>
60 <br>
61 <a href="?mod=<% #id req %>">[Modify]</a>
62 <a href="?del=<% #id req %>">[Delete]</a><br>
63<% end %>
64
65<% end
66
67elseif $"cmd" = "list" then
68 %><h3>All requests</h3><%
69
70 foreach (name, req) in Quota.list () do %>
71<br><hr><br>
72<table class="blanks">
73<tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
6b8b767b 74<tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
6704531c
AC
75<tr> <td>Request:</td> <td><% Web.htmlNl (#data req) %></td> </tr>
76<tr> <td>Reason:</td> <td><% Web.html (#msg req) %></td> </tr>
77</table>
78
79<% if admin then %>
80 <br>
81 <a href="?mod=<% #id req %>">[Modify]</a>
82 <a href="?del=<% #id req %>">[Delete]</a>
83<% end %>
84
85<% end
86
87elseif $"mod" <> "" then
88 Group.requireGroupName "server";
89 val id = Web.stoi ($"mod");
90 val req = Quota.lookup id;
91 val user = Init.lookupUser (#usr req) %>
92<h3>Handle request</h3>
93
94<form method="post">
95<input type="hidden" name="save" value="<% id %>">
96<table class="blanks">
97<tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr>
6b8b767b 98<tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
6704531c
AC
99<tr> <td>Status:</td> <td><select name="status">
100 <option value="0"<% if #status req = Quota.NEW then %> selected<% end %>>New</option>
101 <option value="1"<% if #status req = Quota.INSTALLED then %> selected<% end %>>Installed</option>
102 <option value="2"<% if #status req = Quota.REJECTED then %> selected<% end %>>Rejected</option>
103</select></td> </tr>
104<tr> <td>Request:</td> <td><input name="req" size="60" value="<% Web.html (#data req) %>"></td> </tr>
105<tr> <td>Message:</td> <td><textarea name="msg" rows="10" cols="80" wrap="soft"><% Web.html (#msg req) %></textarea></td> </tr>
106<tr> <td><input type="submit" value="Save"></td> </tr>
107</table>
108</form>
109
110<% elseif $"save" <> "" then
111 Group.requireGroupName "server";
112 val id = Web.stoi ($"save");
113 val req = Quota.lookup id;
114 val oldStatus = #status req;
115 val newStatus = Quota.statusFromInt (Web.stoi ($"status"));
116 Quota.modify {req with data = $"req", msg = $"msg", status = newStatus};
117 if oldStatus <> newStatus then
118 if not (Quota.notifyMod (oldStatus, newStatus, Init.getUserName(), id)) then
119 %><h3>Error sending e-mail notification</h3><%
120 end
121 end
122 %><h3>Request modified</h3>
123 Back to: <a href="?cmd=open">open requests</a>, <a href="?cmd=list">all requests</a>
124
125<% elseif $"del" <> "" then
126 Group.requireGroupName "server";
127 val id = Web.stoi ($"del");
128 val req = Quota.lookup id;
129 val user = Init.lookupUser (#usr req)
130 %><h3>Are you sure you want to delete request by <% #name user %> for <tt><% #data req %></tt>?</h3>
131 <a href="?del2=<% id %>">Yes, I'm sure!</a>
132
133<% elseif $"del2" <> "" then
134 Group.requireGroupName "server";
135 val id = Web.stoi ($"del2");
136 Quota.delete id
137 %><h3>Request deleted</b><h3>
138 Back to: <a href="?cmd=open">open requests</a>, <a href="?cmd=list">all requests</a>
139
140<% else %>
141
142<h3>Request a disk quota change</h3>
143
ddc53b56 144<p>Remember that a high quota does not by itself use up any resources. Quotas are solely a check on unintentional overusage. We don't yet have any concrete policies to charge members based on disk usage, and, if we do implement such policies, you'll be charged only on actual disk usage, not quota.</p>
e2f0a2c7 145
6704531c
AC
146<form method="post">
147
148<table>
149<tr> <th>Volume</th> <th>Used (kB)</th> <th>Quota now (kB)</th> <th>Requested quota (kB)</th> </tr>
150<% foreach vol in Quotas.getQuotas (Init.getUserName ()) do %>
151 <tr> <td><% #vol vol %></td> <td><% #used vol %></td> <td><% #quota vol %></td>
152 <td><input name="<% #vol vol %>" value="<% #quota vol %>"></td> </tr>
153<% end %>
154</table>
155
156<input type="hidden" name="new" value="1">
157<table class="blanks">
158<tr> <td>Additional comments:</td> <td><textarea name="msg" rows="5" cols="80" wrap="soft"></textarea></td> </tr>
159<tr> <td><input type="submit" value="Request"></td> </tr>
160</table>
161</form>
162
163<% end %>
164
165<% @footer[] %>