mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
Refactoring: endpoint naming unifications
This commit is contained in:
parent
f36924d0e9
commit
8a4b75c1bf
|
@ -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
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -24,7 +24,6 @@ import {
|
|||
} from './apiTransport';
|
||||
|
||||
export function getLibrary(request: FrontPull<ILibraryItem[]>) {
|
||||
// title: 'Available LibraryItems list',
|
||||
AxiosGet({
|
||||
endpoint: '/api/library/active',
|
||||
request: request
|
||||
|
@ -32,7 +31,6 @@ export function getLibrary(request: FrontPull<ILibraryItem[]>) {
|
|||
}
|
||||
|
||||
export function getAdminLibrary(request: FrontPull<ILibraryItem[]>) {
|
||||
// title: 'All LibraryItems list',
|
||||
AxiosGet({
|
||||
endpoint: '/api/library/all',
|
||||
request: request
|
||||
|
@ -95,23 +93,9 @@ export function patchSetLocation(target: string, request: FrontPush<ITargetLocat
|
|||
});
|
||||
}
|
||||
|
||||
export function patchEditorsAdd(target: string, request: FrontPush<ITargetUser>) {
|
||||
export function patchSetEditors(target: string, request: FrontPush<ITargetUsers>) {
|
||||
AxiosPatch({
|
||||
endpoint: `/api/library/${target}/editors-add`,
|
||||
request: request
|
||||
});
|
||||
}
|
||||
|
||||
export function patchEditorsRemove(target: string, request: FrontPush<ITargetUser>) {
|
||||
AxiosPatch({
|
||||
endpoint: `/api/library/${target}/editors-remove`,
|
||||
request: request
|
||||
});
|
||||
}
|
||||
|
||||
export function patchEditorsSet(target: string, request: FrontPush<ITargetUsers>) {
|
||||
AxiosPatch({
|
||||
endpoint: `/api/library/${target}/editors-set`,
|
||||
endpoint: `/api/library/${target}/set-editors`,
|
||||
request: request
|
||||
});
|
||||
}
|
||||
|
|
|
@ -64,42 +64,42 @@ export function getTRSFile(target: string, version: string, request: FrontPull<B
|
|||
|
||||
export function postCreateConstituenta(schema: string, request: FrontExchange<ICstCreateData, ICstCreatedResponse>) {
|
||||
AxiosPost({
|
||||
endpoint: `/api/rsforms/${schema}/cst-create`,
|
||||
endpoint: `/api/rsforms/${schema}/create-cst`,
|
||||
request: request
|
||||
});
|
||||
}
|
||||
|
||||
export function patchDeleteConstituenta(schema: string, request: FrontExchange<IConstituentaList, IRSFormData>) {
|
||||
AxiosPatch({
|
||||
endpoint: `/api/rsforms/${schema}/cst-delete-multiple`,
|
||||
endpoint: `/api/rsforms/${schema}/delete-multiple-cst`,
|
||||
request: request
|
||||
});
|
||||
}
|
||||
|
||||
export function patchRenameConstituenta(schema: string, request: FrontExchange<ICstRenameData, ICstCreatedResponse>) {
|
||||
AxiosPatch({
|
||||
endpoint: `/api/rsforms/${schema}/cst-rename`,
|
||||
endpoint: `/api/rsforms/${schema}/rename-cst`,
|
||||
request: request
|
||||
});
|
||||
}
|
||||
|
||||
export function patchProduceStructure(schema: string, request: FrontExchange<ITargetCst, IProduceStructureResponse>) {
|
||||
AxiosPatch({
|
||||
endpoint: `/api/rsforms/${schema}/cst-produce-structure`,
|
||||
endpoint: `/api/rsforms/${schema}/produce-structure`,
|
||||
request: request
|
||||
});
|
||||
}
|
||||
|
||||
export function patchSubstituteConstituents(schema: string, request: FrontExchange<ICstSubstituteData, IRSFormData>) {
|
||||
AxiosPatch({
|
||||
endpoint: `/api/rsforms/${schema}/cst-substitute`,
|
||||
endpoint: `/api/rsforms/${schema}/substitute`,
|
||||
request: request
|
||||
});
|
||||
}
|
||||
|
||||
export function patchMoveConstituenta(schema: string, request: FrontExchange<ICstMovetoData, IRSFormData>) {
|
||||
AxiosPatch({
|
||||
endpoint: `/api/rsforms/${schema}/cst-moveto`,
|
||||
endpoint: `/api/rsforms/${schema}/move-cst`,
|
||||
request: request
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user