Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hub: add menu item for failed tasks. #231

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kobo/admin/templates/hub/menu.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ menu = (
MenuItem("Tasks", "task/index", menu=(
MenuItem("All", "task/index"),
MenuItem("Running", "task/running"),
MenuItem("Failed", "task/failed"),
MenuItem("Finished", "task/finished"),
)),
MenuItem("Info", "worker/list", menu=(
Expand Down
1 change: 1 addition & 0 deletions kobo/hub/urls/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
url(r"^$", TaskListView.as_view(), name="task/index"),
url(r"^(?P<pk>\d+)/$", TaskDetail.as_view(), name="task/detail"),
url(r"^running/$", TaskListView.as_view(state=(TASK_STATES["FREE"], TASK_STATES["ASSIGNED"], TASK_STATES["OPEN"]), title=_("Running tasks"), order_by=["id"]), name="task/running"),
url(r"^failed/$", TaskListView.as_view(state=(TASK_STATES["FAILED"],), title=_("Failed tasks"), order_by=["-dt_created", "id"]), name="task/failed"),
url(r"^finished/$", TaskListView.as_view(state=(TASK_STATES["CLOSED"], TASK_STATES["INTERRUPTED"], TASK_STATES["CANCELED"], TASK_STATES["FAILED"]), title=_("Finished tasks"), order_by=["-dt_created", "id"]), name="task/finished"),
url(r"^(?P<id>\d+)/log/(?P<log_name>.+)$", kobo.hub.views.task_log, name="task/log"),
url(r"^(?P<id>\d+)/log-json/(?P<log_name>.+)$", kobo.hub.views.task_log_json, name="task/log-json"),
Expand Down
9 changes: 9 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ def test_list_running(self):
self.assertTrue(self.task3.method not in str(response.content))
self.assertTrue(self.task4.method not in str(response.content))

def test_list_failed(self):
response = self.client.get('/task/failed/')
self.assertEqual(response.status_code, 200)
# make sure only failed tasks are listed
self.assertTrue(self.task1.get_state_display() not in str(response.content))
self.assertTrue(self.task2.get_state_display() not in str(response.content))
self.assertTrue(self.task3.get_state_display() not in str(response.content))
self.assertTrue(self.task4.get_state_display() in str(response.content))

def test_list_finished(self):
response = self.client.get('/task/finished/')
self.assertEqual(response.status_code, 200)
Expand Down
Loading