mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-20 10:54:58 +00:00
Removes the acknowledge/dismiss all stuff
This commit is contained in:
@@ -129,21 +129,6 @@ describe('TasksService', () => {
|
||||
expect(tasksService.startedFileTasks).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('calls acknowledge_all api endpoint on dismissAll and reloads', () => {
|
||||
tasksService.dismissAllTasks().subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}tasks/acknowledge_all/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
req.flush({})
|
||||
// reload is then called
|
||||
httpTestingController
|
||||
.expectOne(
|
||||
`${environment.apiBaseUrl}tasks/?task_type=consume_file&acknowledged=false`
|
||||
)
|
||||
.flush([])
|
||||
})
|
||||
|
||||
it('supports running tasks', () => {
|
||||
tasksService.run(PaperlessTaskType.SanityCheck).subscribe((res) => {
|
||||
expect(res).toEqual({
|
||||
|
||||
@@ -85,16 +85,6 @@ export class TasksService {
|
||||
)
|
||||
}
|
||||
|
||||
public dismissAllTasks(): Observable<any> {
|
||||
return this.http.post(`${this.baseUrl}tasks/acknowledge_all/`, {}).pipe(
|
||||
first(),
|
||||
takeUntil(this.unsubscribeNotifer),
|
||||
tap(() => {
|
||||
this.reload()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
public cancelPending(): void {
|
||||
this.unsubscribeNotifer.next(true)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Covers:
|
||||
- v10 serializer (new field names)
|
||||
- v9 serializer (backwards-compatible field names)
|
||||
- Filtering, ordering, acknowledge, acknowledge_all, summary, active, run
|
||||
- Filtering, ordering, acknowledge, summary, active, run
|
||||
"""
|
||||
|
||||
import uuid
|
||||
@@ -544,52 +544,6 @@ class TestAcknowledge:
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
|
||||
|
||||
@pytest.mark.django_db()
|
||||
class TestAcknowledgeAll:
|
||||
def test_marks_only_completed_tasks(self, admin_client: APIClient) -> None:
|
||||
"""acknowledge_all/ marks only SUCCESS and FAILURE tasks as acknowledged."""
|
||||
PaperlessTaskFactory(status=PaperlessTask.Status.SUCCESS, acknowledged=False)
|
||||
PaperlessTaskFactory(status=PaperlessTask.Status.FAILURE, acknowledged=False)
|
||||
PaperlessTaskFactory(status=PaperlessTask.Status.PENDING, acknowledged=False)
|
||||
|
||||
response = admin_client.post(ENDPOINT + "acknowledge_all/")
|
||||
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.data == {"result": 2}
|
||||
|
||||
def test_skips_already_acknowledged(self, admin_client: APIClient) -> None:
|
||||
"""acknowledge_all/ does not re-acknowledge tasks that are already acknowledged."""
|
||||
PaperlessTaskFactory(status=PaperlessTask.Status.SUCCESS, acknowledged=True)
|
||||
PaperlessTaskFactory(status=PaperlessTask.Status.SUCCESS, acknowledged=False)
|
||||
|
||||
response = admin_client.post(ENDPOINT + "acknowledge_all/")
|
||||
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.data == {"result": 1}
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("task_status", "expected_count"),
|
||||
[
|
||||
pytest.param(PaperlessTask.Status.PENDING, 0, id="pending-excluded"),
|
||||
pytest.param(PaperlessTask.Status.STARTED, 0, id="started-excluded"),
|
||||
pytest.param(PaperlessTask.Status.REVOKED, 1, id="revoked-included"),
|
||||
],
|
||||
)
|
||||
def test_acknowledge_all_by_status(
|
||||
self,
|
||||
admin_client: APIClient,
|
||||
task_status: PaperlessTask.Status,
|
||||
expected_count: int,
|
||||
) -> None:
|
||||
"""acknowledge_all/ ignores PENDING/STARTED and includes REVOKED."""
|
||||
PaperlessTaskFactory(status=task_status, acknowledged=False)
|
||||
|
||||
response = admin_client.post(ENDPOINT + "acknowledge_all/")
|
||||
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.data == {"result": expected_count}
|
||||
|
||||
|
||||
@pytest.mark.django_db()
|
||||
class TestSummary:
|
||||
def test_returns_per_type_totals(self, admin_client: APIClient) -> None:
|
||||
|
||||
@@ -3755,18 +3755,6 @@ class RemoteVersionView(GenericAPIView[Any]):
|
||||
),
|
||||
},
|
||||
),
|
||||
acknowledge_all=extend_schema(
|
||||
operation_id="acknowledge_all_tasks",
|
||||
description="Acknowledge all completed tasks visible to the requesting user",
|
||||
responses={
|
||||
(200, "application/json"): inline_serializer(
|
||||
name="AcknowledgeAllTasks",
|
||||
fields={
|
||||
"result": serializers.IntegerField(),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
run=extend_schema(
|
||||
operation_id="run_task",
|
||||
description="Manually dispatch a background task. Superuser only.",
|
||||
@@ -3895,23 +3883,6 @@ class TasksViewSet(ReadOnlyModelViewSet[PaperlessTask]):
|
||||
count = tasks.update(acknowledged=True)
|
||||
return Response({"result": count})
|
||||
|
||||
@action(
|
||||
methods=["post"],
|
||||
detail=False,
|
||||
permission_classes=[IsAuthenticated, AcknowledgeTasksPermissions],
|
||||
)
|
||||
def acknowledge_all(self, request):
|
||||
"""Acknowledge all completed tasks visible to the requesting user."""
|
||||
count = (
|
||||
self.get_queryset()
|
||||
.filter(
|
||||
acknowledged=False,
|
||||
status__in=PaperlessTask.COMPLETE_STATUSES,
|
||||
)
|
||||
.update(acknowledged=True)
|
||||
)
|
||||
return Response({"result": count})
|
||||
|
||||
@action(methods=["get"], detail=False)
|
||||
def summary(self, request):
|
||||
"""Aggregated task statistics per task_type over the last N days (default 30)."""
|
||||
|
||||
Reference in New Issue
Block a user