summaryrefslogtreecommitdiff
path: root/opendc/models/simulation.py
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-26 12:27:51 +0200
committerGeorgios Andreadis <info@gandreadis.com>2020-06-26 12:27:51 +0200
commit19bede4fc7f7320bb4eb16c3fe1a211b19ab4714 (patch)
tree6a53629feb7bd8c7a9380d204287f3429ed2f378 /opendc/models/simulation.py
parent92b94b59ad80329a2c99471edbf5bbdc9af1e525 (diff)
Revamp error responses everywhere
Diffstat (limited to 'opendc/models/simulation.py')
-rw-r--r--opendc/models/simulation.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/opendc/models/simulation.py b/opendc/models/simulation.py
index f58581cf..5cd3d49e 100644
--- a/opendc/models/simulation.py
+++ b/opendc/models/simulation.py
@@ -1,16 +1,15 @@
from opendc.models.model import Model
from opendc.models.user import User
+from opendc.util.exceptions import ClientError
from opendc.util.rest import Response
class Simulation(Model):
collection_name = 'simulations'
- def validate_user_access(self, google_id, edit_access):
+ def check_user_access(self, google_id, edit_access):
user = User.from_google_id(google_id)
authorizations = list(
filter(lambda x: str(x['simulationId']) == str(self.obj['_id']), user.obj['authorizations']))
if len(authorizations) == 0 or (edit_access and authorizations[0]['authorizationLevel'] == 'VIEW'):
- return Response(403, "Forbidden from retrieving simulation.")
-
- return None
+ raise ClientError(Response(403, "Forbidden from retrieving simulation."))