diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-06-25 18:35:53 +0200 |
|---|---|---|
| committer | Georgios Andreadis <info@gandreadis.com> | 2020-06-25 18:35:53 +0200 |
| commit | 00597ec99f587557b88b9982a2c41a2cb8db8112 (patch) | |
| tree | b5a535951db7e0b99887ae6456e3410404982449 /opendc/models | |
| parent | 4c272a01f38aba268dd8b8aa17dae4c9f56b087f (diff) | |
Add simulation put path
Diffstat (limited to 'opendc/models')
| -rw-r--r-- | opendc/models/simulation.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/opendc/models/simulation.py b/opendc/models/simulation.py index bb2ef1bc..f58581cf 100644 --- a/opendc/models/simulation.py +++ b/opendc/models/simulation.py @@ -1,5 +1,16 @@ from opendc.models.model import Model +from opendc.models.user import User +from opendc.util.rest import Response class Simulation(Model): collection_name = 'simulations' + + def validate_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 |
