]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Merge pull request #3309 from paperless-ngx/feature-owner-filtering
authorshamoon <4887959+shamoon@users.noreply.github.com>
Thu, 11 May 2023 17:05:51 +0000 (10:05 -0700)
committerGitHub <noreply@github.com>
Thu, 11 May 2023 17:05:51 +0000 (10:05 -0700)
Feature: owner filtering

1  2 
src-ui/src/app/components/common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component.html
src-ui/src/styles.scss
src/documents/tests/test_api.py

Simple merge
index fbb0b5eb5d60bae0ef68b6c63c1e361cbd53f311,d092eb8d712764b5eb6a86108eeb5e0d9f086c31..24f44b62a3f0fd6800e21319847a555f0bec82c7
@@@ -1251,32 -1367,15 +1371,40 @@@ class TestDocumentApi(DirectoriesMixin
              search_query("&ordering=-num_notes"),
              [d1.id, d3.id, d2.id],
          )
+         self.assertListEqual(
+             search_query("&ordering=owner"),
+             [d1.id, d2.id, d3.id],
+         )
+         self.assertListEqual(
+             search_query("&ordering=-owner"),
+             [d3.id, d2.id, d1.id],
+         )
  
 +    def test_pagination_all(self):
 +        """
 +        GIVEN:
 +            - A set of 50 documents
 +        WHEN:
 +            - API reuqest for document filtering
 +        THEN:
 +            - Results are paginated (25 items) and response["all"] returns all ids (50 items)
 +        """
 +        t = Tag.objects.create(name="tag")
 +        docs = []
 +        for i in range(50):
 +            d = Document.objects.create(checksum=i, content=f"test{i}")
 +            d.tags.add(t)
 +            docs.append(d)
 +
 +        response = self.client.get(
 +            f"/api/documents/?tags__id__in={t.id}",
 +        )
 +        self.assertEqual(response.status_code, status.HTTP_200_OK)
 +        results = response.data["results"]
 +        self.assertEqual(len(results), 25)
 +        self.assertEqual(len(response.data["all"]), 50)
 +        self.assertCountEqual(response.data["all"], [d.id for d in docs])
 +
      def test_statistics(self):
          doc1 = Document.objects.create(
              title="none1",