-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #653 from Ilhasoft/staging
Staging
- Loading branch information
Showing
44 changed files
with
1,125 additions
and
452 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,3 @@ exclude = | |
./bothub/common/migrations | ||
./manage.py | ||
./bothub/common/languages.py | ||
./bothub/protos/ |
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 |
---|---|---|
|
@@ -117,9 +117,6 @@ staticfiles/ | |
#Pycharm | ||
.idea/ | ||
|
||
# gRPC Protobuff | ||
bothub/protos/ | ||
|
||
#ASDF | ||
.tool-versions | ||
|
||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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,60 @@ | ||
from rest_framework import serializers | ||
|
||
from bothub.common import languages | ||
from bothub.common.models import Repository, QAKnowledgeBase, QAContext | ||
from bothub.common.models import Repository, QAKnowledgeBase, QAtext | ||
|
||
|
||
class QAKnowledgeBaseSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = QAKnowledgeBase | ||
fields = ["id", "repository", "title"] | ||
fields = [ | ||
"id", | ||
"repository", | ||
"title", | ||
"description", | ||
"language_count", | ||
"user_name", | ||
"user", | ||
"last_update", | ||
"created_at", | ||
] | ||
read_only_fields = ["created_at", "last_update"] | ||
|
||
user = serializers.HiddenField(default=serializers.CurrentUserDefault()) | ||
user_name = serializers.SerializerMethodField("get_user_name") | ||
repository = serializers.PrimaryKeyRelatedField(queryset=Repository.objects) | ||
description = serializers.SerializerMethodField("get_description") | ||
language_count = serializers.SerializerMethodField("get_languages_count") | ||
|
||
def get_user_name(self, obj): | ||
return None if obj.user is None else obj.user.nickname | ||
|
||
class QAContextSerializer(serializers.ModelSerializer): | ||
def get_description(self, obj): | ||
return obj.get_text_description() | ||
|
||
def get_languages_count(self, obj): | ||
return obj.get_languages_count() | ||
|
||
|
||
class QAtextSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = QAContext | ||
fields = ["id", "text", "language", "knowledge_base"] | ||
model = QAtext | ||
fields = [ | ||
"id", | ||
"text", | ||
"language", | ||
"knowledge_base", | ||
"created_at", | ||
"last_update", | ||
"title", | ||
] | ||
read_only_fields = ["created_at", "last_update"] | ||
|
||
knowledge_base = serializers.PrimaryKeyRelatedField( | ||
queryset=QAKnowledgeBase.objects | ||
) | ||
language = serializers.ChoiceField(languages.LANGUAGE_CHOICES, required=True) | ||
title = serializers.SerializerMethodField("get_title") | ||
|
||
def get_title(self, obj): | ||
return obj.get_title() |
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
Oops, something went wrong.