diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-06 19:04:08 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-06 19:04:08 +0200 |
commit | 5d8963a40c03c9e6f613883f3a0d743892464f01 (patch) | |
tree | f5320f2ea78b33bad9bea6c0b145acfc57bd54f5 /module/web/pyload | |
parent | fixes (diff) | |
download | pyload-5d8963a40c03c9e6f613883f3a0d743892464f01.tar.xz |
settings page working
Diffstat (limited to 'module/web/pyload')
-rw-r--r-- | module/web/pyload/views.py | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index c47004a85..21e583348 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -216,42 +216,55 @@ def collector(request): def config(request): conf = settings.PYLOAD.get_config() plugin = settings.PYLOAD.get_plugin_config() + messages = [] + for section in chain(conf.itervalues(), plugin.itervalues()): + for key, option in section.iteritems(): + if key == "desc": continue + + if ";" in option["type"]: + option["list"] = option["type"].split(";") + if request.META.get('REQUEST_METHOD', "GET") == "POST": errors = [] for key, value in request.POST.iteritems(): if not "|" in key: continue - skey, okey = key.split("|")[:] - if conf.has_key(skey): - if conf[skey].has_key(okey): - try: - if str(conf[skey][okey]['value']) != value: - settings.PYLOAD.set_conf_val(skey, okey, value) - except Exception, e: - errors.append("%s | %s : %s" % (skey, okey, e)) + sec, skey, okey = key.split("|")[:] + + if sec == "General": + + if conf.has_key(skey): + if conf[skey].has_key(okey): + try: + if str(conf[skey][okey]['value']) != value: + settings.PYLOAD.set_conf_val(skey, okey, value) + except Exception, e: + errors.append("%s | %s : %s" % (skey, okey, e)) + else: + continue + else: + continue + + elif sec == "Plugin": + if plugin.has_key(skey): + if plugin[skey].has_key(okey): + try: + if str(plugin[skey][okey]['value']) != value: + settings.PYLOAD.set_conf_val(skey, okey, value, "plugin") + except Exception, e: + errors.append("%s | %s : %s" % (skey, okey, e)) + else: + continue else: continue - else: - continue - messages = [] - if errors: messages.append(_("Error occured when setting the following options:")) messages.append("") messages += errors else: messages.append(_("All options were set correctly.")) - - return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': {}, 'errors': messages}, [status_proc])) - - for section in chain(conf.itervalues(), plugin.itervalues()): - for key, option in section.iteritems(): - if key == "desc": continue - - if ";" in option["type"]: - option["list"] = option["type"].split(";") - return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': {'Plugin':plugin, 'General':conf}, 'messages': []}, [status_proc])) + return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': {'Plugin':plugin, 'General':conf}, 'errors': messages}, [status_proc])) |