Commit | Line | Data |
---|---|---|
6b23a78b AC |
1 | <% @header [("title", ["APT package installation requests"])]; |
2 | ||
3 | val admin = Group.inGroupName "server"; | |
4 | ||
c81f707d | 5 | val nodeNum = case $"node" of |
2f3afc4b | 6 | "" => 4 |
c81f707d AC |
7 | | node => Web.stoi node; |
8 | ||
6b23a78b AC |
9 | if $"new" <> "" then |
10 | val pkgs = String.tokens Char.isSpace ($"new"); | |
11 | ||
12 | ref ok = true; | |
13 | ref infos = []; | |
14 | ||
15 | foreach pkg in pkgs do | |
c81f707d | 16 | switch AptQuery.query {node = nodeNum, pkg = pkg} of |
6b23a78b AC |
17 | NONE => |
18 | ok := false; | |
19 | %><b>Error</b>: Unknown package "<% Web.html pkg %>."<br><% | |
20 | | SOME info => | |
21 | if #installed info then | |
22 | ok := false; | |
23 | %><b>Error</b>: Package "<% pkg %>" is already installed!<br><% | |
24 | else | |
25 | infos := info :: infos | |
26 | end | |
27 | end | |
28 | end; | |
29 | ||
18eeb749 | 30 | if ok then |
c81f707d | 31 | val debian = Init.nodeDebian nodeNum %> |
6b23a78b AC |
32 | Are you sure these are the packages you wanted?<br><br> |
33 | <table> | |
34 | <% foreach info in infos do %> | |
18eeb749 | 35 | <tr> <td align="right"><a href="http://packages.debian.org/<% debian %>/<% #section info %>/<% #name info %>"><% #name info %></a></td> |
6b23a78b AC |
36 | <td><% Web.html (#descr info) %></td> </tr> |
37 | <% end %> | |
38 | </table><br> | |
39 | <br> | |
40 | <b>Reason:</b> <blockquote><% Web.htmlNl ($"msg") %></blockquote><br> | |
c81f707d | 41 | <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> |
6b23a78b AC |
42 | |
43 | <% end | |
44 | ||
45 | elseif $"req" <> "" then | |
46 | val pkgs = String.tokens Char.isSpace ($"req"); | |
47 | ||
48 | ref ok = true; | |
49 | ||
50 | foreach pkg in pkgs do | |
c81f707d | 51 | switch AptQuery.query {node = nodeNum, pkg = pkg} of |
6b23a78b AC |
52 | NONE => |
53 | ok := false; | |
54 | %><b>Error</b>: Unknown package "<% Web.html pkg %>."<br><% | |
55 | | SOME info => | |
56 | if #installed info then | |
57 | ok := false; | |
58 | %><b>Error</b>: Package "<% pkg %>" is already installed!<br><% | |
59 | end | |
60 | end | |
61 | end; | |
62 | ||
63 | if ok then | |
c81f707d | 64 | val id = Apt.add {usr = Init.getUserId(), node = nodeNum, data = $"req", msg = $"msg"}; |
6b23a78b | 65 | if not (Apt.notifyNew id) then |
b6dd1aaf | 66 | %><h3>Error sending e-mail notification</h3><% |
6b23a78b | 67 | end |
b6dd1aaf | 68 | %><h3>Request added</h3><% |
6b23a78b AC |
69 | end |
70 | ||
71 | elseif $"cmd" = "open" then | |
b6dd1aaf | 72 | %><h3>Open requests</h3> |
6b23a78b AC |
73 | <a href="apt?cmd=list">List all requests</a><% |
74 | ||
5da9f4a9 | 75 | foreach (name, req) in Apt.listOpen () do %> |
6b23a78b | 76 | <br><hr><br> |
b6dd1aaf AC |
77 | <table class="blanks"> |
78 | <tr> <td>By:</td> <td colspan="2"><a href="user?id=<% #usr req %>"><% name %></a></td> </tr> | |
6b8b767b | 79 | <tr> <td>Time:</td> <td colspan="2"><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr> |
18eeb749 | 80 | <tr> <td>Node:</td> <td colspan="2"><% Web.html (Init.nodeName (#node req)) %></td> </tr> |
b6dd1aaf | 81 | <tr> <td>Packages:</td><% |
6b23a78b AC |
82 | ref first = true; |
83 | ||
5da9f4a9 | 84 | val pkgs = String.tokens Char.isSpace (#data req); |
18eeb749 | 85 | val debian = Init.nodeDebian (#node req); |
6b23a78b AC |
86 | |
87 | foreach pkg in pkgs do | |
88 | if first then | |
89 | first := false | |
90 | else | |
91 | %></tr><tr> <td></td><% | |
92 | end; | |
18eeb749 | 93 | switch AptQuery.query {node = #node req, pkg = pkg} of |
6b23a78b AC |
94 | NONE => |
95 | %><td></td> <td><b>Error</b>: Unknown package "<% Web.html pkg %>."</td><% | |
96 | | SOME info => | |
18eeb749 | 97 | %><td align="right"><a href="http://packages.debian.org/<% debian %>/<% #section info %>/<% #name info %>"><% #name info %></a></td> |
6b23a78b AC |
98 | <td><% Web.html (#descr info) %></td><% |
99 | end | |
100 | end %> | |
101 | </tr> | |
b6dd1aaf | 102 | <tr> <td>Reason:</td> <td colspan="2"><% Web.html (#msg req) %></td> </tr> |
6b23a78b AC |
103 | </table> |
104 | ||
105 | <% if admin then %> | |
106 | <br> | |
107 | <a href="apt?mod=<% #id req %>">[Modify]</a> | |
108 | <a href="apt?del=<% #id req %>">[Delete]</a><br> | |
109 | To install, run: <tt>apt-get install<% foreach pkg in pkgs do %> <% pkg %><% end %></tt> | |
110 | <% end %> | |
111 | ||
112 | <% end | |
113 | ||
114 | elseif $"cmd" = "list" then | |
b6dd1aaf | 115 | %><h3>All requests</h3><% |
6b23a78b | 116 | |
5da9f4a9 | 117 | foreach (name, req) in Apt.list () do %> |
6b23a78b | 118 | <br><hr><br> |
b6dd1aaf AC |
119 | <table class="blanks"> |
120 | <tr> <td>By:</td> <td colspan="2"><a href="user?id=<% #usr req %>"><% name %></a></td> </tr> | |
6b8b767b | 121 | <tr> <td>Time:</td> <td colspan="2"><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr> |
18eeb749 | 122 | <tr> <td>Node:</td> <td colspan="2"><% Web.html (Init.nodeName (#node req)) %></td> </tr> |
b6dd1aaf | 123 | <tr> <td>Packages:</td><% |
6b23a78b AC |
124 | ref first = true; |
125 | ||
5da9f4a9 | 126 | val pkgs = String.tokens Char.isSpace (#data req); |
18eeb749 | 127 | val debian = Init.nodeDebian (#node req); |
6b23a78b AC |
128 | |
129 | foreach pkg in pkgs do | |
130 | if first then | |
131 | first := false | |
132 | else | |
133 | %></tr><tr> <td></td><% | |
134 | end; | |
18eeb749 | 135 | switch AptQuery.query {node = #node req, pkg = pkg} of |
6b23a78b AC |
136 | NONE => |
137 | %><td></td> <td><b>Error</b>: Unknown package "<% Web.html pkg %>."</td><% | |
138 | | SOME info => | |
18eeb749 | 139 | %><td align="right"><a href="http://packages.debian.org/<% debian %>/<% #section info %>/<% #name info %>"><% #name info %></a></td> |
6b23a78b AC |
140 | <td><% Web.html (#descr info) %></td><% |
141 | end | |
142 | end %> | |
143 | </tr> | |
b6dd1aaf | 144 | <tr> <td>Reason:</td> <td colspan="2"><% Web.html (#msg req) %></td> </tr> |
6b23a78b AC |
145 | </table> |
146 | ||
147 | <% if admin then %> | |
148 | <br> | |
149 | <a href="apt?mod=<% #id req %>">[Modify]</a> | |
150 | <a href="apt?del=<% #id req %>">[Delete]</a> | |
151 | <% end %> | |
152 | ||
153 | <% end | |
154 | ||
155 | elseif $"mod" <> "" then | |
156 | Group.requireGroupName "server"; | |
157 | val id = Web.stoi ($"mod"); | |
5da9f4a9 | 158 | val req = Apt.lookup id; |
6b23a78b | 159 | val user = Init.lookupUser (#usr req) %> |
b6dd1aaf | 160 | <h3>Handle request</h3> |
6b23a78b | 161 | |
a4ccdb5e | 162 | <form action="apt" method="post"> |
6b23a78b | 163 | <input type="hidden" name="save" value="<% id %>"> |
b6dd1aaf AC |
164 | <table class="blanks"> |
165 | <tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr> | |
6b8b767b | 166 | <tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr> |
18eeb749 AC |
167 | <tr> <td>Node:</td> <td><select name="node"> |
168 | <% foreach node in Init.listNodes () do %> | |
169 | <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> | |
170 | <% end %> | |
171 | </select> | |
b6dd1aaf | 172 | <tr> <td>Status:</td> <td><select name="status"> |
6b23a78b AC |
173 | <option value="0"<% if #status req = Apt.NEW then %> selected<% end %>>New</option> |
174 | <option value="1"<% if #status req = Apt.INSTALLED then %> selected<% end %>>Installed</option> | |
175 | <option value="2"<% if #status req = Apt.REJECTED then %> selected<% end %>>Rejected</option> | |
176 | </select></td> </tr> | |
b6dd1aaf AC |
177 | <tr> <td>Packages:</td> <td><textarea name="pkgs" rows="5" cols="40" wrap="soft"><% Web.html (#data req) %></textarea></td> </tr> |
178 | <tr> <td>Message:</td> <td><textarea name="msg" rows="10" cols="80" wrap="soft"><% Web.html (#msg req) %></textarea></td> </tr> | |
6b23a78b AC |
179 | <tr> <td><input type="submit" value="Save"></td> </tr> |
180 | </table> | |
181 | </form> | |
182 | ||
183 | <% elseif $"save" <> "" then | |
184 | Group.requireGroupName "server"; | |
185 | val id = Web.stoi ($"save"); | |
18eeb749 | 186 | val node = Web.stoi ($"node"); |
5da9f4a9 | 187 | val req = Apt.lookup id; |
6b23a78b AC |
188 | val oldStatus = #status req; |
189 | val newStatus = Apt.statusFromInt (Web.stoi ($"status")); | |
18eeb749 | 190 | Apt.modify {req with node = node, data = $"pkgs", msg = $"msg", status = newStatus}; |
8812fb4d AC |
191 | if not (Apt.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then |
192 | %><h3>Error sending e-mail notification</h3><% | |
6b23a78b | 193 | end |
b6dd1aaf | 194 | %><h3>Request modified</h3> |
6b23a78b AC |
195 | Back to: <a href="apt?cmd=open">open requests</a>, <a href="apt?cmd=list">all requests</a> |
196 | ||
197 | <% elseif $"del" <> "" then | |
198 | Group.requireGroupName "server"; | |
199 | val id = Web.stoi ($"del"); | |
5da9f4a9 | 200 | val req = Apt.lookup id; |
6b23a78b | 201 | val user = Init.lookupUser (#usr req) |
b6dd1aaf | 202 | %><h3>Are you sure you want to delete request by <% #name user %> for <tt><% #data req %></tt>?</h3> |
6b23a78b AC |
203 | <a href="apt?del2=<% id %>">Yes, I'm sure!</a> |
204 | ||
205 | <% elseif $"del2" <> "" then | |
206 | Group.requireGroupName "server"; | |
207 | val id = Web.stoi ($"del2"); | |
5da9f4a9 | 208 | Apt.delete id |
b6dd1aaf | 209 | %><h3>Request deleted</b><h3> |
6b23a78b AC |
210 | Back to: <a href="apt?cmd=open">open requests</a>, <a href="apt?cmd=list">all requests</a> |
211 | ||
212 | <% else %> | |
213 | ||
b6dd1aaf | 214 | <h3>Request new installations</h3> |
6b23a78b | 215 | |
3688b866 CE |
216 | List the package names you'd like, separated by any whitespace |
217 | characters. If you want the version of a package from <a | |
218 | href="http://backports-master.debian.org/">backports</a>, specify that | |
219 | in the "Reason" field. | |
6b23a78b | 220 | |
a4ccdb5e | 221 | <form action="apt" method="post"> |
b6dd1aaf | 222 | <table class="blanks"> |
18eeb749 AC |
223 | <tr> <td>Machine:</td> <td><select name="node"> |
224 | <% foreach node in Init.listNodes () do %> | |
c81f707d | 225 | <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> |
18eeb749 AC |
226 | <% end %> |
227 | </select></td></tr> | |
b6dd1aaf AC |
228 | <tr> <td>Packages:</td> <td><textarea name="new" rows="10" cols="40" wrap="soft"></textarea></td> </tr> |
229 | <tr> <td>Reason:</td> <td><textarea name="msg" rows="5" cols="80" wrap="soft"></textarea></td> </tr> | |
6b23a78b AC |
230 | <tr> <td><input type="submit" value="Request"></td> </tr> |
231 | </table> | |
232 | </form> | |
233 | ||
234 | <% end %> | |
235 | ||
236 | <% @footer[] %> |