diff options
Diffstat (limited to 'pyload/webui/app/json.py')
-rw-r--r-- | pyload/webui/app/json.py | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/pyload/webui/app/json.py b/pyload/webui/app/json.py index 700b310a0..12dce2484 100644 --- a/pyload/webui/app/json.py +++ b/pyload/webui/app/json.py @@ -22,7 +22,7 @@ def format_time(seconds): def get_sort_key(item): - return item["order"] + return item['order'] @route('/json/status') @@ -87,29 +87,29 @@ def packages(): def package(id): try: data = toDict(PYLOAD.getPackageData(id)) - data["links"] = [toDict(x) for x in data["links"]] - - for pyfile in data["links"]: - if pyfile["status"] == 0: - pyfile["icon"] = "status_finished.png" - elif pyfile["status"] in (2, 3): - pyfile["icon"] = "status_queue.png" - elif pyfile["status"] in (9, 1): - pyfile["icon"] = "status_offline.png" - elif pyfile["status"] == 5: - pyfile["icon"] = "status_waiting.png" - elif pyfile["status"] == 8: - pyfile["icon"] = "status_failed.png" - elif pyfile["status"] == 4: - pyfile["icon"] = "arrow_right.png" - elif pyfile["status"] in (11, 13): - pyfile["icon"] = "status_proc.png" + data['links'] = [toDict(x) for x in data['links']] + + for pyfile in data['links']: + if pyfile['status'] == 0: + pyfile['icon'] = "status_finished.png" + elif pyfile['status'] in (2, 3): + pyfile['icon'] = "status_queue.png" + elif pyfile['status'] in (9, 1): + pyfile['icon'] = "status_offline.png" + elif pyfile['status'] == 5: + pyfile['icon'] = "status_waiting.png" + elif pyfile['status'] == 8: + pyfile['icon'] = "status_failed.png" + elif pyfile['status'] == 4: + pyfile['icon'] = "arrow_right.png" + elif pyfile['status'] in (11, 13): + pyfile['icon'] = "status_proc.png" else: - pyfile["icon"] = "status_downloading.png" + pyfile['icon'] = "status_downloading.png" - tmp = data["links"] + tmp = data['links'] tmp.sort(key=get_sort_key) - data["links"] = tmp + data['links'] = tmp return data except Exception: @@ -217,7 +217,7 @@ def edit_package(): def set_captcha(): if request.environ.get('REQUEST_METHOD', "GET") == "POST": try: - PYLOAD.setCaptchaResult(request.forms["cap_id"], request.forms["cap_result"]) + PYLOAD.setCaptchaResult(request.forms['cap_id'], request.forms['cap_result']) except Exception: pass @@ -241,12 +241,13 @@ def load_config(category, section): conf = PYLOAD.getPluginConfigDict() for key, option in conf[section].iteritems(): - if key in ("desc", "outline"): continue + if key in ("desc", "outline"): + continue - if ";" in option["type"]: - option["list"] = option["type"].split(";") + if ";" in option['type']: + option['list'] = option['type'].split(";") - option["value"] = decode(option["value"]) + option['value'] = decode(option['value']) return render_to_response("settings_item.html", {"skey": section, "section": conf[section]}) @@ -268,9 +269,9 @@ def save_config(category): @route('/json/add_account', method='POST') @login_required("ACCOUNTS") def add_account(): - login = request.POST["account_login"] - password = request.POST["account_password"] - type = request.POST["account_type"] + login = request.POST['account_login'] + password = request.POST['account_password'] + type = request.POST['account_type'] PYLOAD.updateAccount(type, login, password) @@ -282,12 +283,14 @@ def update_accounts(): for name, value in request.POST.iteritems(): value = value.strip() - if not value: continue + if not value: + continue tmp, user = name.split(";") plugin, action = tmp.split("|") - if (plugin, user) in deleted: continue + if (plugin, user) in deleted: + continue if action == "password": PYLOAD.updateAccount(plugin, user, value) @@ -299,12 +302,13 @@ def update_accounts(): deleted.append((plugin,user)) PYLOAD.removeAccount(plugin, user) + @route('/json/change_password', method='POST') def change_password(): - user = request.POST["user_login"] - oldpw = request.POST["login_current_password"] - newpw = request.POST["login_new_password"] + user = request.POST['user_login'] + oldpw = request.POST['login_current_password'] + newpw = request.POST['login_new_password'] if not PYLOAD.changePassword(user, oldpw, newpw): print "Wrong password" |