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.torrent
def POST(self, torrent):
file_priorities = web.input(file_priorities=[]).file_priorities
#file_priorities contains something like ['0','2','3','4']
#transform to: [1,0,1,1,1]
proxy_prio = [0 for x in xrange(len(torrent.file_priorities))]
for pos in file_priorities:
proxy_prio[int(pos)] = 1
proxy.set_torrent_file_priorities(torrent.id, proxy_prio)
values = web.input()
file_priorities = []
for i in xrange(len(torrent.files)):
file_priorities.append(int(getattr(values,"prio_%s" % i )))
proxy.set_torrent_file_priorities(torrent.id, file_priorities)
do_redirect()
route("/torrent/files/(.*)", torrent_files)

View File

@ -6,20 +6,25 @@ $def with (torrent)
$altrow(True)
<tr class="head">
<th width="100%">$_("File")</th>
<th width="130px">$_("Size")</th>
<th width="50px">$_("Size")</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>
$for i, file in enumerate(torrent.files):
<tr class="$altrow()" >
<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))
</td>
<td style="white-space:nowrap">$fsize(file["size"])</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>
</table>
<input type="submit" value="$_('Update')" name="submit_files">