A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Merge branch 'main' into dev
shamoon21ff254ffcb8
diff --cc pyproject.tomlindex 19dfe3fdc,d6a2ee594..0fca9ca46--- a/pyproject.toml+++ b/pyproject.toml@@@ -1,11 -1,12 +1,11 @@@[project]name = "paperless-ngx"- version = "2.20.14"+ version = "2.20.15"description = "A community-supported supercharged document management system: scan, index and archive all your physical documents"readme = "README.md"-requires-python = ">=3.10"+requires-python = ">=3.11"classifiers = ["Programming Language :: Python :: 3 :: Only",- "Programming Language :: Python :: 3.10","Programming Language :: Python :: 3.11","Programming Language :: Python :: 3.12","Programming Language :: Python :: 3.13",diff --cc src-ui/src/environments/environment.prod.tsindex 0db350bc2,7f0ab1c2c..d92d7d7d9--- a/src-ui/src/environments/environment.prod.ts+++ b/src-ui/src/environments/environment.prod.ts@@@ -3,10 -3,10 +3,10 @@@ const base_url = new URL(document.baseUexport const environment = {production: true,apiBaseUrl: document.baseURI + 'api/',- apiVersion: '9', // match src/paperless/settings.py+ apiVersion: '10', // match src/paperless/settings.pyappTitle: 'Paperless-ngx',tag: 'prod',- version: '2.20.14',+ version: '2.20.15',webSocketHost: window.location.host,webSocketProtocol: window.location.protocol == 'https:' ? 'wss:' : 'ws:',webSocketBaseUrl: base_url.pathname + 'ws/',diff --cc src/paperless_mail/serialisers.pyindex a4c3c5830,d84041f45..8a0772732--- a/src/paperless_mail/serialisers.py+++ b/src/paperless_mail/serialisers.py@@@ -57,9 -58,20 +58,20 @@@ class MailAccountSerializer(OwnedObjectreturn instance-class AccountField(serializers.PrimaryKeyRelatedField):+class AccountField(serializers.PrimaryKeyRelatedField[MailAccount]):def get_queryset(self):- return MailAccount.objects.all().order_by("-id")+ user = getattr(self.context.get("request"), "user", None)+ if user is None:+ user = getattr(self.root, "user", None)++ if user is None:+ return MailAccount.objects.none()++ return get_objects_for_user_owner_aware(+ user,+ "change_mailaccount",+ MailAccount,+ ).order_by("-id")class MailRuleSerializer(OwnedObjectSerializer):diff --cc src/paperless_mail/tests/test_api.pyindex f00a8059e,23972da35..088ee0eb6--- a/src/paperless_mail/tests/test_api.py+++ b/src/paperless_mail/tests/test_api.py@@@ -493,9 -632,18 +493,9 @@@ class TestAPIMailRules(DirectoriesMixinself.assertEqual(returned_rule1.name, "Updated Name 1")self.assertEqual(returned_rule1.action, MailRule.MailAction.DELETE)- def test_create_mail_rule_forbidden_for_unpermitted_account(self) -> None:- def test_create_mail_rule_scopes_accounts(self):++ def test_create_mail_rule_scopes_accounts(self) -> None:other_user = User.objects.create_user(username="mail-owner")- foreign_account = MailAccount.objects.create(- name="ForeignEmail",- username="username1",- password="password1",- imap_server="server.example.com",- imap_port=443,- imap_security=MailAccount.ImapSecurity.SSL,- character_set="UTF-8",- owner=other_user,- )+ foreign_account = MailAccountFactory(name="ForeignEmail", owner=other_user)response = self.client.post(self.ENDPOINT,@@@ -512,15 -660,40 +512,33 @@@"attachment_type": MailRule.AttachmentProcessing.ATTACHMENTS_ONLY,},)+ missing_response = self.client.post(+ self.ENDPOINT,+ data={+ "name": "Rule1",+ "account": foreign_account.pk + 1000,+ "folder": "INBOX",+ "filter_from": "[email protected]",+ "maximum_age": 30,+ "action": MailRule.MailAction.MARK_READ,+ "assign_title_from": MailRule.TitleSource.FROM_SUBJECT,+ "assign_correspondent_from": MailRule.CorrespondentSource.FROM_NOTHING,+ "order": 0,+ "attachment_type": MailRule.AttachmentProcessing.ATTACHMENTS_ONLY,+ },+ )- self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)+ self.assertEqual(missing_response.status_code, status.HTTP_400_BAD_REQUEST)+ self.assertEqual(response.data["account"][0].code, "does_not_exist")+ self.assertEqual(missing_response.data["account"][0].code, "does_not_exist")self.assertEqual(MailRule.objects.count(), 0)- def test_create_mail_rule_allowed_for_granted_account_change_permission(self):+ def test_create_mail_rule_allowed_for_granted_account_change_permission(+ self,+ ) -> None:other_user = User.objects.create_user(username="mail-owner")- foreign_account = MailAccount.objects.create(- name="ForeignEmail",- username="username1",- password="password1",- imap_server="server.example.com",- imap_port=443,- imap_security=MailAccount.ImapSecurity.SSL,- character_set="UTF-8",- owner=other_user,- )+ foreign_account = MailAccountFactory(name="ForeignEmail", owner=other_user)assign_perm("change_mailaccount", self.user, foreign_account)response = self.client.post(