diff --git a/arches_lingo/serializers.py b/arches_lingo/serializers.py index 9b048254..551aa39f 100644 --- a/arches_lingo/serializers.py +++ b/arches_lingo/serializers.py @@ -40,6 +40,15 @@ class Meta: nodegroups = ["rights"] fields = "__all__" + +class SchemeRightsTileSerializer(ArchesTileSerializer): + class Meta: + model = TileModel + graph_slug = "scheme" + root_node = "rights" + fields = "__all__" + + class SchemeLabelSerializer(ArchesModelSerializer): class Meta: model = ResourceInstance diff --git a/arches_lingo/src/arches_lingo/api.ts b/arches_lingo/src/arches_lingo/api.ts index 21d95bb5..02c6b9f6 100644 --- a/arches_lingo/src/arches_lingo/api.ts +++ b/arches_lingo/src/arches_lingo/api.ts @@ -1,6 +1,6 @@ import arches from "arches"; import Cookies from "js-cookie"; -import type { AppellativeStatus, SchemeInstance } from "@/arches_lingo/types"; +import type { AppellativeStatus, SchemeInstance, SchemeRights } from "@/arches_lingo/types"; function getToken() { const token = Cookies.get("csrftoken"); @@ -225,15 +225,16 @@ export const updateSchemeNamespace = async ( export const updateSchemeRights = async ( schemeId: string, - schemeRights: SchemeInstance, + tileId: string, + schemeRightsValue: SchemeRights, ) => { - const response = await fetch(arches.urls.api_scheme_rights(schemeId), { + const response = await fetch(arches.urls.api_scheme_rights_tile(schemeId, tileId), { method: "PATCH", headers: { "X-CSRFTOKEN": getToken(), "Content-Type": "application/json", }, - body: JSON.stringify(schemeRights), + body: JSON.stringify(schemeRightsValue), }); const parsed = await response.json(); if (!response.ok) throw new Error(parsed.message || response.statusText); diff --git a/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue b/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue index 89362b5d..34d5bd7a 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue @@ -6,6 +6,7 @@ import SchemeNamespace from "@/arches_lingo/components/scheme/report/SchemeNames import SchemeStandard from "@/arches_lingo/components/scheme/report/SchemeStandard.vue"; import SchemeLabel from "@/arches_lingo/components/scheme/report/SchemeLabel.vue"; import SchemeNote from "@/arches_lingo/components/scheme/report/SchemeNote.vue"; +import SchemeLicense from "@/arches_lingo/components/scheme/report/SchemeLicense.vue"; import type { SectionTypes } from "@/arches_lingo/types.ts"; const { $gettext } = useGettext(); @@ -48,7 +49,7 @@ const schemeComponents = [ { component: SchemeLicense, id: "license", - editorTabName: $gettext("Scheme Rights"), + editorName: $gettext("Scheme Rights"), }, ]; diff --git a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLicense.vue b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLicense.vue index 91bc9bf7..8dbe7784 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLicense.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLicense.vue @@ -1,40 +1,52 @@ @@ -103,33 +132,41 @@ const { $gettext } = useGettext();

{{ $gettext('Rights Holders') }}

{{ $gettext('Rights Type') }}

- +

{{ $gettext('Rights Holders') }}

{{ $gettext('Rights Type') }}

- + @update="(val) => onUpdateReferenceDatatype('right_type', val)" + /> +
diff --git a/arches_lingo/src/arches_lingo/constants.ts b/arches_lingo/src/arches_lingo/constants.ts index 703954f8..ba7c90eb 100644 --- a/arches_lingo/src/arches_lingo/constants.ts +++ b/arches_lingo/src/arches_lingo/constants.ts @@ -37,3 +37,4 @@ export const STATUSES_CONTROLLED_LIST = "2cc0e054-ef9b-41ae-8e86-e0c3b4e7ca00"; export const METATYPES_CONTROLLED_LIST = "ef69e772-de53-45fe-98d4-bf3e7b10eb57"; export const EVENT_TYPES_CONTROLLED_LIST = "6eaa2c6f-af83-464c-9200-051c4cfe7e8e"; +export const RIGHT_TYPE_CONTROLLED_LIST = "1c950e16-3fcf-4f33-9e5e-ce5c6c992cca"; diff --git a/arches_lingo/src/arches_lingo/types.ts b/arches_lingo/src/arches_lingo/types.ts index 56e2542d..32f0ce14 100644 --- a/arches_lingo/src/arches_lingo/types.ts +++ b/arches_lingo/src/arches_lingo/types.ts @@ -129,6 +129,12 @@ export interface SchemeStatement { statement_data_assignment_actor: ResourceInstanceReference[]; } +export interface SchemeRights { + tileid: string; + right_holder?: ResourceInstanceReference[]; + right_type?: ControlledListItem[]; +} + export interface SchemeInstance { namespace?: { namespace_name: string; @@ -139,10 +145,7 @@ export interface SchemeInstance { }; appellative_status?: AppellativeStatus[]; statement?: SchemeStatement[]; - rights?: { - right_holder: ResourceInstanceReference[]; - right_type: ControlledListItem[]; - }; + rights?: SchemeRights; } export interface SchemeResource { diff --git a/arches_lingo/templates/arches_urls.htm b/arches_lingo/templates/arches_urls.htm index 9cb5e955..8a20a627 100644 --- a/arches_lingo/templates/arches_urls.htm +++ b/arches_lingo/templates/arches_urls.htm @@ -21,5 +21,7 @@ api_group_list="{% url 'api-group-list' %}" api_person_list="{% url 'api-person-list' %}" api_scheme_rights='(pluginid)=>{return "{% url "api-scheme-rights" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" %}".replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", pluginid)}' + api_scheme_rights='(resourceid)=>{return "{% url "api-scheme-rights" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" %}".replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", resourceid)}' + api_scheme_rights_tile='(resourceid, tileid)=>{return "{% url "api-scheme-rights-tile" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab"%}".replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", resourceid).replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab", tileid)}' > {% endblock arches_urls %} diff --git a/arches_lingo/urls.py b/arches_lingo/urls.py index 370a6c23..cff0b584 100644 --- a/arches_lingo/urls.py +++ b/arches_lingo/urls.py @@ -14,6 +14,7 @@ PersonRdmSystemSerializerView, SchemeCreationView, SchemeRightsView, + SchemeRightsTileView, SchemeDetailView, SchemeLabelTileView, SchemeLabelView, @@ -69,6 +70,11 @@ SchemeRightsView.as_view(), name="api-scheme-rights", ), + path( + "api/scheme//rights/", + SchemeRightsTileView.as_view(), + name="api-scheme-rights-tile", + ), path( "api/scheme//label", SchemeLabelView.as_view(), diff --git a/arches_lingo/views/api/pythonic_models.py b/arches_lingo/views/api/pythonic_models.py index 30a32601..ba38f902 100644 --- a/arches_lingo/views/api/pythonic_models.py +++ b/arches_lingo/views/api/pythonic_models.py @@ -19,6 +19,8 @@ SchemeNoteSerializer, SchemeNoteTileSerializer, SchemeSerializer, + SchemeRightsSerializer, + SchemeRightsTileSerializer, SchemeStatementSerializer, TextualWorkRdmSystemSerializer, GroupRdmSystemSerializer, @@ -67,6 +69,12 @@ class SchemeRightsView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView): permission_classes = [RDMAdministrator] serializer_class = SchemeRightsSerializer + +class SchemeRightsTileView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView): + permission_classes = [RDMAdministrator] + serializer_class = SchemeRightsTileSerializer + + class SchemeLabelView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView): permission_classes = [RDMAdministrator] serializer_class = SchemeLabelSerializer