Skip to content

Commit

Permalink
Merge 3a2ce37 into 015bed8
Browse files Browse the repository at this point in the history
  • Loading branch information
dyohan9 committed Jul 24, 2019
2 parents 015bed8 + 3a2ce37 commit cc071c8
Show file tree
Hide file tree
Showing 49 changed files with 6,305 additions and 962 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,6 @@ staticfiles/

# OS
.DS_Store

#Pycharm
.idea/
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ requests = "==2.20.1"
coreapi = "==2.3.3"
whitenoise = "==4.1.2"
pytz = "==2018.7"
drf-yasg = "*"

[dev-packages]
"flake8" = "*"
coverage = "*"
ipython = "*"
autopep8 = "*"
packaging = "*"

[requires]
python_version = "3.6"
115 changes: 86 additions & 29 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions bothub/api/v1/routers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from rest_framework import routers

from .views import NewRepositoryViewSet
from .views import MyRepositoriesViewSet
from .views import SearchRepositoriesViewSet
from .views import RepositoryViewSet
from .views import NewRepositoryExampleViewSet
from .views import RepositoryExampleViewSet
Expand Down Expand Up @@ -31,7 +31,7 @@
class Router(routers.SimpleRouter):
routes = [
# Dynamically generated list routes.
# Generated using @list_route decorator
# Generated using @action decorator
# on methods of the viewset.
routers.DynamicRoute(
url=r'^{prefix}/{url_path}{trailing_slash}$',
Expand All @@ -40,7 +40,7 @@ class Router(routers.SimpleRouter):
initkwargs={},
),
# Dynamically generated detail routes.
# Generated using @detail_route decorator on methods of the viewset.
# Generated using @action decorator on methods of the viewset.
routers.DynamicRoute(
url=r'^{prefix}/{lookup}/{url_path}{trailing_slash}$',
name='{basename}-{url_name}',
Expand Down Expand Up @@ -99,7 +99,7 @@ def get_lookup_regex(self, viewset, lookup_prefix=''):

router = Router()
router.register('repository/new', NewRepositoryViewSet)
router.register('my-repositories', MyRepositoriesViewSet)
router.register('search-repositories', SearchRepositoriesViewSet)
router.register('repository', RepositoryViewSet)
router.register('example/new', NewRepositoryExampleViewSet)
router.register('example', RepositoryExampleViewSet)
Expand Down
1 change: 0 additions & 1 deletion bothub/api/v1/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
AnalyzeTextSerializer,
EvaluateSerializer,
EditRepositorySerializer,
VoteSerializer,
RepositoryAuthorizationRoleSerializer,
)

Expand Down
1 change: 1 addition & 0 deletions bothub/api/v1/serializers/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class Meta:
'name',
'icon',
]
ref_name = None
9 changes: 9 additions & 0 deletions bothub/api/v1/serializers/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ..validators import CanContributeInRepositoryExampleValidator
from ..validators import CanContributeInRepositoryValidator
from ..validators import ExampleWithIntentOrEntityValidator
from ..validators import IntentAndSentenceNotExistsValidator
from ..validators import EntityNotEqualLabelValidator
from .translate import RepositoryTranslatedExampleSerializer

Expand All @@ -33,6 +34,7 @@ class Meta:
'created_at',
'value',
]
ref_name = None

repository_example = serializers.PrimaryKeyRelatedField(
queryset=RepositoryExample.objects,
Expand Down Expand Up @@ -62,6 +64,7 @@ class Meta:
'entity',
'label',
]
ref_name = None

repository_example = serializers.PrimaryKeyRelatedField(
queryset=RepositoryExample.objects,
Expand Down Expand Up @@ -107,6 +110,7 @@ class Meta:
'repository_update',
'deleted_in',
]
ref_name = None

entities = RepositoryExampleEntitySerializer(
many=True,
Expand All @@ -132,6 +136,7 @@ class Meta:
'intent',
'entities',
]
ref_name = None

id = serializers.PrimaryKeyRelatedField(
read_only=True,
Expand All @@ -158,10 +163,12 @@ class Meta:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.validators.append(ExampleWithIntentOrEntityValidator())
self.validators.append(IntentAndSentenceNotExistsValidator())

def create(self, validated_data):
entities_data = validated_data.pop('entities')
repository = validated_data.pop('repository')

try:
language = validated_data.pop('language')
except KeyError:
Expand All @@ -186,6 +193,7 @@ class Meta:
'value',
'label',
]
ref_name = None

label = serializers.SerializerMethodField()

Expand All @@ -203,6 +211,7 @@ class Meta:
'value',
'entities',
]
ref_name = None

repository = serializers.StringRelatedField(read_only=True)
entities = serializers.SlugRelatedField(
Expand Down
Loading

0 comments on commit cc071c8

Please sign in to comment.