webui:add some values to config pages

This commit is contained in:
Martijn Voncken 2008-04-03 19:06:17 +00:00
parent c585e75b36
commit 380966f3f1
4 changed files with 25 additions and 15 deletions

View File

@ -30,7 +30,7 @@
# this exception statement from your version. If you delete this exception # this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here. # statement from all source files in the program, then also delete it here.
from deluge.ui.client import sclient as proxy from deluge.ui.client import sclient
from deluge.log import LOG as log from deluge.log import LOG as log
import utils import utils
@ -63,6 +63,14 @@ class NetworkPorts(config_forms.CfgForm ):
if (data['_port_to'] < data['_port_from']): if (data['_port_to'] < data['_port_from']):
raise forms.ValidationError('"Port from" must be greater than "Port to"') raise forms.ValidationError('"Port from" must be greater than "Port to"')
def extra_html(self):
return """
<ul>
<li>Active port:%(active_port)s </li>
<li><a href="http://deluge-torrent.org/test-port.php?port=%(active_port)s">Test active port</li>
</ul>
""" % {'active_port':sclient.get_listen_port()}
config_page.register('network','ports', NetworkPorts) config_page.register('network','ports', NetworkPorts)
class NetworkExtra(config_forms.CfgForm ): class NetworkExtra(config_forms.CfgForm ):
@ -103,6 +111,8 @@ class BandwithTorrent(config_forms.CfgForm):
title = _("Per Torrent") title = _("Per Torrent")
info = _("-1 = Unlimited") info = _("-1 = Unlimited")
max_connections_per_torrent = forms.DelugeInt(_("Maximum Connections")) max_connections_per_torrent = forms.DelugeInt(_("Maximum Connections"))
max_download_speed_per_torrent = forms.DelugeFloat(_("Maximum Download Speed (Kib/s)"))
max_upload_speed_per_torrent = forms.DelugeFloat(_("Maximum Upload Speed (Kib/s)"))
max_upload_slots_per_torrent = forms.DelugeInt(_("Maximum Upload Slots")) max_upload_slots_per_torrent = forms.DelugeInt(_("Maximum Upload Slots"))
config_page.register('bandwidth','torrent', BandwithTorrent) config_page.register('bandwidth','torrent', BandwithTorrent)
@ -113,8 +123,8 @@ class Download(config_forms.CfgForm):
torrentfiles_location = forms.ServerFolder(_("Save .torrent files to")) torrentfiles_location = forms.ServerFolder(_("Save .torrent files to"))
autoadd_location = forms.ServerFolder(_("Auto Add folder"), required=False) autoadd_location = forms.ServerFolder(_("Auto Add folder"), required=False)
compact_allocation = forms.CheckBox(_('Use Compact Allocation')) compact_allocation = forms.CheckBox(_('Use Compact Allocation'))
prioritize_first_last_pieces = forms.CheckBox( prioritize_first_last_pieces = forms.CheckBox(_('Prioritize first and last pieces'))
_('Prioritize first and last pieces')) default_private = forms.CheckBox(_('Set private flag by default'))
config_page.register('deluge','download', Download) config_page.register('deluge','download', Download)
@ -130,11 +140,11 @@ class Plugins(forms.Form):
title = _("Enabled Plugins") title = _("Enabled Plugins")
enabled_plugins = forms.LazyMultipleChoice( enabled_plugins = forms.LazyMultipleChoice(
choices_getter = lambda: [(p,p) for p in proxy.get_available_plugins()] choices_getter = lambda: [(p,p) for p in sclient.get_available_plugins()]
) )
def initial_data(self): def initial_data(self):
return {'enabled_plugins':proxy.get_enabled_plugins()} return {'enabled_plugins':sclient.get_enabled_plugins()}
def save(self, value): def save(self, value):
raise forms.ValidationError("SAVE:TODO") raise forms.ValidationError("SAVE:TODO")

View File

@ -74,6 +74,7 @@ class FilteredForm(newforms.Form):
class Form(FilteredForm): class Form(FilteredForm):
info = "" info = ""
title = "No Title" title = "No Title"
def __init__(self,data = None): def __init__(self,data = None):
if data == None: if data == None:
data = self.initial_data() data = self.initial_data()
@ -100,6 +101,10 @@ class Form(FilteredForm):
def validate(self, data): def validate(self, data):
pass pass
def extra_html(self):
return ''
#convenience Input Fields. #convenience Input Fields.
class CheckBox(newforms.BooleanField): class CheckBox(newforms.BooleanField):
"Non Required BooleanField,why the f is it required by default?" "Non Required BooleanField,why the f is it required by default?"

View File

@ -404,13 +404,3 @@ class pixmaps:
web.header("Cache-Control" , "public, must-revalidate, max-age=86400") web.header("Cache-Control" , "public, must-revalidate, max-age=86400")
print content print content
route("/pixmaps/(.*)", pixmaps) route("/pixmaps/(.*)", pixmaps)
"""
#debug:
class catch_all:
@deco.deluge_page_noauth
def GET(self, name):
log.debug("xname=" + name)
print "name=" + name
route("(.*)", catch_all)
"""

View File

@ -29,11 +29,16 @@ $:form.as_table()
</tr> </tr>
</table> </table>
$if message: $if message:
<div id="message">$message</div> <div id="message">$message</div>
$if error: $if error:
<div class="error">$error</div> <div class="error">$error</div>
<div>
$:form.extra_html()
</div>
</form> </form>