file_priorities

This commit is contained in:
Martijn Voncken 2008-06-23 04:18:06 +00:00
parent e43f2370e1
commit d9676aabca
2 changed files with 16 additions and 12 deletions

View File

@ -191,13 +191,12 @@ class torrent_files:
@deco.check_session @deco.check_session
@deco.torrent @deco.torrent
def POST(self, torrent): def POST(self, torrent):
file_priorities = web.input(file_priorities=[]).file_priorities values = web.input()
#file_priorities contains something like ['0','2','3','4'] file_priorities = []
#transform to: [1,0,1,1,1] for i in xrange(len(torrent.files)):
proxy_prio = [0 for x in xrange(len(torrent.file_priorities))] file_priorities.append(int(getattr(values,"prio_%s" % i )))
for pos in file_priorities:
proxy_prio[int(pos)] = 1 proxy.set_torrent_file_priorities(torrent.id, file_priorities)
proxy.set_torrent_file_priorities(torrent.id, proxy_prio)
do_redirect() do_redirect()
route("/torrent/files/(.*)", torrent_files) route("/torrent/files/(.*)", torrent_files)

View File

@ -6,20 +6,25 @@ $def with (torrent)
$altrow(True) $altrow(True)
<tr class="head"> <tr class="head">
<th width="100%">$_("File")</th> <th width="100%">$_("File")</th>
<th width="130px">$_("Size")</th> <th width="50px">$_("Size")</th>
<th width="50px">$_("Progress")</th> <th width="50px">$_("Progress")</th>
<th width="10px">$_("X")</th>
<th width="10px">$_("N")</th>
<th width="10px">$_("+")</th>
<th width="10px">$_("++")</th>
</tr> </tr>
$for i, file in enumerate(torrent.files): $for i, file in enumerate(torrent.files):
<tr class="$altrow()" > <tr class="$altrow()" >
<td title="$file['path']"> <td title="$file['path']">
<input type="checkbox" name="file_priorities" id="file_priorities" value="$i"
$if (torrent.file_priorities[i]):
checked
>
$(crop_left(file["path"], 60)) $(crop_left(file["path"], 60))
</td> </td>
<td style="white-space:nowrap">$fsize(file["size"])</td> <td style="white-space:nowrap">$fsize(file["size"])</td>
<td align="right">$int(torrent.file_progress[i] * 100)%</td> <td align="right">$int(torrent.file_progress[i] * 100)%</td>
$for prio in [0, 1, 2, 5]:
<td><input type="radio" id="prio_$i" name="prio_$i" value="$prio" style="margin:0px"
$if torrent.file_priorities[i] == prio:
checked
></input></td>
</tr> </tr>
</table> </table>
<input type="submit" value="$_('Update')" name="submit_files"> <input type="submit" value="$_('Update')" name="submit_files">