mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Support acknowledged param
This commit is contained in:
parent
e1b944ce6b
commit
f3438914cc
@ -162,7 +162,9 @@ describe('TasksComponent', () => {
|
|||||||
jest.useFakeTimers()
|
jest.useFakeTimers()
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
httpTestingController
|
httpTestingController
|
||||||
.expectOne(`${environment.apiBaseUrl}tasks/?task_name=consume_file`)
|
.expectOne(
|
||||||
|
`${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
|
||||||
|
)
|
||||||
.flush(tasks)
|
.flush(tasks)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ describe('TasksService', () => {
|
|||||||
it('calls tasks api endpoint on reload', () => {
|
it('calls tasks api endpoint on reload', () => {
|
||||||
tasksService.reload()
|
tasksService.reload()
|
||||||
const req = httpTestingController.expectOne(
|
const req = httpTestingController.expectOne(
|
||||||
`${environment.apiBaseUrl}tasks/?task_name=consume_file`
|
`${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
|
||||||
)
|
)
|
||||||
expect(req.request.method).toEqual('GET')
|
expect(req.request.method).toEqual('GET')
|
||||||
})
|
})
|
||||||
@ -46,7 +46,7 @@ describe('TasksService', () => {
|
|||||||
tasksService.loading = true
|
tasksService.loading = true
|
||||||
tasksService.reload()
|
tasksService.reload()
|
||||||
httpTestingController.expectNone(
|
httpTestingController.expectNone(
|
||||||
`${environment.apiBaseUrl}tasks/?task_name=consume_file`
|
`${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -62,7 +62,9 @@ describe('TasksService', () => {
|
|||||||
req.flush([])
|
req.flush([])
|
||||||
// reload is then called
|
// reload is then called
|
||||||
httpTestingController
|
httpTestingController
|
||||||
.expectOne(`${environment.apiBaseUrl}tasks/?task_name=consume_file`)
|
.expectOne(
|
||||||
|
`${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
|
||||||
|
)
|
||||||
.flush([])
|
.flush([])
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -119,7 +121,7 @@ describe('TasksService', () => {
|
|||||||
tasksService.reload()
|
tasksService.reload()
|
||||||
|
|
||||||
const req = httpTestingController.expectOne(
|
const req = httpTestingController.expectOne(
|
||||||
`${environment.apiBaseUrl}tasks/?task_name=consume_file`
|
`${environment.apiBaseUrl}tasks/?task_name=consume_file&acknowledged=false`
|
||||||
)
|
)
|
||||||
|
|
||||||
req.flush(mockTasks)
|
req.flush(mockTasks)
|
||||||
|
@ -54,7 +54,9 @@ export class TasksService {
|
|||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
||||||
this.http
|
this.http
|
||||||
.get<PaperlessTask[]>(`${this.baseUrl}tasks/?task_name=consume_file`)
|
.get<PaperlessTask[]>(
|
||||||
|
`${this.baseUrl}tasks/?task_name=consume_file&acknowledged=false`
|
||||||
|
)
|
||||||
.pipe(takeUntil(this.unsubscribeNotifer), first())
|
.pipe(takeUntil(this.unsubscribeNotifer), first())
|
||||||
.subscribe((r) => {
|
.subscribe((r) => {
|
||||||
this.fileTasks = r.filter((t) => t.type == PaperlessTaskType.Auto)
|
this.fileTasks = r.filter((t) => t.type == PaperlessTaskType.Auto)
|
||||||
|
@ -772,6 +772,11 @@ class ShareLinkFilterSet(FilterSet):
|
|||||||
|
|
||||||
|
|
||||||
class PaperlessTaskFilterSet(FilterSet):
|
class PaperlessTaskFilterSet(FilterSet):
|
||||||
|
acknowledged = BooleanFilter(
|
||||||
|
label="Acknowledged",
|
||||||
|
field_name="acknowledged",
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PaperlessTask
|
model = PaperlessTask
|
||||||
fields = {
|
fields = {
|
||||||
|
@ -1708,20 +1708,21 @@ class TasksViewSerializer(OwnedObjectSerializer):
|
|||||||
def get_related_document(self, obj) -> str | None:
|
def get_related_document(self, obj) -> str | None:
|
||||||
result = None
|
result = None
|
||||||
re = None
|
re = None
|
||||||
match obj.status:
|
if obj.result:
|
||||||
case states.SUCCESS:
|
match obj.status:
|
||||||
re = self.created_doc_re
|
case states.SUCCESS:
|
||||||
case states.FAILURE:
|
re = self.created_doc_re
|
||||||
re = (
|
case states.FAILURE:
|
||||||
self.duplicate_doc_re
|
re = (
|
||||||
if "existing document is in the trash" not in obj.result
|
self.duplicate_doc_re
|
||||||
else None
|
if "existing document is in the trash" not in obj.result
|
||||||
)
|
else None
|
||||||
if re is not None:
|
)
|
||||||
try:
|
if re is not None:
|
||||||
result = re.search(obj.result).group(1)
|
try:
|
||||||
except Exception:
|
result = re.search(obj.result).group(1)
|
||||||
pass
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -2233,13 +2233,7 @@ class TasksViewSet(ReadOnlyModelViewSet):
|
|||||||
filterset_class = PaperlessTaskFilterSet
|
filterset_class = PaperlessTaskFilterSet
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = (
|
queryset = PaperlessTask.objects.all().order_by("date_created").reverse()
|
||||||
PaperlessTask.objects.filter(
|
|
||||||
acknowledged=False,
|
|
||||||
)
|
|
||||||
.order_by("date_created")
|
|
||||||
.reverse()
|
|
||||||
)
|
|
||||||
task_id = self.request.query_params.get("task_id")
|
task_id = self.request.query_params.get("task_id")
|
||||||
if task_id is not None:
|
if task_id is not None:
|
||||||
queryset = PaperlessTask.objects.filter(task_id=task_id)
|
queryset = PaperlessTask.objects.filter(task_id=task_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user