From 6399e8e8391aed1229b2d1a986954ed8ba5c68fe Mon Sep 17 00:00:00 2001 From: Johnathan Clementi Date: Thu, 2 Jan 2025 15:49:58 -0500 Subject: [PATCH] Add resource instance nodes to scheme label form #147 --- arches_lingo/serializers.py | 16 ++++ arches_lingo/src/arches_lingo/api.ts | 14 ++++ .../components/generic/LabelEditor.vue | 74 ++++++++++++++++--- arches_lingo/templates/arches_urls.htm | 2 + arches_lingo/urls.py | 12 +++ arches_lingo/views/api/pythonic_models.py | 16 +++- 6 files changed, 122 insertions(+), 12 deletions(-) diff --git a/arches_lingo/serializers.py b/arches_lingo/serializers.py index 59d0dc19..26bf149a 100644 --- a/arches_lingo/serializers.py +++ b/arches_lingo/serializers.py @@ -88,3 +88,19 @@ class Meta: graph_slug = "concept" nodegroups = "__all__" fields = "__all__" + + +class PersonRdmSystemSerializer(ArchesModelSerializer): + class Meta: + model = ResourceInstance + graph_slug = "person" + nodegroups = "__all__" + fields = "__all__" + + +class GroupRdmSystemSerializer(ArchesModelSerializer): + class Meta: + model = ResourceInstance + graph_slug = "group" + nodegroups = "__all__" + fields = "__all__" diff --git a/arches_lingo/src/arches_lingo/api.ts b/arches_lingo/src/arches_lingo/api.ts index 3070d011..45afef2d 100644 --- a/arches_lingo/src/arches_lingo/api.ts +++ b/arches_lingo/src/arches_lingo/api.ts @@ -53,6 +53,20 @@ export const fetchTextualWorkRdmSystemList = async () => { return parsed; }; +export const fetchGroupRdmSystemList = async () => { + const response = await fetch(arches.urls.api_group_list); + const parsed = await response.json(); + if (!response.ok) throw new Error(parsed.message || response.statusText); + return parsed; +}; + +export const fetchPersonRdmSystemList = async () => { + const response = await fetch(arches.urls.api_person_list); + const parsed = await response.json(); + if (!response.ok) throw new Error(parsed.message || response.statusText); + return parsed; +}; + export const fetchSchemeCreation = async (schemeId: string) => { const response = await fetch(arches.urls.api_scheme_creation(schemeId)); const parsed = await response.json(); diff --git a/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue b/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue index 82c5df9d..65d8ac70 100644 --- a/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue +++ b/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue @@ -1,12 +1,18 @@ @@ -125,10 +165,22 @@ onMounted(async () => { - + - + {% endblock arches_urls %} diff --git a/arches_lingo/urls.py b/arches_lingo/urls.py index a872f550..deb23edb 100644 --- a/arches_lingo/urls.py +++ b/arches_lingo/urls.py @@ -10,6 +10,8 @@ ConceptListCreateView, ConceptStatementDetailView, ConceptStatementListCreateView, + GroupRdmSystemSerializerView, + PersonRdmSystemSerializerView, SchemeCreationView, SchemeDetailView, SchemeLabelTileView, @@ -83,6 +85,16 @@ TextualWorkRdmSystemSerializerView.as_view(), name="api-textualwork-list", ), + path( + "api/group-rdm-system", + GroupRdmSystemSerializerView.as_view(), + name="api-group-list", + ), + path( + "api/person-rdm-system", + PersonRdmSystemSerializerView.as_view(), + name="api-person-list", + ), path( "api/scheme/statements", SchemeStatementListCreateView.as_view(), diff --git a/arches_lingo/views/api/pythonic_models.py b/arches_lingo/views/api/pythonic_models.py index 439da420..9d5643b4 100644 --- a/arches_lingo/views/api/pythonic_models.py +++ b/arches_lingo/views/api/pythonic_models.py @@ -9,6 +9,9 @@ from arches_lingo.serializers import ( ConceptSerializer, + ConceptStatementSerializer, + GroupRdmSystemSerializer, + PersonRdmSystemSerializer, SchemeCreationSerializer, SchemeLabelSerializer, SchemeLabelTileSerializer, @@ -16,7 +19,6 @@ SchemeNoteSerializer, SchemeNoteTileSerializer, SchemeSerializer, - ConceptStatementSerializer, SchemeStatementSerializer, TextualWorkRdmSystemSerializer, ) @@ -84,6 +86,18 @@ class TextualWorkRdmSystemSerializerView(ArchesModelAPIMixin, ListAPIView): pagination_class = None +class GroupRdmSystemSerializerView(ArchesModelAPIMixin, ListAPIView): + permission_classes = [RDMAdministrator] + serializer_class = GroupRdmSystemSerializer + pagination_class = None + + +class PersonRdmSystemSerializerView(ArchesModelAPIMixin, ListAPIView): + permission_classes = [RDMAdministrator] + serializer_class = PersonRdmSystemSerializer + pagination_class = None + + class ConceptDetailView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView): permission_classes = [RDMAdministrator] serializer_class = ConceptSerializer