mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 15:38:43 +00:00
torrents_command
This commit is contained in:
parent
a9238995ce
commit
f1d13d0bca
1 changed files with 18 additions and 63 deletions
|
@ -129,11 +129,11 @@ class index:
|
||||||
def GET(self, name):
|
def GET(self, name):
|
||||||
vars = web.input(sort=None, order=None)
|
vars = web.input(sort=None, order=None)
|
||||||
|
|
||||||
|
#organize-filters
|
||||||
organize_filters = {}
|
organize_filters = {}
|
||||||
if 'Organize' in proxy.get_enabled_plugins():
|
if 'Organize' in proxy.get_enabled_plugins():
|
||||||
filter_dict = {}
|
filter_dict = {}
|
||||||
|
|
||||||
#organize-filters
|
|
||||||
for filter_name in ["state","tracker","keyword"]:
|
for filter_name in ["state","tracker","keyword"]:
|
||||||
value = getattr(web.input(**{filter_name:None}), filter_name)
|
value = getattr(web.input(**{filter_name:None}), filter_name)
|
||||||
if value and value <> "All":
|
if value and value <> "All":
|
||||||
|
@ -142,7 +142,6 @@ class index:
|
||||||
else:
|
else:
|
||||||
setcookie(filter_name, "")
|
setcookie(filter_name, "")
|
||||||
|
|
||||||
log.debug(filter_dict)
|
|
||||||
torrent_ids = proxy.organize_get_session_state(filter_dict)
|
torrent_ids = proxy.organize_get_session_state(filter_dict)
|
||||||
organize_filters = Storage(proxy.organize_all_filter_items())
|
organize_filters = Storage(proxy.organize_all_filter_items())
|
||||||
|
|
||||||
|
@ -165,6 +164,23 @@ class index:
|
||||||
setcookie("sort", vars.sort)
|
setcookie("sort", vars.sort)
|
||||||
return render.index(torrent_list, organize_filters)
|
return render.index(torrent_list, organize_filters)
|
||||||
|
|
||||||
|
#simple proxy's to deluge.ui.client
|
||||||
|
#execute a command on torrent(s) and redirect to index page.
|
||||||
|
def torrents_command(command):
|
||||||
|
class torrents_command_inner:
|
||||||
|
@deco.check_session
|
||||||
|
@deco.torrent_ids
|
||||||
|
def POST(self, torrent_ids):
|
||||||
|
getattr(proxy, command)(torrent_ids)
|
||||||
|
do_redirect()
|
||||||
|
return torrents_command_inner
|
||||||
|
|
||||||
|
torrent_start = torrents_command("resume_torrent")
|
||||||
|
torrent_stop = torrents_command("pause_torrent")
|
||||||
|
torrent_reannounce = torrents_command("force_reannounce")
|
||||||
|
torrent_recheck = torrents_command("force_recheck")
|
||||||
|
torrent_queue_down = torrents_command("queue_down")
|
||||||
|
torrent_queue_up = torrents_command("queue_up")
|
||||||
|
|
||||||
class torrent_info:
|
class torrent_info:
|
||||||
@deco.deluge_page
|
@deco.deluge_page
|
||||||
|
@ -185,67 +201,6 @@ class torrent_info_inner:
|
||||||
setcookie("torrent_info_tab", active_tab)
|
setcookie("torrent_info_tab", active_tab)
|
||||||
return render.torrent_info_inner(torrent, active_tab)
|
return render.torrent_info_inner(torrent, active_tab)
|
||||||
|
|
||||||
#next 6 classes: a pattern is emerging here.
|
|
||||||
#todo: DRY (in less lines of code)
|
|
||||||
#deco.deluge_command, or a subclass?
|
|
||||||
"""
|
|
||||||
def torrents_command(command):
|
|
||||||
class torrents_command_inner:
|
|
||||||
@deco.check_session
|
|
||||||
@deco.torrent_ids
|
|
||||||
def POST(self, torrent_ids):
|
|
||||||
proxy.getattr(command).(torrent_ids)
|
|
||||||
do_redirect()
|
|
||||||
|
|
||||||
torrent_start = torrents_command("resume_torrent")
|
|
||||||
torrent_stop = torrents_command("pause_torrent")
|
|
||||||
torrent_reannounce = torrents_command("force_reannounce")
|
|
||||||
torrent_recheck = torrents_command("force_recheck")
|
|
||||||
torrent_queue_down = torrents_command("queue_down")
|
|
||||||
torrent_queue_up = torrents_command("queue_up")
|
|
||||||
"""
|
|
||||||
class torrent_start:
|
|
||||||
@deco.check_session
|
|
||||||
@deco.torrent_ids
|
|
||||||
def POST(self, torrent_ids):
|
|
||||||
proxy.resume_torrent(torrent_ids)
|
|
||||||
do_redirect()
|
|
||||||
|
|
||||||
class torrent_stop:
|
|
||||||
@deco.check_session
|
|
||||||
@deco.torrent_ids
|
|
||||||
def POST(self, torrent_ids):
|
|
||||||
proxy.pause_torrent(torrent_ids)
|
|
||||||
do_redirect()
|
|
||||||
|
|
||||||
class torrent_reannounce:
|
|
||||||
@deco.check_session
|
|
||||||
@deco.torrent_ids
|
|
||||||
def POST(self, torrent_ids):
|
|
||||||
proxy.force_reannounce(torrent_ids)
|
|
||||||
do_redirect()
|
|
||||||
|
|
||||||
class torrent_recheck:
|
|
||||||
@deco.check_session
|
|
||||||
@deco.torrent_ids
|
|
||||||
def POST(self, torrent_ids):
|
|
||||||
proxy.force_recheck(torrent_ids)
|
|
||||||
do_redirect()
|
|
||||||
|
|
||||||
class torrent_queue_up:
|
|
||||||
@deco.check_session
|
|
||||||
@deco.torrent_ids
|
|
||||||
def POST(self, torrent_ids):
|
|
||||||
proxy.queue_up(torrent_ids)
|
|
||||||
do_redirect()
|
|
||||||
|
|
||||||
class torrent_queue_down:
|
|
||||||
@deco.check_session
|
|
||||||
@deco.torrent_ids
|
|
||||||
def POST(self, torrent_ids):
|
|
||||||
proxy.queue_down(torrent_ids)
|
|
||||||
do_redirect()
|
|
||||||
|
|
||||||
class torrent_delete:
|
class torrent_delete:
|
||||||
@deco.deluge_page
|
@deco.deluge_page
|
||||||
@deco.torrent_list
|
@deco.torrent_list
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue