diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-06-30 10:31:27 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:42:26 +0200 |
| commit | 690818051d0c9768cdaf735acf77ea9e98f00b38 (patch) | |
| tree | 81c43b13309e765c57a0e7d1ff7085310516b053 /web-server/opendc/models | |
| parent | 13d8de8b9e3ecdfcf1f315a095934bd2b0a68729 (diff) | |
Implement authorizations endpoint
Diffstat (limited to 'web-server/opendc/models')
| -rw-r--r-- | web-server/opendc/models/simulation.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/web-server/opendc/models/simulation.py b/web-server/opendc/models/simulation.py index 5cd3d49e..a77697ab 100644 --- a/web-server/opendc/models/simulation.py +++ b/web-server/opendc/models/simulation.py @@ -1,5 +1,6 @@ from opendc.models.model import Model from opendc.models.user import User +from opendc.util.database import DB from opendc.util.exceptions import ClientError from opendc.util.rest import Response @@ -13,3 +14,10 @@ class Simulation(Model): 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'): raise ClientError(Response(403, "Forbidden from retrieving simulation.")) + + def get_all_authorizations(self): + return [ + user['_id'] for user in DB.fetch_all({'authorizations': { + 'simulationId': self.obj['_id'] + }}, User.collection_name) + ] |
