diff --git a/.github/actions/build-and-test-branch/action.yml b/.github/actions/build-and-test-branch/action.yml index db4b8980..a9c7cdc9 100644 --- a/.github/actions/build-and-test-branch/action.yml +++ b/.github/actions/build-and-test-branch/action.yml @@ -31,27 +31,16 @@ runs: echo Python packages installed shell: bash + - name: Ensure frontend configuration files exist + run: | + python manage.py check + shell: bash + - name: Install Arches applications uses: ./.github/actions/install-arches-applications with: secrets: ${{ inputs.secrets }} - - name: Checkout into feature branch - if: inputs.branch-type == 'feature' - uses: actions/checkout@v4 - with: - repository: ${{ github.repository }} - ref: ${{ github.ref }} - path: . - - - name: Checkout into target branch - if: inputs.branch-type == 'target' - uses: actions/checkout@v4 - with: - repository: ${{ github.repository }} - ref: ${{ github.event.pull_request.base.ref }} - path: . - - name: Install frontend dependencies run: | npm install diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 849d09a0..3aaac8ea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: jobs: - build_feature_branch: + build_target_branch: runs-on: ubuntu-latest services: @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.12"] steps: - uses: actions/checkout@v4 @@ -33,14 +33,21 @@ jobs: python-version: ${{ matrix.python-version }} check-latest: true + - name: Checkout into target branch + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + ref: ${{ github.event.pull_request.base.ref }} + path: . + - name: Build and test branch uses: ./.github/actions/build-and-test-branch with: secrets: ${{ toJSON(secrets) }} project-name: 'arches_lingo' - branch-type: 'feature' + branch-type: 'target' - build_target_branch: + build_feature_branch: runs-on: ubuntu-latest services: @@ -56,7 +63,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.12"] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 @@ -67,12 +74,19 @@ jobs: python-version: ${{ matrix.python-version }} check-latest: true + - name: Checkout into feature branch + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + ref: ${{ github.ref }} + path: . + - name: Build and test branch uses: ./.github/actions/build-and-test-branch with: secrets: ${{ toJSON(secrets) }} project-name: 'arches_lingo' - branch-type: 'target' + branch-type: 'feature' check_frontend_coverage: runs-on: ubuntu-latest @@ -255,4 +269,4 @@ jobs: exit 1 else echo "Feature branch coverage ($feature_branch_python_coverage%) >= Target branch coverage ($target_branch_python_coverage%)." - fi + fi \ No newline at end of file diff --git a/arches_lingo/apps.py b/arches_lingo/apps.py index 258a01be..fba8aa47 100644 --- a/arches_lingo/apps.py +++ b/arches_lingo/apps.py @@ -1,7 +1,14 @@ from django.apps import AppConfig +from django.conf import settings +from arches.settings_utils import generate_frontend_configuration -class Arches_LingoConfig(AppConfig): + +class ArchesLingoConfig(AppConfig): name = "arches_lingo" verbose_name = "Arches Lingo" is_arches_application = True + + def ready(self): + if settings.APP_NAME.lower() == self.name: + generate_frontend_configuration() diff --git a/arches_lingo/install/requirements.txt b/arches_lingo/install/requirements.txt deleted file mode 100644 index 206ad43b..00000000 --- a/arches_lingo/install/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -arches>=7.6.0a1 \ No newline at end of file diff --git a/arches_lingo/install/requirements_dev.txt b/arches_lingo/install/requirements_dev.txt deleted file mode 100644 index 80981ab4..00000000 --- a/arches_lingo/install/requirements_dev.txt +++ /dev/null @@ -1,6 +0,0 @@ -livereload -sst -coverage -django-silk==5.1.0 -pre-commit -black==24.4.2 diff --git a/arches_lingo/media/js/views/components/plugins/reference-data-manager.js b/arches_lingo/media/js/views/components/plugins/reference-data-manager.js deleted file mode 100644 index b1fbe587..00000000 --- a/arches_lingo/media/js/views/components/plugins/reference-data-manager.js +++ /dev/null @@ -1,14 +0,0 @@ -import ko from 'knockout'; -import { createApp } from 'vue'; -import PrimeVue from 'primevue/config'; -import RDMApp from '@/App.vue'; -import RDMAppTepmlate from 'templates/views/components/plugins/reference-data-manager.htm'; - -ko.components.register('reference-data-manager', { - viewModel: function() { - const app = createApp(RDMApp); - app.use(PrimeVue); - app.mount('#rdm-mounting-point'); - }, - template: RDMAppTepmlate, -}); \ No newline at end of file diff --git a/arches_lingo/media/js/views/root.js b/arches_lingo/media/js/views/root.js new file mode 100644 index 00000000..01a6d364 --- /dev/null +++ b/arches_lingo/media/js/views/root.js @@ -0,0 +1,6 @@ +import LingoApp from '@/arches_lingo/App.vue'; +import createVueApplication from 'arches/arches/app/media/js/utils/create-vue-application'; + +createVueApplication(LingoApp).then(vueApp => { + vueApp.mount('#lingo-mounting-point'); +}); diff --git a/arches_lingo/migrations/0001_initial.py b/arches_lingo/migrations/0001_initial.py deleted file mode 100644 index 987ebe6f..00000000 --- a/arches_lingo/migrations/0001_initial.py +++ /dev/null @@ -1,39 +0,0 @@ -from arches.app.models import models - - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ("models", "10121_workflowhistory"), - ] - - def add_plugins(apps, schema_editor): - Plugin = apps.get_model("models", "Plugin") - - Plugin.objects.update_or_create( - pluginid="29321ce0-bd95-4357-a2a5-822e9cb06f70", - name="Reference Data Manager (RDM)", - icon="fa fa-code-fork", - component="views/components/plugins/reference-data-manager", - componentname="reference-data-manager", - config={}, - slug="reference-data-manager", - sortorder=0, - ) - - def remove_plugin(apps, schema_editor): - Plugin = apps.get_model("models", "Plugin") - - for plugin in Plugin.objects.filter( - pluginid__in=["29321ce0-bd95-4357-a2a5-822e9cb06f70"] - ): - plugin.delete() - - operations = [ - migrations.RunPython(add_plugins, remove_plugin), - ] diff --git a/arches_lingo/settings.py b/arches_lingo/settings.py index 0e3dfc66..0b31de25 100644 --- a/arches_lingo/settings.py +++ b/arches_lingo/settings.py @@ -135,7 +135,6 @@ "django.contrib.staticfiles", "django.contrib.gis", "django_hosts", - "arches_references", "arches", "arches.app.models", "arches.management", @@ -145,6 +144,7 @@ "corsheaders", "oauth2_provider", "django_celery_results", + "arches_references", # "silk", ) @@ -425,6 +425,9 @@ # override this to permenantly display/hide the language switcher SHOW_LANGUAGE_SWITCH = len(LANGUAGES) > 1 +# TODO: remove when finalizing release +SILENCED_SYSTEM_CHECKS += ["arches.E002"] + try: from .package_settings import * except ImportError: @@ -440,7 +443,3 @@ from settings_local import * except ImportError as e: pass - -# returns an output that can be read by NODEJS -if __name__ == "__main__": - transmit_webpack_django_config(**locals()) diff --git a/arches_lingo/src/App.vue b/arches_lingo/src/App.vue deleted file mode 100644 index d46924ff..00000000 --- a/arches_lingo/src/App.vue +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/arches_lingo/src/arches_lingo/App.vue b/arches_lingo/src/arches_lingo/App.vue new file mode 100644 index 00000000..e437fa1a --- /dev/null +++ b/arches_lingo/src/arches_lingo/App.vue @@ -0,0 +1,7 @@ + + + diff --git a/arches_lingo/src/components/FooComponent.vue b/arches_lingo/src/arches_lingo/components/FooComponent.vue similarity index 100% rename from arches_lingo/src/components/FooComponent.vue rename to arches_lingo/src/arches_lingo/components/FooComponent.vue diff --git a/arches_lingo/src/declarations.d.ts b/arches_lingo/src/declarations.d.ts index e03bbaa8..6e9a067d 100644 --- a/arches_lingo/src/declarations.d.ts +++ b/arches_lingo/src/declarations.d.ts @@ -1,10 +1,4 @@ -// import declarations from other projects or Arches core -import("../../node_modules/arches/arches/app/src/declarations.d.ts"); - // declare untyped modules that have been added to your project in `package.json` // Module homepage on npmjs.com uses logos "TS" or "DT" to indicate if typed -declare module "arches"; -// declare filetypes used in `./src/` folder -declare module "*.ts"; -declare module "*.vue"; +import("@/arches/declarations.d.ts"); diff --git a/arches_lingo/templates/arches_lingo/root.htm b/arches_lingo/templates/arches_lingo/root.htm new file mode 100644 index 00000000..d0bf82ed --- /dev/null +++ b/arches_lingo/templates/arches_lingo/root.htm @@ -0,0 +1,9 @@ +{% extends "base-root.htm" %} + +{% block title %} + +{% endblock title %} + +{% block body %} +
+{% endblock body %} diff --git a/arches_lingo/templates/views/components/plugins/reference-data-manager.htm b/arches_lingo/templates/views/components/plugins/reference-data-manager.htm deleted file mode 100644 index 76750ab4..00000000 --- a/arches_lingo/templates/views/components/plugins/reference-data-manager.htm +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/arches_lingo/test_settings.py b/arches_lingo/test_settings.py deleted file mode 100644 index 9555c26b..00000000 --- a/arches_lingo/test_settings.py +++ /dev/null @@ -1,34 +0,0 @@ -import os - -# Depends on /arches being on the python path, as arches.tests is not importable -from tests.test_settings import * - -APP_NAME = "arches_lingo" -APP_ROOT = os.path.dirname(__file__) -INSTALLED_APPS = ( - "webpack_loader", - "django.contrib.admin", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", - "django.contrib.gis", - "arches", - "arches.app.models", - "arches.management", - "guardian", - "captcha", - "revproxy", - "corsheaders", - "oauth2_provider", - "django_celery_results", - "arches_lingo", -) -ROOT_URLCONF = "arches_lingo.urls" - -LOCALE_PATHS = [os.path.join(APP_ROOT, "locale")] - -# Further settings may need to be added from project, just don't -# want to clobber anything from core test settings for now. -# Also, settings can be overridden directly. See @override_settings diff --git a/arches_lingo/urls.py b/arches_lingo/urls.py index f80a1b81..9717b611 100644 --- a/arches_lingo/urls.py +++ b/arches_lingo/urls.py @@ -3,9 +3,10 @@ from django.conf.urls.i18n import i18n_patterns from django.urls import include, path -from arches_lingo.views import ConceptTreeView +from arches_lingo.views import LingoRootView, ConceptTreeView urlpatterns = [ + path("", LingoRootView.as_view(), name="root"), path("concept_trees/", ConceptTreeView.as_view(), name="concept_trees"), path("", include("arches_references.urls")), ] diff --git a/arches_lingo/views.py b/arches_lingo/views.py index e605ed6a..945ee545 100644 --- a/arches_lingo/views.py +++ b/arches_lingo/views.py @@ -3,6 +3,8 @@ from django.contrib.postgres.expressions import ArraySubquery from django.db.models import CharField, F, OuterRef, Subquery, Value from django.db.models.expressions import CombinedExpression, Func +from django.shortcuts import render +from django.utils.translation import gettext_lazy as _ from django.utils.decorators import method_decorator from django.views.generic import View @@ -13,8 +15,8 @@ Value as ConceptValue, ) from arches.app.utils.decorators import group_required - from arches.app.utils.response import JSONResponse +from arches.app.views.base import BaseManagerView from arches_lingo.const import ( SCHEMES_GRAPH_ID, @@ -199,3 +201,10 @@ def get(self, request): } # Todo: filter by nodegroup permissions return JSONResponse(data) + + +class LingoRootView(BaseManagerView): + def get(self, request, graphid=None, resourceid=None): + context = self.get_context_data(main_script="views/root") + context["page_title"] = _("Lingo") + return render(request, "arches_lingo/root.htm", context) diff --git a/tests/search_indexes/__init__.py b/tests/search_indexes/__init__.py deleted file mode 100644 index 727eb9af..00000000 --- a/tests/search_indexes/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# these tests can be run from the command line via -# python manage.py test tests/views --pattern="*.py" --settings="tests.test_settings" diff --git a/tests/search_indexes/sample_index_tests.py b/tests/search_indexes/sample_index_tests.py deleted file mode 100644 index aca30235..00000000 --- a/tests/search_indexes/sample_index_tests.py +++ /dev/null @@ -1,37 +0,0 @@ -from unittest.mock import Mock - -from arches.app.search.base_index import BaseIndex -from arches_lingo.search_indexes.sample_index import SampleIndex -from django.test import TestCase - - -class TestSampleIndex(TestCase): - def test_prepare_index(self): - sample_index = SampleIndex(index_name="Sample Index") - sample_index.prepare_index() - - expected_index_metadata = { - "mappings": { - "properties": { - "tile_count": {"type": "keyword"}, - "graph_id": {"type": "keyword"}, - } - } - } - self.assertEqual(sample_index.index_metadata, expected_index_metadata) - - def test_get_documents_to_index(self): - sample_index = SampleIndex(index_name="Sample Index") - - mock_resourceinstance = Mock(graph_id="test_graph_id") - mock_tiles = [Mock(), Mock(), Mock()] # Mock tiles list - - documents, doc_id = sample_index.get_documents_to_index( - mock_resourceinstance, mock_tiles - ) - - self.assertEqual( - documents, - {"tile_count": len(mock_tiles), "graph_id": mock_resourceinstance.graph_id}, - ) - self.assertEqual(doc_id, str(mock_resourceinstance.resourceinstanceid)) diff --git a/tests/test_settings.py b/tests/test_settings.py index 9693188e..d901af69 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,53 +1,11 @@ -""" -ARCHES - a program developed to inventory and manage immovable cultural heritage. -Copyright (C) 2013 J. Paul Getty Trust and World Monuments Fund - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -""" - -from arches.settings import * -import arches import os -try: - from django.utils.translation import gettext_lazy as _ -except ImportError: # unable to import prior to installing requirements.txt in setup.py - pass +from arches_lingo.settings import * PACKAGE_NAME = "arches_lingo" -APP_NAME = "arches_lingo" - -APP_ROOT = os.path.dirname(__file__) -TEST_ROOT = os.path.normpath(os.path.join(ROOT_DIR, "..", "tests")) - -ROOT_URLCONF = "arches_lingo.urls" - -ARCHES_APPLICATIONS = () - -MIN_ARCHES_VERSION = arches.__version__ -MAX_ARCHES_VERSION = arches.__version__ - -# LOAD_V3_DATA_DURING_TESTS = True will engage the most extensive the of the v3 -# data migration tests, which could add over a minute to the test process. It's -# recommended that this setting only be set to True in tests/settings_local.py -# and run in specific cases at the discretion of the developer. -LOAD_V3_DATA_DURING_TESTS = False - -RESOURCE_GRAPH_LOCATIONS = (os.path.join(TEST_ROOT, "fixtures", "resource_graphs"),) -ONTOLOGY_FIXTURES = os.path.join(TEST_ROOT, "fixtures", "ontologies", "test_ontology") -ONTOLOGY_PATH = os.path.join(TEST_ROOT, "fixtures", "ontologies", "cidoc_crm") +PROJECT_TEST_ROOT = os.path.dirname(__file__) +MEDIA_ROOT = os.path.join(PROJECT_TEST_ROOT, "fixtures", "data") BUSINESS_DATA_FILES = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". @@ -89,41 +47,9 @@ TEST_RUNNER = "tests.base_test.ArchesTestRunner" SILENCED_SYSTEM_CHECKS.append( - "arches.W001" -) # Cache backend does not support rate-limiting - -# could add Chrome, PhantomJS etc... here -LOCAL_BROWSERS = [] # ['Firefox'] - -ENABLE_USER_SIGNUP = True -FORCE_USER_SIGNUP_EMAIL_AUTHENTICATION = True - -OVERRIDE_RESOURCE_MODEL_LOCK = True - -ENABLE_TWO_FACTOR_AUTHENTICATION = False -FORCE_TWO_FACTOR_AUTHENTICATION = False + "arches.W001", # Cache backend does not support rate-limiting +) -DATATYPE_LOCATIONS.append("tests.fixtures.datatypes") ELASTICSEARCH_HOSTS = [ {"scheme": "http", "host": "localhost", "port": ELASTICSEARCH_HTTP_PORT} ] -LANGUAGES = [ - ("de", _("German")), - ("en", _("English")), - ("en-gb", _("British English")), - ("es", _("Spanish")), - ("ar", _("Arabic")), -] - -DOCKER = False - -try: - from arches.settings_local import * -except ImportError: - pass - -if DOCKER: - try: - from arches.settings_docker import * - except ImportError: - pass diff --git a/arches_lingo/tests.py b/tests/tests.py similarity index 100% rename from arches_lingo/tests.py rename to tests/tests.py diff --git a/webpack/webpack.common.js b/webpack/webpack.common.js index 5e6c05ec..c8d01348 100644 --- a/webpack/webpack.common.js +++ b/webpack/webpack.common.js @@ -325,7 +325,8 @@ module.exports = () => { loader: Path.join(PROJECT_RELATIVE_NODE_MODULES_PATH, 'ts-loader'), options: { appendTsSuffixTo: [/\.vue$/], - transpileOnly: true + transpileOnly: true, + configFile: Path.resolve(__dirname, '..', 'tsconfig.json') } }, {