change name of config-file; choose-files on add

This commit is contained in:
Martijn Voncken 2008-06-24 18:20:14 +00:00
commit 76a19a7d5a
9 changed files with 42 additions and 68 deletions

View file

@ -188,6 +188,11 @@ class torrent_delete:
route("/torrent/delete/(.*)",torrent_delete) route("/torrent/delete/(.*)",torrent_delete)
class torrent_files: class torrent_files:
@deco.deluge_page
@deco.torrent
def GET(self,torrent):
return render.torrent_files(torrent, None)
@deco.check_session @deco.check_session
@deco.torrent @deco.torrent
def POST(self, torrent): def POST(self, torrent):

View file

@ -60,7 +60,7 @@ class subclassed_render(object):
self.cfg_template = config.get('template') self.cfg_template = config.get('template')
template_path = os.path.join(self.webui_path, 'templates/%s/' % self.cfg_template) template_path = os.path.join(self.webui_path, 'templates/%s/' % self.cfg_template)
if not os.path.exists(template_path): if not os.path.exists(template_path):
template_path = os.path.join(self.webui_path, 'templates/deluge/') template_path = os.path.join(self.webui_path, 'templates/white/')
self.meta = Storage(eval(open(os.path.join(template_path,'meta.cfg')).read())) self.meta = Storage(eval(open(os.path.join(template_path,'meta.cfg')).read()))
#load renerders #load renerders

View file

@ -1,6 +1,10 @@
$def with (torrent) $def with (torrent, redirect=None)
<form method="POST" action="$base/torrent/files/$torrent.id"> <form method="POST" action="$base/torrent/files/$torrent.id">
$if redirect:
<input type="hidden" name="redir" value="$base/home">
$else:
<input type="hidden" name="redir" value="$self_url()"> <input type="hidden" name="redir" value="$self_url()">
<table width="100%"> <table width="100%">
$altrow(True) $altrow(True)

View file

@ -12,59 +12,13 @@ $if error:
<table> <table>
$:add_form.as_table() $:add_form.as_table()
</table> </table>
<!--OLD stuff :
<div class="form_row">
<span class="form_label">$_('Url')</span>
<input type="text" name="url" class="form_input" size=60
value="$get('url')" >
</div>
<div class="form_row">
<span class="form_label">$_('Upload torrent')</span>
<input type="file" name="torrent" class="form_input" size=50>
</div>
<div class="form_row">
<span class="form_label">$_('Hash')</span>
<input type="text" name="hash" class="form_input" size=60
value="$get('hash')" >
</div>
-->
<!--
<div class="form_row">
<input type="checkbox" name="add_another" class="form_input"
$if get_config('add_another'):
selected
>
<span class="form_label">$_('Add Another (Stay in add page)')</span>
</div>
-->
<a onclick="javascript:toggle_options()">$_('Options')</a> <a onclick="javascript:toggle_options()">$_('Options')</a>
<!--todo: cookie setting for last-used options display or not--> <!--todo: cookie setting for last-used options display or not-->
<br> <br>
<div id="torrent_add_options" style="display:none"> <div id="torrent_add_options" style="display:none">
<!--
it's possible to use blocks with options_form, but not now.
<table>
$:options_form.as_table(["download_location", "compact_allocation"])
</table>
<h3>$_("BandWidth")</h3>
<table>
$:options_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>
$:options_form.as_table(["prioritize_first_last_pieces", "add_paused", "default_private"])
</table>
-->
<table> <table>
$:options_form.as_table() $:options_form.as_table()
</table> </table>

View file

@ -39,7 +39,7 @@ $for id, title, url in admin_pages:
</td><td> </td><td>
</td><td align="right" width="420px"> </td><td align="right" width="500px">
$:part_stats() $:part_stats()
</td></tr></table> </td></tr></table>

View file

