From 69eb9e649428b930448f496a7a39a9f12bb278bb Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 11 Aug 2010 12:01:55 +0200 Subject: correct order in webif --- module/web/ajax/views.py | 2 +- module/web/pyload/views.py | 28 ++++++++++++++++++++++++++-- module/web/templates/default/collector.html | 4 ++-- module/web/templates/default/queue.html | 4 ++-- 4 files changed, 31 insertions(+), 7 deletions(-) (limited to 'module/web') diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py index 0ad5e5156..82e478af3 100644 --- a/module/web/ajax/views.py +++ b/module/web/ajax/views.py @@ -232,7 +232,7 @@ def abort_link(request, id): @permission('pyload.can_add_dl') def push_to_queue(request, id): try: - settings.PYLOAD.push_package_2_queue(int(id)) + settings.PYLOAD.push_package_to_queue(int(id)) return JsonResponse("sucess") except: return HttpResponseServerError() diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index 2d210b6d7..8cdef094b 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -10,6 +10,7 @@ from os.path import join from urllib import unquote from itertools import chain from datetime import datetime +from operator import itemgetter from django.conf import settings from django.contrib.auth.decorators import login_required @@ -19,6 +20,10 @@ from django.shortcuts import render_to_response from django.template import RequestContext from django.utils.translation import ugettext as _ + +def get_sort_key(item): + return item[1]["order"] + def check_server(function): def _dec(view_func): def _view(request, * args, ** kwargs): @@ -99,8 +104,18 @@ def queue(request): pyfile["icon"] = "status_proc.png" else: pyfile["icon"] = "status_downloading.png" + + + #@TODO: replace lambdas + data = zip(queue.keys(), queue.values()) + data.sort(key=get_sort_key) + + for id, value in data: + tmp = zip(value["links"].keys(), value["links"].values()) + tmp.sort(key=get_sort_key) + value["links"] = tmp - return render_to_response(join(settings.TEMPLATE, 'queue.html'), RequestContext(request, {'content': queue}, [status_proc])) + return render_to_response(join(settings.TEMPLATE, 'queue.html'), RequestContext(request, {'content': data}, [status_proc])) @login_required @@ -267,8 +282,17 @@ def collector(request): pyfile["icon"] = "status_proc.png" else: pyfile["icon"] = "status_downloading.png" + + #@TODO: replace lambdas + data = zip(queue.keys(), queue.values()) + data.sort(key=get_sort_key) - return render_to_response(join(settings.TEMPLATE, 'collector.html'), RequestContext(request, {'content': queue}, [status_proc])) + for id, value in data: + tmp = zip(value["links"].keys(), value["links"].values()) + tmp.sort(key=get_sort_key) + value["links"] = tmp + + return render_to_response(join(settings.TEMPLATE, 'collector.html'), RequestContext(request, {'content': data}, [status_proc])) @login_required diff --git a/module/web/templates/default/collector.html b/module/web/templates/default/collector.html index 266038af1..613fb824b 100644 --- a/module/web/templates/default/collector.html +++ b/module/web/templates/default/collector.html @@ -106,7 +106,7 @@ document.addEvent("domready", function(){ {% endblock %} {% block content %} -{% for id,package in content.iteritems %} +{% for id,package in content %}
{{ package.name }} @@ -118,7 +118,7 @@ document.addEvent("domready", function(){