-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add concept & scheme serializers & views
- Loading branch information
1 parent
68f5da2
commit 236af9c
Showing
7 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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): | ||
# TODO: Reduce duplication with Meta.nodegroups, below? | ||
statement = SchemeStatementSerializer(many=True, required=False) | ||
|
||
class Meta: | ||
model = ResourceInstance | ||
graph_slug = "scheme" | ||
nodegroups = ["statement"] | ||
fields = "__all__" | ||
|
||
|
||
class ConceptStatementSerializer(ArchesTileSerializer): | ||
class Meta: | ||
model = TileModel | ||
graph_slug = "concept" | ||
root_node = "statement" | ||
fields = "__all__" | ||
|
||
|
||
class ConceptSerializer(ArchesModelSerializer): | ||
statement = ConceptStatementSerializer(many=True, required=False) | ||
|
||
class Meta: | ||
model = ResourceInstance | ||
graph_slug = "concept" | ||
nodegroups = ["statement"] | ||
fields = "__all__" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from rest_framework.permissions import IsAuthenticated | ||
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView | ||
|
||
from arches.app.views.api.mixins import ArchesModelAPIMixin | ||
|
||
from arches_lingo.serializers import ( | ||
ConceptSerializer, | ||
SchemeSerializer, | ||
ConceptStatementSerializer, | ||
SchemeStatementSerializer, | ||
) | ||
|
||
|
||
class SchemeListCreateView(ArchesModelAPIMixin, ListCreateAPIView): | ||
permission_classes = [IsAuthenticated] | ||
serializer_class = SchemeSerializer | ||
|
||
|
||
class SchemeDetailView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView): | ||
permission_classes = [IsAuthenticated] | ||
serializer_class = SchemeSerializer | ||
|
||
|
||
class SchemeStatementListCreateView(ArchesModelAPIMixin, ListCreateAPIView): | ||
permission_classes = [IsAuthenticated] | ||
serializer_class = SchemeStatementSerializer | ||
|
||
|
||
class SchemeStatementDetailView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView): | ||
permission_classes = [IsAuthenticated] | ||
serializer_class = SchemeStatementSerializer | ||
|
||
|
||
class ConceptListCreateView(ArchesModelAPIMixin, ListCreateAPIView): | ||
permission_classes = [IsAuthenticated] | ||
serializer_class = ConceptSerializer | ||
|
||
|
||
class ConceptDetailView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView): | ||
permission_classes = [IsAuthenticated] | ||
serializer_class = ConceptSerializer | ||
|
||
|
||
class ConceptStatementListCreateView(ArchesModelAPIMixin, ListCreateAPIView): | ||
permission_classes = [IsAuthenticated] | ||
serializer_class = ConceptStatementSerializer | ||
|
||
|
||
class ConceptStatementDetailView(ArchesModelAPIMixin, RetrieveUpdateDestroyAPIView): | ||
permission_classes = [IsAuthenticated] | ||
serializer_class = ConceptStatementSerializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters