Skip to content

Commit

Permalink
Merge 1e24743 into 27ae14b
Browse files Browse the repository at this point in the history
  • Loading branch information
helllllllder committed Sep 24, 2021
2 parents 27ae14b + 1e24743 commit 7fc3065
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 230 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ staticfiles/
.idea/

# gRPC Protobuff
bothub/protos/*.py
bothub/protos/

#ASDF
.tool-versions
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ before_script:
- psql -U postgres -c "CREATE USER bothub WITH PASSWORD 'bothub';"
- psql -U postgres -c "ALTER ROLE bothub WITH SUPERUSER;"
- psql -U bothub postgres -c "CREATE DATABASE bothub;"
- python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/authentication.proto
- python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/organization.proto
- python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/repository.proto
- python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/project.proto

install:
- pip install pipenv
Expand All @@ -50,6 +46,7 @@ env:
- SUPPORTED_LANGUAGES="en|pt"
- DEFAULT_DATABASE="postgres://bothub:bothub@localhost:5432/bothub"
script:
- make createproto
- python manage.py migrate
- python manage.py collectstatic
- flake8
Expand Down
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y gcc bzip2 git curl nginx libpq-dev gettext \
libgdal-dev python3-cffi python3-gdal vim

RUN pip install -U pip==20.2.2 setuptools==49.6.0
RUN pip install pipenv==2018.11.26
RUN apt-get install make

RUN pip install -U pip==21.2.2 setuptools==57.4.0
RUN pip install pipenv==2021.5.29
RUN pip install gunicorn==19.9.0
RUN pip install gevent==1.4.0
RUN pip install psycopg2-binary
Expand All @@ -23,10 +25,7 @@ RUN pipenv install --system

COPY . .

RUN python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/authentication.proto
RUN python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/organization.proto
RUN python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/repository.proto
RUN python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/project.proto
RUN make createproto

RUN chmod +x ./entrypoint.sh
ENTRYPOINT [ "./entrypoint.sh" ]
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@ collectstatic:
then python manage.py collectstatic --no-input; \
else pipenv run python manage.py collectstatic --no-input; fi

search_index:
@make check_environment
@if [ ${IS_PRODUCTION} = true ]; \
then python manage.py search_index --rebuild -f; \
else pipenv run python manage.py search_index --rebuild -f; fi

createproto:
@rm -rf ./bothub/protos/*.py
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/authentication.proto
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/organization.proto
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/repository.proto
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/project.proto

@rm -rf ./bothub/protos/
@git clone --depth 1 --branch main https://github.com/Ilhasoft/weni-protobuffers ./bothub/protos/
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/src/weni/protobuf/intelligence/authentication.proto
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/src/weni/protobuf/intelligence/organization.proto
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/src/weni/protobuf/intelligence/repository.proto
@python -m grpc_tools.protoc --experimental_allow_proto3_optional --proto_path=./ --python_out=./ --grpc_python_out=./ ./bothub/protos/src/weni/protobuf/connect/project.proto


# Utils
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/connect_grpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import grpc
from django.conf import settings

from bothub.protos import project_pb2_grpc, project_pb2
from bothub.protos.src.weni.protobuf.connect import project_pb2_grpc, project_pb2


class ConnectGRPCClient:
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/organization/handlers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from bothub.api.grpc.organization.services import OrgService
from bothub.protos import organization_pb2_grpc
from bothub.protos.src.weni.protobuf.intelligence import organization_pb2_grpc


def grpc_handlers(server):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/organization/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from bothub.authentication.models import User
from bothub.common.models import Organization, OrganizationAuthorization
from bothub.protos import organization_pb2
from bothub.protos.src.weni.protobuf.intelligence import organization_pb2


class OrgProtoSerializer(proto_serializers.ModelProtoSerializer):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/organization/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
RepositoryAuthorization,
Repository,
)
from bothub.protos.organization_pb2 import OrgStatistic
from bothub.protos.src.weni.protobuf.intelligence.organization_pb2 import OrgStatistic


class OrgService(
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/repository/handlers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .services import RepositoryService
from bothub.protos import repository_pb2_grpc
from bothub.protos.src.weni.protobuf.intelligence import repository_pb2_grpc


def grpc_handlers(server):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/repository/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from bothub.api.v2.repository.serializers import RepositoryCategorySerializer
from bothub.common.models import Repository
from bothub.protos import repository_pb2
from bothub.protos.src.weni.protobuf.intelligence import repository_pb2


class RepositoryProtoSerializer(proto_serializers.ModelProtoSerializer):
Expand Down
5 changes: 4 additions & 1 deletion bothub/api/grpc/repository/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
OrganizationAuthorization,
RepositoryAuthorization,
)
from bothub.protos import repository_pb2_grpc, repository_pb2
from bothub.protos.src.weni.protobuf.intelligence import (
repository_pb2_grpc,
repository_pb2,
)


class RepositoryServiceTestCase(RPCTransactionTestCase):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/user/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
UserService,
UserLanguageService,
)
from bothub.protos import authentication_pb2_grpc
from bothub.protos.src.weni.protobuf.intelligence import authentication_pb2_grpc


def grpc_handlers(server):
Expand Down
2 changes: 1 addition & 1 deletion bothub/api/grpc/user/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rest_framework import serializers

from bothub.authentication.models import User
from bothub.protos import authentication_pb2
from bothub.protos.src.weni.protobuf.intelligence import authentication_pb2


class UserProtoSerializer(proto_serializers.ModelProtoSerializer):
Expand Down
5 changes: 4 additions & 1 deletion bothub/api/grpc/user/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from bothub.api.v2.tests.utils import create_user_and_token
from bothub.authentication.models import User
from bothub.common.models import Organization, OrganizationAuthorization
from bothub.protos import authentication_pb2_grpc, authentication_pb2
from bothub.protos.src.weni.protobuf.intelligence import (
authentication_pb2_grpc,
authentication_pb2,
)


class UserServiceTest(RPCTransactionTestCase):
Expand Down
6 changes: 5 additions & 1 deletion bothub/api/v2/repository/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ def filter_repository_version_language(self, queryset, name, value):
repository = RepositoryVersionLanguage.objects.get(
pk=value
).repository_version.repository
if str(repository.uuid) not in settings.REPOSITORY_RESTRICT_ACCESS_NLP_LOGS:
restrict_access_list = settings.REPOSITORY_RESTRICT_ACCESS_NLP_LOGS
if (
restrict_access_list != []
and str(repository.uuid) not in restrict_access_list
):
# Restricts log access to a particular or multiple intelligences
raise PermissionDenied()
authorization = repository.get_user_authorization(request.user)
Expand Down
60 changes: 0 additions & 60 deletions bothub/protos/authentication.proto

This file was deleted.

53 changes: 0 additions & 53 deletions bothub/protos/organization.proto

This file was deleted.

40 changes: 0 additions & 40 deletions bothub/protos/project.proto

This file was deleted.

50 changes: 0 additions & 50 deletions bothub/protos/repository.proto

This file was deleted.

0 comments on commit 7fc3065

Please sign in to comment.