torrent_add:options ui
This commit is contained in:
parent
9df4492083
commit
8f8a6e41aa
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# deluge_webserver.py
|
||||
#
|
||||
# Copyright (C) Martijn Voncken 2008 <mvoncken@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
@ -58,9 +58,9 @@ class FilteredForm(newforms.Form):
|
|||
output.append(str_hidden)
|
||||
return u'\n'.join(output)
|
||||
|
||||
def as_table(self , filter = None):
|
||||
def as_table(self , filter = None): #add class="newforms"
|
||||
"Returns this form rendered as HTML <tr>s -- excluding the <table></table>."
|
||||
return self._html_output_filtered(u'<tr><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>', u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%s', False, filter)
|
||||
return self._html_output_filtered(u'<tr><th class="newforms">%(label)s</th><td class="newforms">%(errors)s%(field)s%(help_text)s</td></tr>', u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%s', False, filter)
|
||||
|
||||
def as_ul(self, filter = None):
|
||||
"Returns this form rendered as HTML <li>s -- excluding the <ul></ul>."
|
||||
|
@ -70,7 +70,7 @@ class FilteredForm(newforms.Form):
|
|||
"Returns this form rendered as HTML <p>s."
|
||||
return self._html_output_filtered(u'<p>%(label)s %(field)s%(help_text)s</p>', u'<p>%s</p>', '</p>', u' %s', True, filter)
|
||||
|
||||
class Form(newforms.Form):
|
||||
class Form(FilteredForm):
|
||||
info = ""
|
||||
title = "No Title"
|
||||
def __init__(self,data = None):
|
||||
|
|
|
@ -54,6 +54,9 @@ import os
|
|||
|
||||
from json_api import json_api
|
||||
|
||||
#special/complex pages:
|
||||
from torrent_add import torrent_add
|
||||
|
||||
#routing:
|
||||
urls = (
|
||||
"/login", "login",
|
||||
|
@ -176,41 +179,6 @@ class torrent_reannounce:
|
|||
ws.proxy.force_reannounce([torrent_id])
|
||||
do_redirect()
|
||||
|
||||
class torrent_add:
|
||||
@deco.deluge_page
|
||||
def GET(self, name):
|
||||
return render.torrent_add()
|
||||
|
||||
@deco.check_session
|
||||
def POST(self, name):
|
||||
"""
|
||||
allows:
|
||||
*posting of url
|
||||
*posting file-upload
|
||||
*posting of data as string(for greasemonkey-private)
|
||||
"""
|
||||
|
||||
vars = web.input(url = None, torrent = {})
|
||||
|
||||
torrent_name = None
|
||||
torrent_data = None
|
||||
if vars.torrent.filename:
|
||||
torrent_name = vars.torrent.filename
|
||||
torrent_data = vars.torrent.file.read()
|
||||
|
||||
if vars.url and torrent_name:
|
||||
error_page(_("Choose an url or a torrent, not both."))
|
||||
if vars.url:
|
||||
ws.proxy.add_torrent_url(vars.url)
|
||||
do_redirect()
|
||||
elif torrent_name:
|
||||
data_b64 = base64.b64encode(torrent_data)
|
||||
#b64 because of strange bug-reports related to binary data
|
||||
ws.proxy.add_torrent_filecontent(vars.torrent.filename, data_b64)
|
||||
do_redirect()
|
||||
else:
|
||||
error_page(_("no data."))
|
||||
|
||||
class remote_torrent_add:
|
||||
"""
|
||||
For use in remote scripts etc.
|
||||
|
|
|
@ -48,6 +48,9 @@ class subclassed_render(object):
|
|||
self.apply_cfg()
|
||||
|
||||
def apply_cfg(self):
|
||||
if not hasattr(ws,"config"):
|
||||
print "render.py: WARNING,no config"
|
||||
return
|
||||
cache = ws.config.get('cache_templates')
|
||||
self.base_template = template.render(
|
||||
os.path.join(ws.webui_path, 'templates/deluge/'),
|
||||
|
@ -79,8 +82,11 @@ def category_tabs(torrent_list):
|
|||
|
||||
|
||||
def template_crop(text, end):
|
||||
if len(text) > end:
|
||||
return text[0:end - 3] + '...'
|
||||
try:
|
||||
if len(text) > end:
|
||||
return text[0:end - 3] + '...'
|
||||
except:
|
||||
return "[ERROR NOT A STRING:(%s)]" % text
|
||||
return text
|
||||
|
||||
def template_sort_head(id,name):
|
||||
|
|
|
@ -318,6 +318,12 @@ ul.errorlist {
|
|||
#torrent_list {
|
||||
-moz-border-radius:7px;
|
||||
}
|
||||
|
||||
th.newforms {
|
||||
font-size: 12px;
|
||||
text-align:right;
|
||||
color:#FFFFFF;
|
||||
}
|
||||
/* Hides from IE-mac \*/
* html .clearfix {height: 1%;}
.clearfix {display: block;}
/* End hide from IE-mac */
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$def with (add_form)
|
||||
$:render.header(_("Add Torrent"))
|
||||
<div class="panel">
|
||||
<form method="POST" action="/torrent/add" ENCTYPE="multipart/form-data">
|
||||
|
@ -27,6 +28,28 @@ $if get_config('add_another'):
|
|||
<input type="submit" name="submit"
|
||||
value="$_('Submit')" class="form_input">
|
||||
|
||||
<h2>Options</h2>
|
||||
<div class="error">Options are not used yet!</div>
|
||||
|
||||
<h3>$_("Allocation/Location")</h3>
|
||||
<table>
|
||||
$:add_form.as_table(["download_location", "compact_allocation"])
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
<h3>$_("BandWidth")</h3>
|
||||
<table>
|
||||
$:add_form.as_table(["max_download_speed_per_torrent", "max_upload_speed_per_torrent", "max_connections_per_torrent", "max_upload_slots_per_torrent"])
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<h3>$_("General")</h3>
|
||||
<table>
|
||||
$:add_form.as_table(["prioritize_first_last_pieces", "add_paused", "default_private"])
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -68,14 +68,14 @@ start = time.time()
|
|||
torrent_ids = ws.proxy.get_session_state() #Syc-api.
|
||||
torrent_dict = {}
|
||||
for id in torrent_ids:
|
||||
async_proxy.get_torrent_status(dict_cb(id,torrent_dict), id, [])
|
||||
async_proxy.get_torrent_status(dict_cb(id,torrent_dict), id, ["name"])
|
||||
async_proxy.force_call(block=True)
|
||||
|
||||
print "Async-list:",time.time() - start
|
||||
print torrent_dict
|
||||
|
||||
|
||||
print sorted(torrent_list[0].keys())
|
||||
print torrent_dict[torrent_ids[0]].keys()
|
||||
print torrent_dict[torrent_ids[0]]["name"]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -237,16 +237,12 @@ def get_torrent_list():
|
|||
torrent_ids = ws.proxy.get_session_state() #Syc-api.
|
||||
torrent_dict = {}
|
||||
for id in torrent_ids:
|
||||
ws.async_proxy.get_torrent_status(dict_cb(id,torrent_dict), id, [])
|
||||
ws.async_proxy.get_torrent_status(dict_cb(id,torrent_dict), id,
|
||||
TORRENT_KEYS)
|
||||
ws.async_proxy.force_call(block=True)
|
||||
|
||||
return [enhance_torrent_status(id, status)
|
||||
for id, status in torrent_dict.iteritems()]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_categories(torrent_list):
|
||||
trackers = [(torrent['category'] or 'unknown') for torrent in torrent_list]
|
||||
categories = {}
|
||||
|
|
Loading…
Reference in New Issue