Fix: let template viewers preview zones

The zone preview is a POST, so it required permission to add templates. Both
preview endpoints now require viewing templates and documents.
This commit is contained in:
stumpylog committed 2026-11-19 08:27:51 -08:00
1 parent 0e7cbda3d9
commit f401267c4b
3 files changed
+79 -5

No files matched your search

+15
View File
@@ -699,6 +699,21 @@ class ViewDocumentsPermissions(GlobalPermissionsByMethod):
}
class ViewOcrTemplatesPermissions(GlobalPermissionsByMethod):
"""
Requires the global permission to view OCR templates for OPTIONS, GET and
POST, for the template editor's read-only preview endpoints.
"""
perms_map = {
"OPTIONS": ["documents.view_ocrtemplate"],
"GET": ["documents.view_ocrtemplate"],
# The zone preview is a POST only to carry the zone in the body; it
# creates and changes nothing, so viewing templates is enough.
"POST": ["documents.view_ocrtemplate"],
}
class TrashPermissions(GlobalPermissionsByMethod):
"""Check the global document permission for each trash operation."""