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()