Skip to content

Commit

Permalink
Fix bothub proto create org
Browse files Browse the repository at this point in the history
  • Loading branch information
dyohan9 committed Apr 27, 2021
1 parent c348ff3 commit f6cbf8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion bothub/api/grpc/organization/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Meta:

class OrgCreateProtoSerializer(proto_serializers.ModelProtoSerializer):

organization_name = serializers.CharField()
user_email = serializers.CharField()
user_nickname = serializers.CharField()

Expand All @@ -49,7 +50,7 @@ def validate_user_email(self, value: str) -> str:
class Meta:
model = Organization
proto_class = organization_pb2.Org
fields = ["name", "user_email", "user_nickname"]
fields = ["organization_name", "user_email", "user_nickname"]


class OrgUpdateProtoSerializer(proto_serializers.ModelProtoSerializer):
Expand Down
11 changes: 8 additions & 3 deletions bothub/api/grpc/organization/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@


class OrgService(
mixins.ListModelMixin, mixins.RetrieveModelMixin, generics.GenericService
mixins.ListModelMixin,
mixins.RetrieveModelMixin,
mixins.CreateModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
generics.GenericService,
):
def List(self, request, context):

Expand All @@ -40,9 +45,9 @@ def Create(self, request, context):
serializer.is_valid(raise_exception=True)

validated_data = {
"name": serializer.validated_data.get("name"),
"name": serializer.validated_data.get("organization_name"),
"nickname": utils.organization_unique_slug_generator(
serializer.validated_data.get("name")
serializer.validated_data.get("organization_name")
),
"description": "",
"locale": "",
Expand Down
4 changes: 2 additions & 2 deletions bothub/protos/organization.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import "google/protobuf/empty.proto";

service OrgController {
rpc List(OrgListRequest) returns (stream Org) {}
rpc Retrieve(OrgStatisticRetrieveRequest) returns (OrgStatistic) {}
rpc Create(OrgCreateRequest) returns (Org) {}
rpc Update(OrgUpdateRequest) returns (OrgUpdateRequest) {}
rpc Destroy(OrgDestroyRequest) returns (google.protobuf.Empty) {}
rpc Retrieve(OrgStatisticRetrieveRequest) returns (OrgStatistic) {}
}

message Org {
Expand All @@ -30,7 +30,7 @@ message OrgListRequest {
}

message OrgCreateRequest {
string name = 1;
string organization_name = 1;
string user_email = 2;
string user_nickname = 3;
}
Expand Down

0 comments on commit f6cbf8f

Please sign in to comment.