29
29
from flask import Response , abort , current_app , jsonify , send_file
30
30
from webargs import fields , validate
31
31
32
- from ...auth .const import PERM_VIEW_PRIVATE
32
+ from ...auth .const import PERM_EDIT_OBJ , PERM_VIEW_PRIVATE
33
33
from ...const import MIME_TYPES
34
34
from ..auth import has_permissions
35
35
from ..report import check_report_id_exists , get_reports , run_report
42
42
)
43
43
from . import ProtectedResource
44
44
from .emit import GrampsJSONEncoder
45
+ from .util import check_fix_default_person
45
46
46
47
47
48
class ReportsResource (ProtectedResource , GrampsJSONEncoder ):
@@ -50,6 +51,8 @@ class ReportsResource(ProtectedResource, GrampsJSONEncoder):
50
51
@use_args ({}, location = "query" )
51
52
def get (self , args : Dict ) -> Response :
52
53
"""Get all available report attributes."""
54
+ if has_permissions ({PERM_EDIT_OBJ }):
55
+ check_fix_default_person (get_db_handle (readonly = False ))
53
56
reports = get_reports (get_db_handle ())
54
57
return self .response (200 , reports )
55
58
@@ -60,6 +63,8 @@ class ReportResource(ProtectedResource, GrampsJSONEncoder):
60
63
@use_args ({}, location = "query" )
61
64
def get (self , args : Dict , report_id : str ) -> Response :
62
65
"""Get specific report attributes."""
66
+ if has_permissions ({PERM_EDIT_OBJ }):
67
+ check_fix_default_person (get_db_handle (readonly = False ))
63
68
reports = get_reports (get_db_handle (), report_id = report_id )
64
69
if not reports :
65
70
abort (404 )
@@ -90,6 +95,9 @@ def get(self, args: Dict, report_id: str) -> Response:
90
95
if "of" in report_options :
91
96
abort (422 )
92
97
98
+ if has_permissions ({PERM_EDIT_OBJ }):
99
+ check_fix_default_person (get_db_handle (readonly = False ))
100
+
93
101
file_name , file_type = run_report (
94
102
db_handle = get_db_handle (),
95
103
report_id = report_id ,
@@ -121,6 +129,8 @@ def post(self, args: Dict, report_id: str) -> Response:
121
129
abort (400 )
122
130
if "of" in report_options :
123
131
abort (422 )
132
+ if has_permissions ({PERM_EDIT_OBJ }):
133
+ check_fix_default_person (get_db_handle (readonly = False ))
124
134
tree = get_tree_from_jwt ()
125
135
task = run_task (
126
136
generate_report ,
0 commit comments