summaryrefslogtreecommitdiffstats
path: root/module/web/ajax/views.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-13 19:31:10 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-13 19:31:10 +0200
commite7ea8a420d01c927c17cf2db692cb0355aa87b95 (patch)
treefffd2c397b2fc300ca8086785d0898442e325531 /module/web/ajax/views.py
parentcouldn't connect to host fix (diff)
downloadpyload-e7ea8a420d01c927c17cf2db692cb0355aa87b95.tar.xz
new package ui for webif
Diffstat (limited to 'module/web/ajax/views.py')
-rw-r--r--module/web/ajax/views.py37
1 files changed, 33 insertions, 4 deletions
diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py
index 7d5c1884c..f020a8303 100644
--- a/module/web/ajax/views.py
+++ b/module/web/ajax/views.py
@@ -20,6 +20,8 @@ def format_time(seconds):
minutes, seconds = divmod(seconds, 60)
return "%.2i:%.2i:%.2i" % (hours, minutes, seconds)
+def get_sort_key(item):
+ return item["order"]
def permission(perm):
def _dec(view_func):
@@ -178,15 +180,42 @@ def packages(request):
def package(request, id):
try:
data = settings.PYLOAD.get_package_data(int(id))
- data['links'] = []
- for file in settings.PYLOAD.get_package_files(data['id']):
- data['links'].append(settings.PYLOAD.get_file_info(file))
+
+ for pyfile in data["links"].itervalues():
+ 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"] in (11,13):
+ pyfile["icon"] = "status_proc.png"
+ else:
+ pyfile["icon"] = "status_downloading.png"
+
+ tmp = data["links"].values()
+ tmp.sort(key=get_sort_key)
+ data["links"] = tmp
return JsonResponse(data)
except:
+ print_exc()
+ return HttpResponseServerError()
+
+@permission('pyload.can_add_dl')
+def package_order(request, ids):
+ try:
+ pid, pos = ids.split("|")
+ settings.PYLOAD.order_package(int(pid), int(pos))
+ return JsonResponse("sucess")
+ except:
+ print_exc()
return HttpResponseServerError()
-
@permission('pyload.can_see_dl')
def link(request, id):
try: