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

Prototype concept and scheme serializers #103 #104

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Add login interface [#13](https://github.com/archesproject/arches-lingo/issues/13)
- Add front-end router [#11](https://github.com/archesproject/arches-lingo/issues/11)
- Add concept and scheme serializers [#103](https://github.com/archesproject/arches-lingo/issues/103)
- Add backend for search [#67](https://github.com/archesproject/arches-lingo/issues/67)
- Add concept and scheme pages [#15](https://github.com/archesproject/arches-lingo/issues/15)
- Add concept hierarchy component [#18](https://github.com/archesproject/arches-lingo/issues/18)
Expand Down
34 changes: 34 additions & 0 deletions arches_lingo/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from arches.app.models.models import ResourceInstance, TileModel
from arches.app.models.serializers import ArchesModelSerializer, ArchesTileSerializer


class SchemeStatementSerializer(ArchesTileSerializer):
class Meta:
model = TileModel
graph_slug = "scheme"
root_node = "statement"
fields = "__all__"


class SchemeSerializer(ArchesModelSerializer):
class Meta:
model = ResourceInstance
graph_slug = "scheme"
nodegroups = "__all__"
fields = "__all__"


class ConceptStatementSerializer(ArchesTileSerializer):
class Meta:
model = TileModel
graph_slug = "concept"
root_node = "statement"
fields = "__all__"


class ConceptSerializer(ArchesModelSerializer):
class Meta:
model = ResourceInstance
graph_slug = "concept"
nodegroups = "__all__"
fields = "__all__"
1 change: 1 addition & 0 deletions arches_lingo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def get_optional_env_variable(var_name, default=None) -> str:
"guardian",
"captcha",
"revproxy",
"rest_framework",
"corsheaders",
"oauth2_provider",
"django_celery_results",
Expand Down
36 changes: 35 additions & 1 deletion arches_lingo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,49 @@

from arches_lingo.views.root import LingoRootView
from arches_lingo.views.api.concepts import ConceptTreeView, ValueSearchView
from arches_lingo.views.api.pythonic_models import (
ConceptDetailView,
ConceptListCreateView,
ConceptStatementDetailView,
ConceptStatementListCreateView,
SchemeDetailView,
SchemeListCreateView,
SchemeStatementDetailView,
SchemeStatementListCreateView,
)

urlpatterns = [
path("", LingoRootView.as_view(), name="root"),
path("login", LingoRootView.as_view(), name="login"),
path("advanced-search", LingoRootView.as_view(), name="advanced-search"),
path("schemes", LingoRootView.as_view(), name="schemes"),
path("concept/<uuid:id>", LingoRootView.as_view(), name="concept"),
path("api/concepts", ConceptTreeView.as_view(), name="api-concepts"),
path("api/concept-tree", ConceptTreeView.as_view(), name="api-concepts"),
path("api/search", ValueSearchView.as_view(), name="api-search"),
path("api/concepts", ConceptListCreateView.as_view(), name="concepts-list-create"),
path("api/concept/<uuid:pk>", ConceptDetailView.as_view(), name="concept-detail"),
path(
"api/concept/statements",
ConceptStatementListCreateView.as_view(),
name="concept-statements-list-create",
),
path(
"api/concept/statement/<uuid:pk>",
ConceptStatementDetailView.as_view(),
name="concept-statement-detail",
),
path("api/schemes", SchemeListCreateView.as_view(), name="schemes-list-create"),
path("api/scheme/<uuid:pk>", SchemeDetailView.as_view(), name="scheme-detail"),
path(
"api/scheme/statements",
SchemeStatementListCreateView.as_view(),
name="scheme-statements-list-create",
),
path(
"api/scheme/statement/<uuid:pk>",
SchemeStatementDetailView.as_view(),
name="scheme-statement-detail",
),
path("", include("arches_references.urls")),
]

Expand Down
51 changes: 51 additions & 0 deletions arches_lingo/views/api/pythonic_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView

from arches.app.permissions.rest_framework import RDMAdministrator
from arches.app.views.api.mixins import ArchesModelAPIMixin

from arches_lingo.serializers import (
ConceptSerializer,
SchemeSerializer,
ConceptStatementSerializer,
SchemeStatementSerializer,
)


class SchemeListCreateView(ArchesModelAPIMixin, ListCreateAPIView):
permission_classes = [RDMAdministrator]
serializer_class = SchemeSerializer


class SchemeDetailView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView):
permission_classes = [RDMAdministrator]
serializer_class = SchemeSerializer


class SchemeStatementListCreateView(ArchesModelAPIMixin, ListCreateAPIView):
permission_classes = [RDMAdministrator]
serializer_class = SchemeStatementSerializer


class SchemeStatementDetailView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView):
permission_classes = [RDMAdministrator]
serializer_class = SchemeStatementSerializer


class ConceptListCreateView(ArchesModelAPIMixin, ListCreateAPIView):
permission_classes = [RDMAdministrator]
serializer_class = ConceptSerializer


class ConceptDetailView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView):
permission_classes = [RDMAdministrator]
serializer_class = ConceptSerializer


class ConceptStatementListCreateView(ArchesModelAPIMixin, ListCreateAPIView):
permission_classes = [RDMAdministrator]
serializer_class = ConceptStatementSerializer


class ConceptStatementDetailView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView):
permission_classes = [RDMAdministrator]
serializer_class = ConceptStatementSerializer
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Framework :: Django",
"Framework :: Django :: 5.1",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
]
requires-python = ">=3.10"
requires-python = ">=3.11"
dependencies = [
"arches @ git+https://github.com/archesproject/arches.git@dev/8.0.x",
"arches @ git+https://github.com/archesproject/arches.git@jtw/pythonic-resource-models",
"arches_vue_utils @ git+https://github.com/archesproject/arches-vue-utils.git@main",
"arches_references @ git+https://github.com/archesproject/arches-references.git@main",
"arches_references @ git+https://github.com/archesproject/arches-references.git@jtw/pythonic-resource-models-compatibility",
]
version = "0.0.1"

Expand Down
Loading