payment: note that Stripe has instituted an additional 1% fee for non-US cards
[hcoop/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};
8812fb4d
AC
117 if not (Quota.notifyMod (oldStatus, newStatus, Init.getUserName(), id)) then
118 %><h3>Error sending e-mail notification</h3><%
6704531c
AC
119 end
120 %><h3>Request modified</h3>
121 Back to: <a href="?cmd=open">open requests</a>, <a href="?cmd=list">all requests</a>
122
123<% elseif $"del" <> "" then
124 Group.requireGroupName "server";
125 val id = Web.stoi ($"del");
126 val req = Quota.lookup id;
127 val user = Init.lookupUser (#usr req)
128 %><h3>Are you sure you want to delete request by <% #name user %> for <tt><% #data req %></tt>?</h3>
129 <a href="?del2=<% id %>">Yes, I'm sure!</a>
130
131<% elseif $"del2" <> "" then
132 Group.requireGroupName "server";
133 val id = Web.stoi ($"del2");
134 Quota.delete id
135 %><h3>Request deleted</b><h3>
136 Back to: <a href="?cmd=open">open requests</a>, <a href="?cmd=list">all requests</a>
137
138<% else %>
139
140<h3>Request a disk quota change</h3>
141
ddc53b56 142<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 143
6704531c
AC
144<form method="post">
145
146<table>
bb2ab39e 147 <tr> <th>Volume</th> <th>Used</th> <th>Current Quota</th> <th>Requested Quota (kB)</th> </tr>
6704531c 148<% foreach vol in Quotas.getQuotas (Init.getUserName ()) do %>
bb2ab39e 149 <tr> <td><% #vol vol %></td> <td><% #used vol %> kB (<% (#used vol) / 1024 %> MiB)</td> <td><% #quota vol %> kB (<% (# quota vol) / 1024 %> MiB)</td>
10e55875 150 <td><input name="<% #vol vol %>" value="<% #quota vol %>" pattern="\\d+"></td> </tr>
6704531c
AC
151<% end %>
152</table>
153
154<input type="hidden" name="new" value="1">
155<table class="blanks">
156<tr> <td>Additional comments:</td> <td><textarea name="msg" rows="5" cols="80" wrap="soft"></textarea></td> </tr>
157<tr> <td><input type="submit" value="Request"></td> </tr>
158</table>
159</form>
160
161<% end %>
162
163<% @footer[] %>