From 52dbe93d3c7f5acb98eadc4819af7a43ccf199a7 Mon Sep 17 00:00:00 2001 From: jedi Date: Fri, 23 Feb 2024 18:51:52 +0100 Subject: [PATCH] rename availability policies --- backend/configure.py | 2 ++ backend/toolshed/api/info.py | 5 ++--- backend/toolshed/tests/test_api.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/configure.py b/backend/configure.py index ead8fa9..67b87b5 100755 --- a/backend/configure.py +++ b/backend/configure.py @@ -196,6 +196,8 @@ def main(): reset() elif args.cmd == 'testdata': testdata() + elif args.cmd == 'migrate': + print('not implemented yet') else: print('Unknown command: {}'.format(args.cmd)) exit(1) diff --git a/backend/toolshed/api/info.py b/backend/toolshed/api/info.py index 1ed623d..3c54412 100644 --- a/backend/toolshed/api/info.py +++ b/backend/toolshed/api/info.py @@ -5,7 +5,7 @@ from rest_framework.response import Response from hostadmin.models import Domain from authentication.signature_auth import SignatureAuthentication -from toolshed.models import Tag, Property, Category +from toolshed.models import Tag, Property, Category, InventoryItem from toolshed.serializers import CategorySerializer, PropertySerializer from backend.settings import TOOLSHED_VERSION @@ -51,8 +51,7 @@ def list_categories(request, format=None): # /categories/ @permission_classes([IsAuthenticated]) @authentication_classes([SignatureAuthentication]) def list_availability_policies(request, format=None): # /availability_policies/ - policies = ['private', 'friends', 'internal', 'public'] - return Response(policies) + return Response(InventoryItem.AVAILABILITY_POLICY_CHOICES) @api_view(['GET']) diff --git a/backend/toolshed/tests/test_api.py b/backend/toolshed/tests/test_api.py index 18968d7..c926dec 100644 --- a/backend/toolshed/tests/test_api.py +++ b/backend/toolshed/tests/test_api.py @@ -43,7 +43,8 @@ class CombinedApiTestCase(UserTestMixin, CategoryTestMixin, TagTestMixin, Proper def test_policy_api(self): response = client.get('/api/availability_policies/', self.f['local_user1']) self.assertEqual(response.status_code, 200) - self.assertEqual(response.json(), ['private', 'friends', 'internal', 'public']) + self.assertEqual(response.json(), [['sell', 'Sell'], ['rent', 'Rent'], ['lend', 'Lend'], ['share', 'Share'], + ['private', 'Private']]) def test_combined_api_anonymous(self): response = anonymous_client.get('/api/info/')