diff --git a/deluge/ui/webui/webui_plugin/config.py b/deluge/ui/webui/webui_plugin/config.py index cb02efb62..4bc80e171 100644 --- a/deluge/ui/webui/webui_plugin/config.py +++ b/deluge/ui/webui/webui_plugin/config.py @@ -81,6 +81,20 @@ class WebCfgForm(Form): def post_save(self): pass +class CookieCfgForm(Form): + "config base for webui" + def initial_data(self): + return ws.config + + def save(self, data): + ws.config.update(data) + ws.save_config() + self.post_save() + + def post_save(self): + pass + + class CfgForm(Form): "config base for deluge-cfg" @@ -90,8 +104,7 @@ class CfgForm(Form): ws.proxy.set_config(dict(data)) -#convenience Fields. - +#convenience Input Fields. class _IntInput(forms.TextInput): """ because deluge-floats are edited as ints. @@ -99,6 +112,8 @@ class _IntInput(forms.TextInput): def render(self, name, value, attrs=None): try: value = int(float(value)) + if value == -1: + value = _("Unlimited") except: pass return forms.TextInput.render(self, name, value, attrs) @@ -125,10 +140,23 @@ class DelugeInt(forms.IntegerField): forms.IntegerField.__init__(self, label=label, min_value=-1, max_value=sys.maxint, widget=_IntInput, **kwargs) + def clean(self, value): + if str(value).lower() == _('Unlimited').lower(): + value = -1 + return int(forms.IntegerField.clean(self, value)) + class DelugeFloat(DelugeInt): def clean(self, value): return int(DelugeInt.clean(self, value)) +class MultipleChoice(forms.MultipleChoiceField): + #temp/test + def __init__(self, label, choices, **kwargs): + forms.MultipleChoiceField.__init__(self, label=label, choices=choices, + widget=forms.CheckboxSelectMultiple, required=False) + + +#/fields class config_page: """ @@ -159,6 +187,11 @@ class config_page: vars = web.input() for field in fields: form_data[field] = vars.get(field) + #DIRTY HACK: (for multiple-select) + if isinstance(form_class.base_fields[field], + forms.MultipleChoiceField): + form_data[field] = web.input(**{field:[]})[field] + #/DIRTY HACK form = form_class(form_data) if form.is_valid(): @@ -170,7 +203,7 @@ class config_page: ws.log.debug(e.message) return self.render(form , name, error = e.message) else: - return self.render(form , name, error= _('Please correct the errors above and try again')) + return self.render(form , name, error= _('Correct the errors above and try again')) def render(self, f , name , message = '' , error=''): return render.config(groups, blocks, f, name , message , error) diff --git a/deluge/ui/webui/webui_plugin/config_tabs_deluge.py b/deluge/ui/webui/webui_plugin/config_tabs_deluge.py index 532d90f63..159a72fbb 100644 --- a/deluge/ui/webui/webui_plugin/config_tabs_deluge.py +++ b/deluge/ui/webui/webui_plugin/config_tabs_deluge.py @@ -34,7 +34,7 @@ import lib.newforms as forms import config import utils - +from webserver_common import ws class ServerFolderField(forms.CharField): @@ -54,10 +54,12 @@ class NetworkPorts(config.CfgForm ): return data def save(self,data): - data['listen_ports'] = [data['_port_from'] , data['_port_to'] ] if (data['_port_to'] < data['_port_from']): raise ValidationError('"Port from" must be greater than "Port to"') - config.CfgForm.save() + data['listen_ports'] = [data['_port_from'] , data['_port_to'] ] + del(data['_port_from']) + del(data['_port_to']) + config.CfgForm.save(self, data) config.register_block('network','ports', NetworkPorts) @@ -121,4 +123,10 @@ class Daemon(config.CfgForm): config.register_block('deluge','daemon', Daemon) +class Plugins(config.CfgForm): + title = _("Enabled Plugins") + _choices = [(p,p) for p in ws.proxy.get_available_plugins()] + enabled_plugins = config.MultipleChoice(_(""), _choices) + +config.register_block('deluge','plugins', Plugins) diff --git a/deluge/ui/webui/webui_plugin/templates/advanced/static/advanced.css b/deluge/ui/webui/webui_plugin/templates/advanced/static/advanced.css index 5fb590ba6..015a9e57c 100644 --- a/deluge/ui/webui/webui_plugin/templates/advanced/static/advanced.css +++ b/deluge/ui/webui/webui_plugin/templates/advanced/static/advanced.css @@ -289,6 +289,9 @@ form { /*all forms!*/ #config_panel { height:60%; + float:left; + width:500px; + margin-left:20px; } #config_panel th { font-size: 12px; diff --git a/deluge/ui/webui/webui_plugin/tests/test_all.py b/deluge/ui/webui/webui_plugin/tests/test_all.py index d8298c6ba..68b073e79 100644 --- a/deluge/ui/webui/webui_plugin/tests/test_all.py +++ b/deluge/ui/webui/webui_plugin/tests/test_all.py @@ -222,9 +222,10 @@ class TestIntegration(TestWebUiBase): self.assertEqual(len(self.torrent_ids), 3) else: - #test correctness of existing-list - for url in self.urls: - self.assert_500('/torrent/add',{'url':url,'torrent':None}) + if ws.env <> '0.6': + #test correctness of existing-list + for url in self.urls: + self.assert_500('/torrent/add',{'url':url,'torrent':None}) def testPauseResume(self): #pause all @@ -353,13 +354,24 @@ class TestIntegration(TestWebUiBase): ,'/torrent/info/' + torrent_id, post = 1) """ + def testConfig(self): + #0.6 only + if ws.env <> '0.6': + return + # + import WebUi.config_tabs_webui #auto registers + import WebUi.config_tabs_deluge #auto registers + import WebUi.config as config + + for name in config.blocks: + self.assert_exists("/config/%s" % name) + + #todo->post page with current values. + + + -# -if True: - cfg = ws.proxy.get_config() - for key in sorted(cfg.keys()): - print key,cfg[key]