Skip to content

Commit

Permalink
check if owner user existis and save the user before call nlp_train
Browse files Browse the repository at this point in the history
  • Loading branch information
BarbosaJackson committed Dec 29, 2022
1 parent 295d9fb commit 9ec1daf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
26 changes: 14 additions & 12 deletions bothub/api/v2/repository/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,18 +1015,20 @@ def create(self, validated_data):
repository.versions.create(
is_default=True, created_by=self.context["request"].user
)
celery_app.send_task(
"send_recent_activity",
[
{
"user": owner.user.email,
"entity": "AI",
"action": "CREATE",
"entity_name": repository.name,
"intelligence_id": repository.owner.organization.id
}
]
)

if owner.user:
celery_app.send_task(
"send_recent_activity",
[
{
"user": owner.user.email,
"entity": "AI",
"action": "CREATE",
"entity_name": repository.name,
"intelligence_id": repository.owner.organization.id
}
]
)
return repository

def get_intents(self, obj):
Expand Down
3 changes: 2 additions & 1 deletion bothub/api/v2/repository/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ def train(self, request, **kwargs):
user_authorization = repository.get_user_authorization(request.user)
serializer = TrainSerializer(data=request.data) # pragma: no cover
serializer.is_valid(raise_exception=True) # pragma: no cover
user = request.user
if not user_authorization.can_write:
raise PermissionDenied()
request = repository.request_nlp_train(
Expand All @@ -549,7 +550,7 @@ def train(self, request, **kwargs):
"send_recent_activity",
[
{
"user": request.user.email,
"user": user.email,
"entity": "AI",
"action": "TRAIN",
"entity_name": repository.name,
Expand Down

0 comments on commit 9ec1daf

Please sign in to comment.