diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-10-03 20:53:22 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-10-03 20:53:22 +0200 |
commit | 405aa7a9953481a39a4f08f3677fbe9e1523f997 (patch) | |
tree | a62686503ac94118b2f282c34c00512dabff0339 /module/web | |
parent | shareonline expire date fix (diff) | |
download | pyload-405aa7a9953481a39a4f08f3677fbe9e1523f997.tar.xz |
time settings for accounts
Diffstat (limited to 'module/web')
-rw-r--r-- | module/web/pyload/views.py | 37 | ||||
-rw-r--r-- | module/web/templates/default/settings.html | 21 |
2 files changed, 41 insertions, 17 deletions
diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index 678884790..523fe60ea 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -24,6 +24,18 @@ from django.utils.translation import ugettext as _ def get_sort_key(item): return item[1]["order"] +def formatSize(size): + """formats size of bytes""" + size = int(size) + steps = 0 + sizes = ["B", "KB", "MB", "GB", "TB"] + + while size > 1000: + size /= 1024.0 + steps += 1 + + return "%.2f %s" % (size, sizes[steps]) + def check_server(function): def _dec(view_func): def _view(request, * args, ** kwargs): @@ -303,23 +315,25 @@ def config(request): elif sec == "Accounts": if ";" in okey: action, name = okey.split(";") - if action == "delete": settings.PYLOAD.remove_account(skey, name) - elif action == "password": - - for acc in accs[skey]: - if acc["login"] == name and value.strip(): - settings.PYLOAD.update_account(skey, name, value) - elif okey == "newacc" and value: + if okey == "newacc" and value: # add account pw = request.POST.get("Accounts|%s|newpw" % skey) settings.PYLOAD.update_account(skey, value, pw) - - + + for pluginname, accdata in accs.iteritems(): + for data in accdata: + newpw = request.POST.get("Accounts|%s|password;%s" % (pluginname, data["login"]), "").strip() + time = request.POST.get("Accounts|%s|time;%s" % (pluginname, data["login"]), "").strip() + + if newpw or (time and (not data["options"].has_key("time") or time != data["options"]["time"][0])): + settings.PYLOAD.update_account(pluginname, data["login"], newpw, {"time": [time]}) + + if errors: messages.append(_("Error occured when setting the following options:")) messages.append("") @@ -334,6 +348,8 @@ def config(request): data["trafficleft"] = _("unlimited") elif not data["trafficleft"]: data["trafficleft"] = _("not available") + else: + data["trafficleft"] = formatSize(data["trafficleft"]) if data["validuntil"] == -1: data["validuntil"] = _("unlimited") @@ -342,6 +358,9 @@ def config(request): else: t = localtime(data["validuntil"]) data["validuntil"] = strftime("%d-%m-%Y",t) + + if data["options"].has_key("time"): + data["time"] = data["options"]["time"][0] return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': {'Plugin':plugin, 'General':conf, 'Accounts': accs}, 'errors': messages}, [status_proc])) diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html index f23027210..09fe2e8b1 100644 --- a/module/web/templates/default/settings.html +++ b/module/web/templates/default/settings.html @@ -133,33 +133,38 @@ <tr> <td><label for="{{configname}}|{{plugin}}|password;{{account.login}}" style="color:#424242;">{{account.login}}:</label></td> <td> - <input id="{{plugin}}|delete;{{account.login}}" name="{{configname}}|{{plugin}}|password;{{account.login}}" type="password" value="{{account.password}}"/> + <input id="{{plugin}}|password;{{account.login}}" name="{{configname}}|{{plugin}}|password;{{account.login}}" type="password" value="{{account.password}}" size="14"/> </td> <td> {% trans "Status:" %} - <span style="font-weight: bold;"> {% if account.valid %} + <span style="font-weight: bold; color:#90ee90;"> {% trans "valid" %} {% else %} + <span style="font-weight: bold; color: #f08080;"> {% trans "not valid" %} {% endif %} </span> - |</td> + </td> <td> {% trans "Valid until:" %} <span style="font-weight: bold;"> {{ account.validuntil }} </span> - |</td> + </td> <td> {% trans "Traffic left:" %} <span style="font-weight: bold;"> {{ account.trafficleft }} </span> - |</td> + </td> + <td> + {% trans "Time:" %} + <input id="{{configname}}|{{plugin}}|time;{{account.login}}" name="{{configname}}|{{plugin}}|time;{{account.login}}" type="text" size="7" value="{{account.time}}"/> + </td> <td> {% trans "Delete? " %} - <input id="{{plugin}}|delete;{{account.login}}" name="{{configname}}|{{plugin}}|delete;{{account.login}}" type="checkbox" value="True"/> + <input id="{{configname}}|{{plugin}}|delete;{{account.login}}" name="{{configname}}|{{plugin}}|delete;{{account.login}}" type="checkbox" value="True"/> </td> </tr> @@ -170,14 +175,14 @@ <td><label for="{{configname}}|{{plugin}}|{{account.login}}" style="color:#424242;">{% trans "New account:" %}</label></td> <td> - <input id="{{plugin}}|newacc" name="{{configname}}|{{plugin}}|newacc" type="text"/> + <input id="{{plugin}}|newacc" name="{{configname}}|{{plugin}}|newacc" type="text" size="14"/> </td> </tr> <tr> <td><label for="{{configname}}|{{plugin}}|{{account.name}}" style="color:#424242;">{% trans "New password:" %}</label></td> <td> - <input id="{{config}}|{{plugin}}" name="{{configname}}|{{plugin}}|newpw" type="password"/> + <input id="{{configname}}|{{plugin}}" name="{{configname}}|{{plugin}}|newpw" type="password" size="14"/> </td> </tr> |