diff options
Diffstat (limited to 'opendc-web/opendc-web-api/opendc/api/v2/prefabs')
3 files changed, 7 insertions, 11 deletions
diff --git a/opendc-web/opendc-web-api/opendc/api/v2/prefabs/authorizations/endpoint.py b/opendc-web/opendc-web-api/opendc/api/v2/prefabs/authorizations/endpoint.py index 0de50851..5a8d367f 100644 --- a/opendc-web/opendc-web-api/opendc/api/v2/prefabs/authorizations/endpoint.py +++ b/opendc-web/opendc-web-api/opendc/api/v2/prefabs/authorizations/endpoint.py @@ -1,17 +1,14 @@ from opendc.models.prefab import Prefab from opendc.util.database import DB -from opendc.models.user import User from opendc.util.rest import Response def GET(request): """Return all prefabs the user is authorized to access""" - user = User.from_google_id(request.current_user['sub']) + user_id = request.current_user['sub'] - user.check_exists() - - own_prefabs = DB.fetch_all({'authorId': user.get_id()}, Prefab.collection_name) + own_prefabs = DB.fetch_all({'authorId': user_id}, Prefab.collection_name) public_prefabs = DB.fetch_all({'visibility': 'public'}, Prefab.collection_name) authorizations = {"authorizations": []} diff --git a/opendc-web/opendc-web-api/opendc/api/v2/prefabs/endpoint.py b/opendc-web/opendc-web-api/opendc/api/v2/prefabs/endpoint.py index e77c7150..4a30f7eb 100644 --- a/opendc-web/opendc-web-api/opendc/api/v2/prefabs/endpoint.py +++ b/opendc-web/opendc-web-api/opendc/api/v2/prefabs/endpoint.py @@ -1,7 +1,6 @@ from datetime import datetime from opendc.models.prefab import Prefab -from opendc.models.user import User from opendc.util.database import Database from opendc.util.rest import Response @@ -15,8 +14,8 @@ def POST(request): prefab.set_property('datetimeCreated', Database.datetime_to_string(datetime.now())) prefab.set_property('datetimeLastEdited', Database.datetime_to_string(datetime.now())) - user = User.from_google_id(request.current_user['sub']) - prefab.set_property('authorId', user.get_id()) + user_id = request.current_user['sub'] + prefab.set_property('authorId', user_id) prefab.insert() diff --git a/opendc-web/opendc-web-api/opendc/api/v2/prefabs/prefabId/test_endpoint.py b/opendc-web/opendc-web-api/opendc/api/v2/prefabs/prefabId/test_endpoint.py index 2daeb6bf..bc3b1a32 100644 --- a/opendc-web/opendc-web-api/opendc/api/v2/prefabs/prefabId/test_endpoint.py +++ b/opendc-web/opendc-web-api/opendc/api/v2/prefabs/prefabId/test_endpoint.py @@ -32,7 +32,7 @@ def test_get_private_prefab(client, mocker): DB.fetch_one.side_effect = [{ '_id': test_id, 'name': 'test prefab', - 'authorId': test_id, + 'authorId': 'test', 'visibility': 'private', 'rack': {} }, @@ -92,7 +92,7 @@ def test_update_prefab(client, mocker): DB.fetch_one.side_effect = [{ '_id': test_id, 'name': 'test prefab', - 'authorId': test_id, + 'authorId': 'test', 'visibility': 'private', 'rack': {} }, @@ -132,7 +132,7 @@ def test_delete_prefab(client, mocker): DB.fetch_one.side_effect = [{ '_id': test_id, 'name': 'test prefab', - 'authorId': test_id, + 'authorId': 'test', 'visibility': 'private', 'rack': {} }, |
