diff --git a/arches_references/management/commands/packages.py b/arches_references/management/commands/packages.py index 902bc91..6825ac5 100644 --- a/arches_references/management/commands/packages.py +++ b/arches_references/management/commands/packages.py @@ -45,15 +45,15 @@ def import_controlled_lists(self, source): wb = openpyxl.load_workbook(source) with transaction.atomic(): for sheet in wb.sheetnames: - if sheet == "ControlledList": + if sheet == "List": created_instances_pks.extend( self.import_sheet_to_model(wb[sheet], List) ) - elif sheet == "ControlledListItem": + elif sheet == "ListItem": created_instances_pks.extend( self.import_sheet_to_model(wb[sheet], ListItem) ) - elif sheet == "ControlledListItemValue": + elif sheet == "ListItemValue": created_instances_pks.extend( self.import_sheet_to_model(wb[sheet], ListItemValue) ) @@ -146,7 +146,7 @@ def import_sheet_to_model(self, sheet, model): def export_controlled_lists(self, data_dest, file_name): wb = openpyxl.Workbook() ws = wb.active - ws.title = "ControlledList" + ws.title = "List" self.export_model_to_sheet(ws, List) self.export_model_to_sheet(wb, ListItem) self.export_model_to_sheet(wb, ListItemValue) @@ -155,14 +155,14 @@ def export_controlled_lists(self, data_dest, file_name): # data_dest = os.path.dirname(settings.SYSTEM_SETTINGS_LOCAL_PATH) if data_dest != "" and data_dest != ".": wb.save(os.path.join(data_dest, file_name)) - self.stdout.write("Data exported successfully to controlled_lists.xlsx") + self.stdout.write(f"Data exported successfully to {file_name}") else: self.stdout.write( "No destination directory specified. Please rerun this command with the '-d' parameter populated." ) def export_model_to_sheet(self, wb, model): - # For the first sheet (ControlledList), use blank sheet that is initiallized with workbook + # For the first sheet (List), use blank sheet that is initiallized with workbook # otherwise, append a new sheet if isinstance(wb, openpyxl.worksheet.worksheet.Worksheet): ws = wb diff --git a/arches_references/search_indexes/sample_index.py b/arches_references/search_indexes/sample_index.py deleted file mode 100644 index cd9c1e8..0000000 --- a/arches_references/search_indexes/sample_index.py +++ /dev/null @@ -1,20 +0,0 @@ -from arches.app.search.base_index import BaseIndex - - -class SampleIndex(BaseIndex): - def prepare_index(self): - self.index_metadata = { - "mappings": { - "properties": { - "tile_count": {"type": "keyword"}, - "graph_id": {"type": "keyword"}, - } - } - } - super(SampleIndex, self).prepare_index() - - def get_documents_to_index(self, resourceinstance, tiles): - return ( - {"tile_count": len(tiles), "graph_id": resourceinstance.graph_id}, - str(resourceinstance.resourceinstanceid), - ) diff --git a/arches_references/settings.py b/arches_references/settings.py index fadbf68..ad1719d 100644 --- a/arches_references/settings.py +++ b/arches_references/settings.py @@ -140,6 +140,7 @@ "corsheaders", "oauth2_provider", "django_celery_results", + "arches_vue_utils", # "silk", ) diff --git a/arches_references/src/arches_references/components/ControlledListsMain.vue b/arches_references/src/arches_references/components/ControlledListsMain.vue index 6f17bc6..a30b7ac 100644 --- a/arches_references/src/arches_references/components/ControlledListsMain.vue +++ b/arches_references/src/arches_references/components/ControlledListsMain.vue @@ -17,7 +17,7 @@ import ListHeader from "@/arches_references/components/misc/ListHeader.vue"; import MainSplitter from "@/arches_references/components/MainSplitter.vue"; import type { Ref } from "vue"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { Selectable } from "@/arches_references/types"; const router = useRouter(); diff --git a/arches_references/src/arches_references/components/editor/AddValue.vue b/arches_references/src/arches_references/components/editor/AddValue.vue index 8f8f07e..f41866f 100644 --- a/arches_references/src/arches_references/components/editor/AddValue.vue +++ b/arches_references/src/arches_references/components/editor/AddValue.vue @@ -16,7 +16,7 @@ import { import { dataIsNew, shouldUseContrast } from "@/arches_references/utils.ts"; import type { Ref } from "vue"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { ControlledListItem, Value, diff --git a/arches_references/src/arches_references/components/editor/ItemHeader.vue b/arches_references/src/arches_references/components/editor/ItemHeader.vue index c4d95f6..b65feb8 100644 --- a/arches_references/src/arches_references/components/editor/ItemHeader.vue +++ b/arches_references/src/arches_references/components/editor/ItemHeader.vue @@ -7,7 +7,7 @@ import { bestLabel } from "@/arches_references/utils.ts"; import LetterCircle from "@/arches_references/components/misc/LetterCircle.vue"; import type { Ref } from "vue"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { ControlledListItem } from "@/arches_references/types"; const selectedLanguage = inject(selectedLanguageKey) as Ref; diff --git a/arches_references/src/arches_references/components/misc/ListHeader.vue b/arches_references/src/arches_references/components/misc/ListHeader.vue index 05da62c..38cf6c8 100644 --- a/arches_references/src/arches_references/components/misc/ListHeader.vue +++ b/arches_references/src/arches_references/components/misc/ListHeader.vue @@ -9,7 +9,7 @@ import { import { bestLabel, dataIsList } from "@/arches_references/utils.ts"; import type { Ref } from "vue"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { ControlledList, ControlledListItem, diff --git a/arches_references/src/arches_references/components/tree/ActionBanner.vue b/arches_references/src/arches_references/components/tree/ActionBanner.vue index 3342930..dc003ce 100644 --- a/arches_references/src/arches_references/components/tree/ActionBanner.vue +++ b/arches_references/src/arches_references/components/tree/ActionBanner.vue @@ -14,7 +14,7 @@ import { bestLabel, shouldUseContrast } from "@/arches_references/utils.ts"; import type { Ref } from "vue"; import type { TreeSelectionKeys } from "primevue/tree"; import type { TreeNode } from "primevue/treenode"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; const isMultiSelecting = defineModel("isMultiSelecting", { required: true, diff --git a/arches_references/src/arches_references/components/tree/AddDeleteControls.vue b/arches_references/src/arches_references/components/tree/AddDeleteControls.vue index 84d49c1..b3b7cc4 100644 --- a/arches_references/src/arches_references/components/tree/AddDeleteControls.vue +++ b/arches_references/src/arches_references/components/tree/AddDeleteControls.vue @@ -31,7 +31,7 @@ import { import type { Ref } from "vue"; import type { TreeSelectionKeys } from "primevue/tree"; import type { TreeNode } from "primevue/treenode"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { ControlledList, ControlledListItem, diff --git a/arches_references/src/arches_references/components/tree/ListTree.vue b/arches_references/src/arches_references/components/tree/ListTree.vue index 486db9e..b46b3ee 100644 --- a/arches_references/src/arches_references/components/tree/ListTree.vue +++ b/arches_references/src/arches_references/components/tree/ListTree.vue @@ -24,7 +24,7 @@ import type { RouteLocationNormalizedLoadedGeneric } from "vue-router"; import type { TreePassThroughMethodOptions } from "primevue/tree"; import type { TreeExpandedKeys, TreeSelectionKeys } from "primevue/tree"; import type { TreeNode } from "primevue/treenode"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { ControlledList, ControlledListItem, diff --git a/arches_references/src/arches_references/components/tree/MoveRow.vue b/arches_references/src/arches_references/components/tree/MoveRow.vue index e20319e..7e8efa1 100644 --- a/arches_references/src/arches_references/components/tree/MoveRow.vue +++ b/arches_references/src/arches_references/components/tree/MoveRow.vue @@ -29,7 +29,7 @@ import { import type { Ref } from "vue"; import type { TreeExpandedKeys, TreeSelectionKeys } from "primevue/tree"; import type { TreeNode } from "primevue/treenode"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { ControlledList, ControlledListItem, diff --git a/arches_references/src/arches_references/components/tree/PresentationControls.vue b/arches_references/src/arches_references/components/tree/PresentationControls.vue index 0623c1c..99aa74a 100644 --- a/arches_references/src/arches_references/components/tree/PresentationControls.vue +++ b/arches_references/src/arches_references/components/tree/PresentationControls.vue @@ -14,7 +14,7 @@ import { import { shouldUseContrast } from "@/arches_references/utils.ts"; import type { Ref } from "vue"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; const { $gettext } = useGettext(); diff --git a/arches_references/src/arches_references/components/tree/TreeRow.vue b/arches_references/src/arches_references/components/tree/TreeRow.vue index 6d74e13..45b9973 100644 --- a/arches_references/src/arches_references/components/tree/TreeRow.vue +++ b/arches_references/src/arches_references/components/tree/TreeRow.vue @@ -36,7 +36,7 @@ import MoveRow from "@/arches_references/components/tree/MoveRow.vue"; import type { Ref } from "vue"; import type { TreeExpandedKeys, TreeSelectionKeys } from "primevue/tree"; import type { TreeNode } from "primevue/treenode"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { ControlledList, ControlledListItem, diff --git a/arches_references/src/arches_references/constants.ts b/arches_references/src/arches_references/constants.ts index 1ebc673..b656c3b 100644 --- a/arches_references/src/arches_references/constants.ts +++ b/arches_references/src/arches_references/constants.ts @@ -1,5 +1,5 @@ import type { InjectionKey, Ref } from "vue"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { ControlledList, ControlledListItem, diff --git a/arches_references/src/arches_references/utils.ts b/arches_references/src/arches_references/utils.ts index 31fa110..dc25f8f 100644 --- a/arches_references/src/arches_references/utils.ts +++ b/arches_references/src/arches_references/utils.ts @@ -1,7 +1,7 @@ import arches from "arches"; import type { TreeNode } from "primevue/treenode"; -import type { Language } from "@/arches/types"; +import type { Language } from "@/arches_vue_utils/types"; import type { ControlledList, ControlledListItem, diff --git a/pyproject.toml b/pyproject.toml index 98a6279..faa6d36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ classifiers = [ requires-python = ">=3.10" dependencies = [ "arches @ git+https://github.com/archesproject/arches.git@dev/8.0.x", + "arches-vue-utils @ git+https://github.com/archesproject/arches-vue-utils.git@main", ] version = "0.0.1" diff --git a/tests/cli_tests.py b/tests/cli_tests.py index 4b1fb72..3cff831 100644 --- a/tests/cli_tests.py +++ b/tests/cli_tests.py @@ -59,8 +59,10 @@ def test_import_controlled_list(self): source=input_file, stdout=output, ) - list_pk = "e962bdaf-8243-4fbb-bd43-39bc1f54c168" - self.assertTrue(List.objects.filter(pk=list_pk).exists()) + + self.assertEqual(List.objects.all().count(), 2) + self.assertEqual(ListItem.objects.all().count(), 10) + self.assertEqual(ListItemValue.objects.all().count(), 21) ### TODO Add test for creating new language if language code not in db but found in import file diff --git a/tests/fixtures/data/controlled_lists.xlsx b/tests/fixtures/data/controlled_lists.xlsx index 08840eb..8f6885e 100644 Binary files a/tests/fixtures/data/controlled_lists.xlsx and b/tests/fixtures/data/controlled_lists.xlsx differ