@ -5,6 +5,16 @@ $def with (filters)
<div id="organize_block"> <div id="organize_block">
<div id="organize_state"> <div id="organize_state">
<div class="title">$_('Keyword')</div>
<input type="text" name="keyword" id="keyword" value="$get('keyword')" style="width:100px;padding:0px"
title="$_('Filter on a keyword')"
/>
$if get('keyword'):
<img src="$base/static/images/tango/edit-clear.png" alt="$_('Clear')"
onclick="el('keyword').value='';el('category_form').submit();"
>
<!--1st button widget is default , i dont want that here, using an image instead :(-->
<br /><br />
<div class="title">$_('State')</div> <div class="title">$_('State')</div>
<ul> <ul>
$for state, num in filters.state: $for state, num in filters.state:
@ -38,17 +48,6 @@ $for tracker, num in filters.tracker:
</ul> </ul>
<div class="title">$_('Keyword')</div>
<input type="text" name="keyword" id="keyword" value="$get('keyword')" style="width:100px;padding:0px"
title="$_('Filter on a keyword')"
/>
$if get('keyword'):
<img src="$base/static/images/tango/edit-clear.png" alt="$_('Clear')"
onclick="el('keyword').value='';el('category_form').submit();"
>
<!--1st button widget is default , i dont want that here, using an image instead :(-->
</div> </div>
</form> </form>
</div> </div>

View file

@ -154,7 +154,7 @@ h3 {
border-width:2px 2px 2px 12px; border-width:2px 2px 2px 12px;
border-color:#C3D9FF; border-color:#C3D9FF;
-moz-border-radius:5px; -moz-border-radius:5px;
height:400px; height:280px;
/*float: right;*/ /*float: right;*/
} }

View file

@ -66,11 +66,13 @@ class AddForm(forms.Form):
widget=forms.TextInput(attrs={'size':60})) widget=forms.TextInput(attrs={'size':60}))
torrent = forms.CharField(label=_("Upload torrent"), required=False, torrent = forms.CharField(label=_("Upload torrent"), required=False,
widget=forms.FileInput(attrs={'size':60})) widget=forms.FileInput(attrs={'size':60}))
#hash = forms.CharField(label=_("Hash"), required=False, #hash = forms.CharField(label=_("Hash"), required=False,
# widget=forms.TextInput(attrs={'size':60})) # widget=forms.TextInput(attrs={'size':60}))
#ret = forms.CheckBox(_('Add more')) #ret = forms.CheckBox(_('Add more'))
choose_files = forms.CheckBox(_('Choose Files'))
class torrent_add: class torrent_add:
def add_page(self,error = None): def add_page(self,error = None):
@ -95,6 +97,7 @@ class torrent_add:
*posting of url *posting of url
*posting file-upload *posting file-upload
""" """
vars = web.input(url = None, torrent = {},choose_files = False)
options_form = OptionsForm(utils.get_newforms_data(OptionsForm)) options_form = OptionsForm(utils.get_newforms_data(OptionsForm))
if not options_form.is_valid(): if not options_form.is_valid():
@ -103,7 +106,7 @@ class torrent_add:
options = options_form.cleaned_data options = options_form.cleaned_data
vars = web.input(url = None, torrent = {})
torrent_name = None torrent_name = None
torrent_data = None torrent_data = None
if vars.torrent.filename: if vars.torrent.filename:
@ -114,17 +117,27 @@ class torrent_add:
#error_page(_("Choose an url or a torrent, not both.")) #error_page(_("Choose an url or a torrent, not both."))
print self.add_page(error = _("Choose an url or a torrent, not both.")) print self.add_page(error = _("Choose an url or a torrent, not both."))
return return
if vars.url: if vars.url:
proxy.add_torrent_url(vars.url, None,options) proxy.add_torrent_url(vars.url, None,options)
log.debug("add-url:options :%s" % options) log.debug("add-url:options :%s" % options)
utils.do_redirect() this.redirect(vars.choose_files)
elif torrent_name: elif torrent_name:
proxy.add_torrent_file_binary(vars.torrent.filename, torrent_data, options) proxy.add_torrent_file_binary(vars.torrent.filename, torrent_data, options)
log.debug("add-file:options :%s" % options) log.debug("add-file:options :%s" % options)
utils.do_redirect() self.redirect(vars.choose_files)
else: else:
print self.add_page(error = _("No data")) print self.add_page(error = _("No data"))
return return
def redirect(self,choose_files):
if choose_files: #redirect to file chooser
torrent_id = proxy.get_session_state()[-1] #HACK! no return-value for torrent_add_*
utils.seeother("/torrent/files/%s" % torrent_id)
else: #default
self.do_redirect()
def register(): def register():
component.get("PageManager").register_page("/torrent/add(.*)",torrent_add) component.get("PageManager").register_page("/torrent/add(.*)",torrent_add)

View file

@ -53,7 +53,7 @@ from webserver_common import REVNO, VERSION, TORRENT_KEYS, CONFIG_DEFAULTS
from deluge.ui.client import sclient, aclient from deluge.ui.client import sclient, aclient
webui_plugin_manager = component.get("WebPluginManager") webui_plugin_manager = component.get("WebPluginManager")
config = ConfigManager("webui.conf") config = ConfigManager("webui06.conf")
#async-proxy: map callback to a a dict-setter #async-proxy: map callback to a a dict-setter
def dict_cb(key,d): def dict_cb(key,d):
@ -92,7 +92,6 @@ def do_redirect():
ck = cookies() ck = cookies()
url_vars = {} url_vars = {}
#redirect to a non-default page.
if vars.redir: if vars.redir:
w_seeother(vars.redir) #redir variable contains base w_seeother(vars.redir) #redir variable contains base
return return