diff --git a/rsconcept/backend/apps/rsform/tests/s_views/t_library.py b/rsconcept/backend/apps/rsform/tests/s_views/t_library.py index 1626b044..6d48aa08 100644 --- a/rsconcept/backend/apps/rsform/tests/s_views/t_library.py +++ b/rsconcept/backend/apps/rsform/tests/s_views/t_library.py @@ -179,7 +179,7 @@ class TestLibraryViewset(EndpointTester): self.unowned.refresh_from_db() self.assertEqual(self.unowned.location, data['location']) - @decl_endpoint('/api/library/{item}/editors-add', method='patch') + @decl_endpoint('/api/library/{item}/add-editor', method='patch') def test_add_editor(self): time_update = self.owned.time_update @@ -203,7 +203,7 @@ class TestLibraryViewset(EndpointTester): self.assertEqual(set(self.owned.editors()), set([self.user, self.user2])) - @decl_endpoint('/api/library/{item}/editors-remove', method='patch') + @decl_endpoint('/api/library/{item}/remove-editor', method='patch') def test_remove_editor(self): time_update = self.owned.time_update @@ -230,7 +230,7 @@ class TestLibraryViewset(EndpointTester): self.assertEqual(self.owned.editors(), [self.user]) - @decl_endpoint('/api/library/{item}/editors-set', method='patch') + @decl_endpoint('/api/library/{item}/set-editors', method='patch') def test_set_editors(self): time_update = self.owned.time_update diff --git a/rsconcept/backend/apps/rsform/tests/s_views/t_rsforms.py b/rsconcept/backend/apps/rsform/tests/s_views/t_rsforms.py index ca674801..27383b7a 100644 --- a/rsconcept/backend/apps/rsform/tests/s_views/t_rsforms.py +++ b/rsconcept/backend/apps/rsform/tests/s_views/t_rsforms.py @@ -186,7 +186,7 @@ class TestRSFormViewset(EndpointTester): self.assertIn('document.json', zipped_file.namelist()) - @decl_endpoint('/api/rsforms/{item}/cst-create', method='post') + @decl_endpoint('/api/rsforms/{item}/create-cst', method='post') def test_create_constituenta(self): data = {'alias': 'X3'} self.executeForbidden(data=data, item=self.unowned_id) @@ -229,7 +229,7 @@ class TestRSFormViewset(EndpointTester): self.assertEqual(response.data['new_cst']['alias'], data['alias']) - @decl_endpoint('/api/rsforms/{item}/cst-rename', method='patch') + @decl_endpoint('/api/rsforms/{item}/rename-cst', method='patch') def test_rename_constituenta(self): x1 = self.owned.insert_new( alias='X1', @@ -279,7 +279,7 @@ class TestRSFormViewset(EndpointTester): self.assertEqual(x1.cst_type, CstType.TERM) - @decl_endpoint('/api/rsforms/{item}/cst-substitute', method='patch') + @decl_endpoint('/api/rsforms/{item}/substitute', method='patch') def test_substitute_single(self): x1 = self.owned.insert_new( alias='X1', @@ -316,7 +316,7 @@ class TestRSFormViewset(EndpointTester): self.assertEqual(d1.term_resolved, 'form1') self.assertEqual(d1.definition_formal, 'X2') - @decl_endpoint('/api/rsforms/{item}/cst-substitute', method='patch') + @decl_endpoint('/api/rsforms/{item}/substitute', method='patch') def test_substitute_multiple(self): self.set_params(item=self.owned_id) x1 = self.owned.insert_new('X1') @@ -362,7 +362,7 @@ class TestRSFormViewset(EndpointTester): self.assertEqual(d3.definition_formal, r'D1 \ D2') - @decl_endpoint('/api/rsforms/{item}/cst-create', method='post') + @decl_endpoint('/api/rsforms/{item}/create-cst', method='post') def test_create_constituenta_data(self): data = { 'alias': 'X3', @@ -383,7 +383,7 @@ class TestRSFormViewset(EndpointTester): self.assertEqual(response.data['new_cst']['definition_resolved'], '4') - @decl_endpoint('/api/rsforms/{item}/cst-delete-multiple', method='patch') + @decl_endpoint('/api/rsforms/{item}/delete-multiple-cst', method='patch') def test_delete_constituenta(self): self.set_params(item=self.owned_id) @@ -407,7 +407,7 @@ class TestRSFormViewset(EndpointTester): self.executeBadData(data=data, item=self.owned_id) - @decl_endpoint('/api/rsforms/{item}/cst-moveto', method='patch') + @decl_endpoint('/api/rsforms/{item}/move-cst', method='patch') def test_move_constituenta(self): self.set_params(item=self.owned_id) @@ -473,7 +473,7 @@ class TestRSFormViewset(EndpointTester): self.assertFalse(Constituenta.objects.filter(pk=x1.pk).exists()) - @decl_endpoint('/api/rsforms/{item}/cst-produce-structure', method='patch') + @decl_endpoint('/api/rsforms/{item}/produce-structure', method='patch') def test_produce_structure(self): self.set_params(item=self.owned_id) x1 = self.owned.insert_new('X1') diff --git a/rsconcept/backend/apps/rsform/views/library.py b/rsconcept/backend/apps/rsform/views/library.py index ffb8bb62..cbbb937f 100644 --- a/rsconcept/backend/apps/rsform/views/library.py +++ b/rsconcept/backend/apps/rsform/views/library.py @@ -49,9 +49,9 @@ class LibraryViewSet(viewsets.ModelViewSet): 'set_owner', 'set_access_policy', 'set_location', - 'editors_add', - 'editors_remove', - 'editors_set' + 'add_editor', + 'remove_editor', + 'set_editors' ]: access_level = permissions.ItemOwner elif self.action in [ @@ -220,8 +220,8 @@ class LibraryViewSet(viewsets.ModelViewSet): c.HTTP_404_NOT_FOUND: None } ) - @action(detail=True, methods=['patch'], url_path='editors-add') - def editors_add(self, request: Request, pk): + @action(detail=True, methods=['patch'], url_path='add-editor') + def add_editor(self, request: Request, pk): ''' Endpoint: Add editor for item. ''' item = self._get_item() serializer = s.UserTargetSerializer(data=request.data) @@ -240,8 +240,8 @@ class LibraryViewSet(viewsets.ModelViewSet): c.HTTP_404_NOT_FOUND: None } ) - @action(detail=True, methods=['patch'], url_path='editors-remove') - def editors_remove(self, request: Request, pk): + @action(detail=True, methods=['patch'], url_path='remove-editor') + def remove_editor(self, request: Request, pk): ''' Endpoint: Remove editor for item. ''' item = self._get_item() serializer = s.UserTargetSerializer(data=request.data) @@ -260,8 +260,8 @@ class LibraryViewSet(viewsets.ModelViewSet): c.HTTP_404_NOT_FOUND: None } ) - @action(detail=True, methods=['patch'], url_path='editors-set') - def editors_set(self, request: Request, pk): + @action(detail=True, methods=['patch'], url_path='set-editors') + def set_editors(self, request: Request, pk): ''' Endpoint: Set list of editors for item. ''' item = self._get_item() serializer = s.UsersListSerializer(data=request.data) diff --git a/rsconcept/backend/apps/rsform/views/rsforms.py b/rsconcept/backend/apps/rsform/views/rsforms.py index abdb28dc..030de8ce 100644 --- a/rsconcept/backend/apps/rsform/views/rsforms.py +++ b/rsconcept/backend/apps/rsform/views/rsforms.py @@ -35,11 +35,14 @@ class RSFormViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retr ''' Determine permission class. ''' if self.action in [ 'load_trs', + 'create_cst', + 'delete_multiple_cst', + 'rename_cst', + 'move_cst', + 'substitute', + 'restore_order', 'reset_aliases', - 'cst_create', - 'cst_delete_multiple', - 'cst_rename', - 'cst_substitute' + 'produce_structure' ]: permission_list = [permissions.ItemEditor] elif self.action in [ @@ -65,8 +68,8 @@ class RSFormViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retr c.HTTP_404_NOT_FOUND: None } ) - @action(detail=True, methods=['post'], url_path='cst-create') - def cst_create(self, request: Request, pk): + @action(detail=True, methods=['post'], url_path='create-cst') + def create_cst(self, request: Request, pk): ''' Create new constituenta. ''' schema = self._get_schema() serializer = s.CstCreateSerializer(data=request.data) @@ -103,7 +106,7 @@ class RSFormViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retr c.HTTP_404_NOT_FOUND: None } ) - @action(detail=True, methods=['patch'], url_path='cst-produce-structure') + @action(detail=True, methods=['patch'], url_path='produce-structure') def produce_structure(self, request: Request, pk): ''' Produce a term for every element of the target constituenta typification. ''' schema = self._get_schema() @@ -140,8 +143,8 @@ class RSFormViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retr c.HTTP_404_NOT_FOUND: None } ) - @action(detail=True, methods=['patch'], url_path='cst-rename') - def cst_rename(self, request: Request, pk): + @action(detail=True, methods=['patch'], url_path='rename-cst') + def rename_cst(self, request: Request, pk): ''' Rename constituenta possibly changing type. ''' schema = self._get_schema() serializer = s.CstRenameSerializer(data=request.data, context={'schema': schema}) @@ -178,8 +181,8 @@ class RSFormViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retr c.HTTP_404_NOT_FOUND: None } ) - @action(detail=True, methods=['patch'], url_path='cst-substitute') - def cst_substitute(self, request: Request, pk): + @action(detail=True, methods=['patch'], url_path='substitute') + def substitute(self, request: Request, pk): ''' Substitute occurrences of constituenta with another one. ''' schema = self._get_schema() serializer = s.CstSubstituteSerializer( @@ -210,8 +213,8 @@ class RSFormViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retr c.HTTP_404_NOT_FOUND: None } ) - @action(detail=True, methods=['patch'], url_path='cst-delete-multiple') - def cst_delete_multiple(self, request: Request, pk): + @action(detail=True, methods=['patch'], url_path='delete-multiple-cst') + def delete_multiple_cst(self, request: Request, pk): ''' Endpoint: Delete multiple constituents. ''' schema = self._get_schema() serializer = s.CstListSerializer( @@ -237,8 +240,8 @@ class RSFormViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retr c.HTTP_404_NOT_FOUND: None } ) - @action(detail=True, methods=['patch'], url_path='cst-moveto') - def cst_moveto(self, request: Request, pk): + @action(detail=True, methods=['patch'], url_path='move-cst') + def move_cst(self, request: Request, pk): ''' Endpoint: Move multiple constituents. ''' schema = self._get_schema() serializer = s.CstMoveSerializer( diff --git a/rsconcept/frontend/src/backend/library.ts b/rsconcept/frontend/src/backend/library.ts index 7cae3309..b75aac44 100644 --- a/rsconcept/frontend/src/backend/library.ts +++ b/rsconcept/frontend/src/backend/library.ts @@ -24,7 +24,6 @@ import { } from './apiTransport'; export function getLibrary(request: FrontPull) { - // title: 'Available LibraryItems list', AxiosGet({ endpoint: '/api/library/active', request: request @@ -32,7 +31,6 @@ export function getLibrary(request: FrontPull) { } export function getAdminLibrary(request: FrontPull) { - // title: 'All LibraryItems list', AxiosGet({ endpoint: '/api/library/all', request: request @@ -95,23 +93,9 @@ export function patchSetLocation(target: string, request: FrontPush) { +export function patchSetEditors(target: string, request: FrontPush) { AxiosPatch({ - endpoint: `/api/library/${target}/editors-add`, - request: request - }); -} - -export function patchEditorsRemove(target: string, request: FrontPush) { - AxiosPatch({ - endpoint: `/api/library/${target}/editors-remove`, - request: request - }); -} - -export function patchEditorsSet(target: string, request: FrontPush) { - AxiosPatch({ - endpoint: `/api/library/${target}/editors-set`, + endpoint: `/api/library/${target}/set-editors`, request: request }); } diff --git a/rsconcept/frontend/src/backend/rsforms.ts b/rsconcept/frontend/src/backend/rsforms.ts index 8134d447..ce06313b 100644 --- a/rsconcept/frontend/src/backend/rsforms.ts +++ b/rsconcept/frontend/src/backend/rsforms.ts @@ -64,42 +64,42 @@ export function getTRSFile(target: string, version: string, request: FrontPull) { AxiosPost({ - endpoint: `/api/rsforms/${schema}/cst-create`, + endpoint: `/api/rsforms/${schema}/create-cst`, request: request }); } export function patchDeleteConstituenta(schema: string, request: FrontExchange) { AxiosPatch({ - endpoint: `/api/rsforms/${schema}/cst-delete-multiple`, + endpoint: `/api/rsforms/${schema}/delete-multiple-cst`, request: request }); } export function patchRenameConstituenta(schema: string, request: FrontExchange) { AxiosPatch({ - endpoint: `/api/rsforms/${schema}/cst-rename`, + endpoint: `/api/rsforms/${schema}/rename-cst`, request: request }); } export function patchProduceStructure(schema: string, request: FrontExchange) { AxiosPatch({ - endpoint: `/api/rsforms/${schema}/cst-produce-structure`, + endpoint: `/api/rsforms/${schema}/produce-structure`, request: request }); } export function patchSubstituteConstituents(schema: string, request: FrontExchange) { AxiosPatch({ - endpoint: `/api/rsforms/${schema}/cst-substitute`, + endpoint: `/api/rsforms/${schema}/substitute`, request: request }); } export function patchMoveConstituenta(schema: string, request: FrontExchange) { AxiosPatch({ - endpoint: `/api/rsforms/${schema}/cst-moveto`, + endpoint: `/api/rsforms/${schema}/move-cst`, request: request }); } diff --git a/rsconcept/frontend/src/context/OssContext.tsx b/rsconcept/frontend/src/context/OssContext.tsx index da041282..b496ce2e 100644 --- a/rsconcept/frontend/src/context/OssContext.tsx +++ b/rsconcept/frontend/src/context/OssContext.tsx @@ -5,9 +5,9 @@ import { createContext, useCallback, useContext, useMemo, useState } from 'react import { DataCallback } from '@/backend/apiTransport'; import { deleteUnsubscribe, - patchEditorsSet, patchLibraryItem, patchSetAccessPolicy, + patchSetEditors, patchSetLocation, patchSetOwner, postSubscribe @@ -236,7 +236,7 @@ export const OssState = ({ itemID, children }: OssStateProps) => { return; } setProcessingError(undefined); - patchEditorsSet(itemID, { + patchSetEditors(itemID, { data: { users: newEditors }, diff --git a/rsconcept/frontend/src/context/RSFormContext.tsx b/rsconcept/frontend/src/context/RSFormContext.tsx index 3a193059..8a59b910 100644 --- a/rsconcept/frontend/src/context/RSFormContext.tsx +++ b/rsconcept/frontend/src/context/RSFormContext.tsx @@ -6,9 +6,9 @@ import { DataCallback } from '@/backend/apiTransport'; import { patchConstituenta } from '@/backend/constituents'; import { deleteUnsubscribe, - patchEditorsSet, patchLibraryItem, patchSetAccessPolicy, + patchSetEditors, patchSetLocation, patchSetOwner, postSubscribe @@ -309,7 +309,7 @@ export const RSFormState = ({ itemID, versionID, children }: RSFormStateProps) = return; } setProcessingError(undefined); - patchEditorsSet(itemID, { + patchSetEditors(itemID, { data: { users: newEditors },