Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scheme rights form/report, #151 #180

Merged
merged 35 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
483a947
Add right holder to scheme rights, #151
njkim Dec 20, 2024
0f8719e
Make id consistent, #151
njkim Dec 21, 2024
4d4e8a7
Add right type, #151
njkim Dec 21, 2024
db6371a
Add schem right editor, #151
njkim Jan 9, 2025
dc4ffc3
nit, #151
njkim Jan 9, 2025
845b6f0
Add constance, #151
njkim Jan 9, 2025
fd7ab5a
Add statement report, #151
njkim Jan 12, 2025
abeab6a
Draft scheme statement, #151
njkim Jan 15, 2025
636a63e
Fix create function, #151
njkim Jan 15, 2025
1268f49
nit, #151
njkim Jan 16, 2025
c90620b
Rename variables for consistency, #151
njkim Jan 17, 2025
79a9a92
Fix scheme rights statement, #151
njkim Jan 22, 2025
31a8dac
Fix url path, #151
njkim Jan 22, 2025
adb4b91
Replace hardcoded concept ids, #151
njkim Jan 22, 2025
59b7640
nit, #151
njkim Jan 23, 2025
64970e9
Simplify the frontend, #151
njkim Jan 23, 2025
4c2a025
Update statement var, #151
njkim Jan 23, 2025
c29afcf
experiment with create() method
jacobtylerwalls Jan 24, 2025
bfcc3f4
Refactor init funcs, #151
njkim Jan 24, 2025
16e69d9
Use resource serializer for creates and updates (like label editor)
jacobtylerwalls Jan 24, 2025
5cf1365
Update fronted using a new serializer, #151
njkim Jan 24, 2025
b7761f6
nit, #151
njkim Jan 25, 2025
efbff0f
nit, #151
njkim Jan 25, 2025
17feb55
nit, #151
njkim Jan 25, 2025
d31f731
nit, #151
njkim Jan 25, 2025
7502075
Add children to concept select, #151
njkim Jan 27, 2025
31df7bf
Fix node alias, #151
njkim Jan 27, 2025
f4ef8d6
Confirm the values are available, #151
njkim Jan 27, 2025
aba4784
Update the indentation, #151
njkim Jan 27, 2025
fc1f091
Specify the types in the editor, #151
njkim Jan 27, 2025
f19d170
Fix formatting, #151
njkim Jan 27, 2025
1e3fea9
nit, #151
njkim Jan 28, 2025
649e321
Refctor editor div & report div, #151
njkim Jan 28, 2025
e194870
nit, #151
njkim Jan 28, 2025
fb7f259
Fix formatting, #151
njkim Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions arches_lingo/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@ class Meta:
fields = "__all__"


class SchemeRightsSerializer(ArchesModelSerializer):
class Meta:
model = ResourceInstance
graph_slug = "scheme"
nodegroups = ["rights", "right_statement"]
fields = "__all__"

def update(self, instance, validated_data):
"""Repair parenttile until fixed in core."""
updated = super().update(instance, validated_data)
if updated.right_statement:
self.repair_right_statement(updated)
return updated

def repair_right_statement(self, instance):
# Shouldn't need to refresh_from_db() here, but I'll (jtw)
# look into that later, since this is all just a workaround.
instance.refresh_from_db()
instance.right_statement.parenttile = instance.rights
instance.right_statement.save()
return instance


class SchemeLabelSerializer(ArchesModelSerializer):
class Meta:
model = ResourceInstance
Expand Down
47 changes: 47 additions & 0 deletions arches_lingo/src/arches_lingo/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type {
AppellativeStatus,
SchemeInstance,
SchemeStatement,
SchemeRights,
SchemeRightStatement,
} from "@/arches_lingo/types";

function getToken() {
Expand Down Expand Up @@ -230,6 +232,13 @@ export const createScheme = async (newScheme: SchemeInstance) => {
return parsed;
};

export const fetchSchemeRights = async (schemeId: string) => {
const response = await fetch(arches.urls.api_scheme_rights(schemeId));
const parsed = await response.json();
if (!response.ok) throw new Error(parsed.message || response.statusText);
return parsed;
};

export const updateSchemeCreation = async (
schemeId: string,
schemeInstance: SchemeInstance,
Expand Down Expand Up @@ -264,6 +273,44 @@ export const updateSchemeNamespace = async (
return parsed;
};

export const createSchemeFromRights = async (
schemeRightsValue: SchemeInstance,
) => {
const response = await fetch(arches.urls.api_scheme_rights_list_create, {
method: "POST",
headers: {
"X-CSRFTOKEN": getToken(),
"Content-Type": "application/json",
},
body: JSON.stringify({ schemeRightsValue }),
});
const parsed = await response.json();
if (!response.ok) throw new Error(parsed.message || response.statusText);
return parsed;
};

export const updateSchemeRights = async (
schemeId: string,
schemeRightsValue: SchemeRights,
schemeRightStatementValue: SchemeRightStatement,
) => {
const response = await fetch(arches.urls.api_scheme_rights(schemeId), {
method: "PATCH",
headers: {
"X-CSRFTOKEN": getToken(),
"Content-Type": "application/json",
},
body: JSON.stringify({
resourceinstanceid: schemeId,
rights: schemeRightsValue,
right_statement: schemeRightStatementValue,
}),
});
const parsed = await response.json();
if (!response.ok) throw new Error(parsed.message || response.statusText);
return parsed;
};

export const fetchSearchResults = async (
searchTerm: string,
items: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
import {
OPEN_EDITOR,
Expand Down Expand Up @@ -52,6 +53,11 @@ const schemeComponents = [
id: "note",
editorName: $gettext("Scheme Notes"),
},
{
component: SchemeLicense,
id: "license",
editorName: $gettext("Scheme Rights"),
},
];

watch(
Expand Down
Loading
Loading