summaryrefslogtreecommitdiffstats
path: root/pyload/webui
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-12 19:23:51 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-12 19:23:51 +0200
commitf0afbee15380bf5fc242fb3dd5439a9ea9c67d5c (patch)
tree7e82c022c157a39232fc590ab2ffa69787f5d260 /pyload/webui
parentCleanup (diff)
parentimport fixes + code-cleanup (diff)
downloadpyload-f0afbee15380bf5fc242fb3dd5439a9ea9c67d5c.tar.xz
Merge branch 'pr/n3_ardi69' into 0.4.10
Conflicts: pyload/plugin/Plugin.py pyload/webui/app/pyloadweb.py
Diffstat (limited to 'pyload/webui')
-rw-r--r--pyload/webui/app/pyloadweb.py48
1 files changed, 30 insertions, 18 deletions
diff --git a/pyload/webui/app/pyloadweb.py b/pyload/webui/app/pyloadweb.py
index 85f3f8ca1..fd7caf46f 100644
--- a/pyload/webui/app/pyloadweb.py
+++ b/pyload/webui/app/pyloadweb.py
@@ -25,6 +25,7 @@ from pyload.utils import formatSize, fs_join, fs_encode, fs_decode
# Helper
+
def pre_processor():
s = request.environ.get('beaker.session')
user = parse_userdata(s)
@@ -45,13 +46,12 @@ def pre_processor():
if info["plugins"] == "True":
plugins = True
-
- return {"user" : user,
- 'status' : status,
+ return {"user": user,
+ 'status': status,
'captcha': captcha,
- 'perms' : perms,
- 'url' : request.url,
- 'update' : update,
+ 'perms': perms,
+ 'url': request.url,
+ 'update': update,
'plugins': plugins}
@@ -59,7 +59,7 @@ def base(messages):
return render_to_response('base.html', {'messages': messages}, [pre_processor])
-## Views
+# Views
@error(403)
def error403(code):
return "The parameter you passed has the wrong format"
@@ -239,6 +239,9 @@ def get_download(path):
return static_file(fs_encode(path), fs_encode(root))
+__TYPES = ("account", "addon", "container", "crypter", "extractor", "hook", "hoster", "internal", "ocr")
+__TYPE_REPLACES = (('_account', ' (Account)'), ('_addon', ' (Addon)'), ('_container', ''), ('_crypter', ' (Crypter)'), ('_extractor', ''), ('_hook', ' (Hook)'), ('_hoster', ' (Hoster)'))
+
@route('/settings')
@login_required('SETTINGS')
@@ -253,7 +256,17 @@ def config():
conf_menu.append((entry, conf[entry].description))
for entry in sorted(plugin.keys()):
- plugin_menu.append((entry, plugin[entry].description))
+ desc = plugin[entry].description
+ name, none, type = desc.partition("_")
+ if type in __TYPES:
+ if len([a for a, b in plugin.iteritems() if b.description.startswith(name + "_")]) > 1:
+ for search, repl in __TYPE_REPLACES:
+ if desc.endswith(search):
+ desc = desc.replace(search, repl)
+ break
+ else:
+ desc = name
+ plugin_menu.append((entry, desc))
accs = PYLOAD.getAccounts(False)
@@ -267,7 +280,7 @@ def config():
if data.validuntil == -1:
data.validuntil = _("unlimited")
- elif not data.validuntil :
+ elif not data.validuntil:
data.validuntil = _("not available")
else:
t = time.localtime(data.validuntil)
@@ -284,8 +297,8 @@ def config():
data.options["limitdl"] = "0"
return render_to_response('settings.html',
- {'conf': {'plugin': plugin_menu, 'general': conf_menu, 'accs': accs}, 'types': PYLOAD.getAccountTypes()},
- [pre_processor])
+ {'conf': {'plugin': plugin_menu, 'general': conf_menu, 'accs': accs}, 'types': PYLOAD.getAccountTypes()},
+ [pre_processor])
@route('/filechooser')
@@ -374,8 +387,8 @@ def path(file="", path=""):
files = sorted(files, key=itemgetter('type', 'sort'))
return render_to_response('pathchooser.html',
- {'cwd': cwd, 'files': files, 'parentdir': parentdir, 'type': type, 'oldfile': oldfile,
- 'absolute': abs}, [])
+ {'cwd': cwd, 'files': files, 'parentdir': parentdir, 'type': type, 'oldfile': oldfile,
+ 'absolute': abs}, [])
@route('/logs')
@@ -425,7 +438,7 @@ def logs(item=-1):
if item < 1 or type(item) is not int:
item = 1 if len(log) - perpage + 1 < 1 else len(log) - perpage + 1
- if type(fro) is datetime: # we will search for datetime
+ if type(fro) is datetime: # we will search for datetime
item = -1
data = []
@@ -445,16 +458,16 @@ def logs(item=-1):
level = '?'
message = l
if item == -1 and dtime is not None and fro <= dtime:
- item = counter #found our datetime
+ item = counter # found our datetime
if item >= 0:
data.append({'line': counter, 'date': date + " " + time, 'level': level, 'message': message})
perpagecheck += 1
- if fro is None and dtime is not None: #if fro not set set it to first showed line
+ if fro is None and dtime is not None: # if fro not set set it to first showed line
fro = dtime
if perpagecheck >= perpage > 0:
break
- if fro is None: #still not set, empty log?
+ if fro is None: # still not set, empty log?
fro = datetime.now()
if reversed:
data.reverse()
@@ -478,7 +491,6 @@ def admin():
get_permission(data["perms"], data["permission"])
data["perms"]["admin"] = True if data["role"] is 0 else False
-
s = request.environ.get('beaker.session')
if request.environ.get('REQUEST_METHOD', "GET") == "POST":
for name in user: