From 8502c738d276fc9603ddd449945e27430eb183cc Mon Sep 17 00:00:00 2001 From: ngfchl Date: Mon, 12 Dec 2022 10:09:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E7=A7=8D=E5=AD=90=E6=97=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pt_site/admin.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pt_site/admin.py b/pt_site/admin.py index 8a95c37..6be299c 100644 --- a/pt_site/admin.py +++ b/pt_site/admin.py @@ -914,7 +914,7 @@ class TorrentInfoAdmin(AjaxAdmin): # instead of ModelAdmin print(post) downloader = Downloader.objects.filter(id=post.get('downloader')).first() print(downloader) - + save_path = post.get('save_path') # 这里获取到数据后,可以做些业务处理 # post中的_action 是方法名 # post中 _selected 是选中的数据,逗号分割 @@ -969,7 +969,7 @@ class TorrentInfoAdmin(AjaxAdmin): # instead of ModelAdmin # res = qb_client.torrents_add(torrent.magnet_url) res = tr_client.add_torrent( torrent=torrent_info.magnet_url, - download_dir=torrent_info.save_path, + download_dir=save_path, cookies=torrent_info.site.mysite.cookie ) print(res) @@ -1037,7 +1037,7 @@ class TorrentInfoAdmin(AjaxAdmin): # instead of ModelAdmin urls=torrent_info.magnet_url, cookie=torrent_info.site.mysite.cookie, # 保存路径 - save_path=torrent_info.save_path, + download_path=save_path, # 自动管理种子 use_auto_torrent_management=True, # 任务标签,用于和种子信息关联 @@ -1112,7 +1112,19 @@ class TorrentInfoAdmin(AjaxAdmin): # instead of ModelAdmin 'size': 'small', # value字段可以指定默认值 'value': '', + 'require': True, # 列表推导式来获取下载器 'options': get_downloader() - }] + }, { + # 这里的type 对应el-input的原生input属性,默认为input + 'type': 'input', + # key 对应post参数中的key + 'key': 'save_path', + # 显示的文本 + 'label': '保存路径', + 'value': '/downloads', + 'width': '200px', + # 为空校验,默认为False + 'require': True + }, ] }