2929from flask import Response , abort , current_app , jsonify , send_file
3030from webargs import fields , validate
3131
32- from ...auth .const import PERM_VIEW_PRIVATE
32+ from ...auth .const import PERM_EDIT_OBJ , PERM_VIEW_PRIVATE
3333from ...const import MIME_TYPES
3434from ..auth import has_permissions
3535from ..report import check_report_id_exists , get_reports , run_report
4242)
4343from . import ProtectedResource
4444from .emit import GrampsJSONEncoder
45+ from .util import check_fix_default_person
4546
4647
4748class ReportsResource (ProtectedResource , GrampsJSONEncoder ):
@@ -50,6 +51,8 @@ class ReportsResource(ProtectedResource, GrampsJSONEncoder):
5051 @use_args ({}, location = "query" )
5152 def get (self , args : Dict ) -> Response :
5253 """Get all available report attributes."""
54+ if has_permissions ({PERM_EDIT_OBJ }):
55+ check_fix_default_person (get_db_handle (readonly = False ))
5356 reports = get_reports (get_db_handle ())
5457 return self .response (200 , reports )
5558
@@ -60,6 +63,8 @@ class ReportResource(ProtectedResource, GrampsJSONEncoder):
6063 @use_args ({}, location = "query" )
6164 def get (self , args : Dict , report_id : str ) -> Response :
6265 """Get specific report attributes."""
66+ if has_permissions ({PERM_EDIT_OBJ }):
67+ check_fix_default_person (get_db_handle (readonly = False ))
6368 reports = get_reports (get_db_handle (), report_id = report_id )
6469 if not reports :
6570 abort (404 )
@@ -90,6 +95,9 @@ def get(self, args: Dict, report_id: str) -> Response:
9095 if "of" in report_options :
9196 abort (422 )
9297
98+ if has_permissions ({PERM_EDIT_OBJ }):
99+ check_fix_default_person (get_db_handle (readonly = False ))
100+
93101 file_name , file_type = run_report (
94102 db_handle = get_db_handle (),
95103 report_id = report_id ,
@@ -121,6 +129,8 @@ def post(self, args: Dict, report_id: str) -> Response:
121129 abort (400 )
122130 if "of" in report_options :
123131 abort (422 )
132+ if has_permissions ({PERM_EDIT_OBJ }):
133+ check_fix_default_person (get_db_handle (readonly = False ))
124134 tree = get_tree_from_jwt ()
125135 task = run_task (
126136 generate_report ,
0 commit comments