From 4375c344e93096c2324646f083d33a8dd8933292 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 7 Aug 2023 00:38:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B8=85=E7=90=86=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E7=AD=96=E7=95=A5=E5=B9=B6=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=94=9F=E6=88=90cron=E6=96=87=E6=9C=AC3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- safesite/services.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/safesite/services.py b/safesite/services.py index 0f0a2b92..986843dc 100644 --- a/safesite/services.py +++ b/safesite/services.py @@ -36,11 +36,15 @@ def correct_myschedule(): elif typeset == 'crontab': try: crontab = item.crontab - item.name = get_chinese_description(typeset, - {"minute": crontab.minute, "hour": crontab.hour, "day_of_month": crontab.day_of_month, - "month_of_year": crontab.month_of_year, "day_of_week": crontab.day_of_week}) - if item.name == '': - crontab.delete() + if crontab: + item.name = get_chinese_description(typeset, + {"minute": crontab.minute, "hour": crontab.hour, "day_of_month": crontab.day_of_month, + "month_of_year": crontab.month_of_year, "day_of_week": crontab.day_of_week}) + if item.name == '': + crontab.delete() + item.delete() + else: + PeriodicTask.objects.filter(gridtaskset_periodictask__myschedule=item).delete() item.delete() except ObjectDoesNotExist: GridTaskSet.objects.filter(myschedule=item).delete()