From 19bede4fc7f7320bb4eb16c3fe1a211b19ab4714 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 26 Jun 2020 12:27:51 +0200 Subject: Revamp error responses everywhere --- opendc/models/simulation.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'opendc/models/simulation.py') 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.")) -- cgit v1.2.3