Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
search permissions for encounters
Browse files Browse the repository at this point in the history
  • Loading branch information
naknomum committed Dec 1, 2023
1 parent 952d356 commit 01d720e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/modules/encounters/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,29 @@ def post(self):

from app.extensions.export.models import Export

ct = 0
added = set()
export = Export()
for enc in encs:
if not enc.current_user_has_view_permission():
continue
export.add(enc)
if enc.sighting_guid not in added:
ct += 1
if (
enc.sighting_guid not in added
and enc.sighting.current_user_has_view_permission()
):
added.add(enc.sighting_guid)
export.add(enc.sighting)
if enc.individual_guid and enc.individual_guid not in added:
if (
enc.individual_guid
and enc.individual_guid not in added
and enc.individual.current_user_has_view_permission()
):
added.add(enc.individual_guid)
export.add(enc.individual)
if not ct:
abort(400, 'No results to export')
export.save()
return send_file(
export.filepath,
Expand Down
1 change: 1 addition & 0 deletions app/modules/encounters/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Meta:
'verbatimLocality',
'location_geo_point',
'customFields',
'hasView',
)
dump_only = (Encounter.guid.key,)

Expand Down

0 comments on commit 01d720e

Please sign in to comment.