[Feature] Search for Permissions, Prep Compound / Structure to be extended, Prep Template overwrites (#347)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#347
This commit is contained in:
2026-03-11 11:27:15 +13:00
parent d4295c9349
commit b737fc93eb
12 changed files with 242 additions and 27 deletions

View File

@ -41,6 +41,24 @@ def get_package_for_read(user, package_uuid: UUID):
return package
def get_package_for_write(user, package_uuid: UUID):
"""
Get package by UUID with permission check.
"""
# FIXME: update package manager with custom exceptions to avoid manual checks here
try:
package = Package.objects.get(uuid=package_uuid)
except Package.DoesNotExist:
raise EPAPINotFoundError(f"Package with UUID {package_uuid} not found")
# FIXME: optimize package manager to exclusively work with UUIDs
if not user or user.is_anonymous or not PackageManager.writable(user, package):
raise EPAPIPermissionDeniedError("Insufficient permissions to access this package.")
return package
def get_scenario_for_read(user, scenario_uuid: UUID):
"""Get scenario by UUID with read permission check."""
try: