From 0ffd3699fc696bca7d7bd1b35870aa66fb0598ef Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Wed, 28 Oct 2020 00:31:12 -0400 Subject: [PATCH] Add ability to manually fail instructor tasks in batches. When an InstructorTask is stuck in QUEUING (say if there was a problem with celery), the support team needs to manually intervene and mark the task as "FAILED" so that new tasks of that type can be created for that course. This is usually done one at a time, but sometimes a bug or outage might cause many tasks to fail at once, making recovery extremely cumbersome. This commit adds the ability to do this process in batches. --- lms/djangoapps/instructor_task/admin.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/instructor_task/admin.py b/lms/djangoapps/instructor_task/admin.py index 5ddcd85ea4..a7d63806e7 100644 --- a/lms/djangoapps/instructor_task/admin.py +++ b/lms/djangoapps/instructor_task/admin.py @@ -5,8 +5,6 @@ This will mostly involve searching by course_id or task_id and manually failing a task. """ - - from config_models.admin import ConfigurationModelAdmin from django.contrib import admin @@ -14,9 +12,21 @@ from .config.models import GradeReportSetting from .models import InstructorTask +def mark_tasks_as_failed(modeladmin, request, queryset): + queryset.update( + task_state='FAILURE', + task_output='{}', + task_key='dummy_task_key', + ) + +mark_tasks_as_failed.short_description = "Mark Tasks as Failed" + + class InstructorTaskAdmin(admin.ModelAdmin): + actions = [mark_tasks_as_failed] list_display = [ 'task_id', + 'task_state', 'task_type', 'course_id', 'username',