-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
284 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
[ | ||
{ | ||
"pk": "eng", | ||
"model": "lex.language", | ||
"fields": { | ||
"name": "English" | ||
} | ||
}, | ||
{ | ||
"pk": "spa", | ||
"model": "lex.language", | ||
"fields": { | ||
"name": "Spanish" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "lex.lexicalclass", | ||
"fields": { | ||
"name": "noun", | ||
"language": "eng" | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "lex.lexicalclass", | ||
"fields": { | ||
"name": "noun", | ||
"language": "spa" | ||
} | ||
}, | ||
{ | ||
"pk": 3, | ||
"model": "lex.lexicalclass", | ||
"fields": { | ||
"name": "verb", | ||
"language": "eng" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "lex.representationtype", | ||
"fields": { | ||
"name": "written", | ||
"language": "eng" | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "lex.representationtype", | ||
"fields": { | ||
"name": "written", | ||
"language": "spa" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "lex.enumeration", | ||
"fields": { | ||
"name": "number", | ||
"language": "eng" | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "lex.enumeration", | ||
"fields": { | ||
"name": "number", | ||
"language": "spa" | ||
} | ||
}, | ||
{ | ||
"pk": 3, | ||
"model": "lex.enumeration", | ||
"fields": { | ||
"name": "gender", | ||
"language": "spa" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "lex.enumvalue", | ||
"fields": { | ||
"enum": 1, | ||
"value": "sg" | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "lex.enumvalue", | ||
"fields": { | ||
"enum": 1, | ||
"value": "pl" | ||
} | ||
}, | ||
{ | ||
"pk": 3, | ||
"model": "lex.enumvalue", | ||
"fields": { | ||
"enum": 2, | ||
"value": "sg" | ||
} | ||
}, | ||
{ | ||
"pk": 4, | ||
"model": "lex.enumvalue", | ||
"fields": { | ||
"enum": 2, | ||
"value": "pl" | ||
} | ||
}, | ||
{ | ||
"pk": 5, | ||
"model": "lex.enumvalue", | ||
"fields": { | ||
"enum": 3, | ||
"value": "masc" | ||
} | ||
}, | ||
{ | ||
"pk": 6, | ||
"model": "lex.enumvalue", | ||
"fields": { | ||
"enum": 3, | ||
"value": "fem" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "lex.lexemeterm", | ||
"fields": { | ||
"usage": "", | ||
"termNote": "", | ||
"concept": 1, | ||
"name": "steering_wheel", | ||
"language": "eng" | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "lex.lexemeterm", | ||
"fields": { | ||
"usage": "", | ||
"termNote": "", | ||
"concept": 2, | ||
"name": "tire", | ||
"language": "eng" | ||
} | ||
}, | ||
{ | ||
"pk": 3, | ||
"model": "lex.lexemeterm", | ||
"fields": { | ||
"usage": "", | ||
"termNote": "", | ||
"concept": 3, | ||
"name": "wheel", | ||
"language": "eng" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "term.subjectfield", | ||
"fields": { | ||
"name": "general" | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "term.subjectfield", | ||
"fields": { | ||
"name": "automotive" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "term.concept", | ||
"fields": { | ||
"subjectField": [ | ||
2 | ||
], | ||
"name": "steering_wheel" | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "term.concept", | ||
"fields": { | ||
"subjectField": [ | ||
2 | ||
], | ||
"name": "tire" | ||
} | ||
}, | ||
{ | ||
"pk": 3, | ||
"model": "term.concept", | ||
"fields": { | ||
"subjectField": [ | ||
1, | ||
2 | ||
], | ||
"name": "wheel" | ||
} | ||
}, | ||
{ | ||
"pk": 1, | ||
"model": "term.conceptdefinition", | ||
"fields": { | ||
"definition": "A car's steering wheel", | ||
"concept": 1, | ||
"language": "eng" | ||
} | ||
}, | ||
{ | ||
"pk": 2, | ||
"model": "term.conceptdefinition", | ||
"fields": { | ||
"definition": "A car's tire", | ||
"concept": 2, | ||
"language": "eng" | ||
} | ||
}, | ||
{ | ||
"pk": 3, | ||
"model": "term.conceptdefinition", | ||
"fields": { | ||
"definition": "A thin cylindrical object", | ||
"concept": 3, | ||
"language": "eng" | ||
} | ||
} | ||
] |
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,15 @@ | ||
from rest_framework.filters import BaseFilterBackend | ||
|
||
# We are doing filtering like this because it is based on multiple parameters from the urlconf | ||
|
||
class SubjectFilter(BaseFilterBackend): | ||
""" | ||
Filters querysets based on subject, if present | ||
""" | ||
def filter_queryset(self, request, queryset, view): | ||
if 'subject' in view.kwargs: | ||
subj = view.kwargs['subject'] | ||
return queryset.filter(subject=subj) | ||
else: | ||
return queryset | ||
|
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
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 |
---|---|---|
@@ -1,25 +1,23 @@ | ||
from term.models import * | ||
from term.serializers import * | ||
from term.filters import * | ||
from django.http import Http404 | ||
from rest_framework.views import APIView | ||
from rest_framework.response import Response | ||
from rest_framework import status | ||
from rest_framework.generics import ListCreateAPIView | ||
from rest_framework.viewsets import * | ||
|
||
class SubjectView(ListCreateAPIView): | ||
class TermAPIView(ModelViewSet): | ||
filter_backends = (SubjectFilter,) | ||
|
||
class SubjectView(TermAPIView): | ||
model = SubjectField | ||
serializer_class = SubjectSerializer | ||
lookup_field = 'name' | ||
|
||
class ConceptList(APIView): | ||
def get(self, request, subject=None, format=None): | ||
return Response(None) | ||
class ConceptView(TermAPIView): | ||
model = Concept | ||
serializer_class = ConceptSerializer | ||
lookup_field = 'name' | ||
|
||
class Concept(APIView): | ||
def get(self, request, id, subject=None, format=None): | ||
return Response(None) | ||
|
||
class Lemma(APIView): | ||
def get(self, request, lemma, subject=None, format=None): | ||
return Response(None) |