@@ -67,28 +67,31 @@ class Meta:
6767 authentication_classes = []
6868 permission_classes = []
6969
70- request_body = openapi .Schema (
71- type = openapi .TYPE_OBJECT ,
72- title = "Account Creation Schema" ,
73- description = "Account creation schema description." ,
74- required = ["hostname" , "email" ],
75- properties = {
76- "hostname" : openapi .Schema (
77- type = openapi .TYPE_STRING , description = "Hostname of the User Database."
78- ),
79- "email" : openapi .Schema (
80- type = openapi .TYPE_STRING , description = "Email address of user."
81- ),
82- "token" : openapi .Schema (
83- type = openapi .TYPE_STRING ,
84- description = "Token returned with new user being "
85- "generated in the User Database." ,
86- ),
87- },
88- )
89-
9070 @swagger_auto_schema (
91- request_body = request_body ,
71+ request_body = openapi .Schema (
72+ type = openapi .TYPE_OBJECT ,
73+ title = "Account Creation Schema" ,
74+ description = "Account creation schema description." ,
75+ required = ["hostname" , "email" ],
76+ properties = {
77+ "hostname" : openapi .Schema (
78+ type = openapi .TYPE_STRING ,
79+ description = "Hostname of the User Database." ,
80+ example = "http://localhost:8000/"
81+ ),
82+ "email" : openapi .Schema (
83+ type = openapi .TYPE_STRING ,
84+ description = "Email address of user." ,
85+ 86+ ),
87+ "token" : openapi .Schema (
88+ type = openapi .TYPE_STRING ,
89+ description = "Token returned with new user being "
90+ "generated in the User Database." ,
91+ example = "testToken123456789"
92+ ),
93+ },
94+ ),
9295 responses = {
9396 201 : "Account creation request is successful." ,
9497 400 : "Bad request format." ,
@@ -100,22 +103,34 @@ class Meta:
100103 def post (self , request ) -> Response :
101104 serializer = self .InputSerializer (data = request .data )
102105 serializer .is_valid (raise_exception = True )
103-
104- if check_user_email (request .data ['email' ]) is True :
106+ email = serializer .validated_data ['email' ]
107+ 108+ return Response (
109+ status = status .HTTP_201_CREATED ,
110+ data = {"message" :"Testing account request successful!!" }
111+ )
112+ if check_user_email (email ) is True :
105113 return Response (
106114 status = status .HTTP_409_CONFLICT ,
107- data = {"message" :"CONFLICT: Account has already been authenticated or requested." }
115+ data = {
116+ "message" :f"CONFLICT: That account, { email } , has already " \
117+ + "been requested. Please contact an admin with further " \
118+ + "questions."
119+ }
108120 )
109121
110- if check_new_user (request . data [ ' email' ] ) is True :
122+ if check_new_user (email ) is True :
111123 return Response (
112124 status = status .HTTP_409_CONFLICT ,
113- data = {"message" : "Account has already been requested." },
125+ data = {
126+ "message" : f"That account, { email } , has already been " \
127+ + "requested. Please contact an admin with further questions."
128+ }
114129 )
115130
116131 try :
117132 new_user_email (serializer .validated_data )
118- return Response (status = status .HTTP_201_CREATED )
133+ return Response (status = status .HTTP_201_CREATED , data = { "message" : "" } )
119134 except Exception as error :
120135 return Response (
121136 status = status .HTTP_500_INTERNAL_SERVER_ERROR ,
@@ -181,13 +196,6 @@ def post(self, request):
181196 if response .status_code == 200 :
182197 return Response (status = status .HTTP_201_CREATED , data = {"message" : "user account created" })
183198
184- class AuthenticationInputSerializer (serializers .Serializer ):
185- auth_service = serializers .JSONField (validators = [validate_auth_service ])
186-
187- class Meta :
188- model = Authentication
189- fields = ['username' , 'auth_service' ]
190-
191199class AddAuthenticationApi (APIView ):
192200 """
193201 Add Authentication Object
@@ -204,6 +212,13 @@ class AddAuthenticationApi(APIView):
204212 ```
205213 """
206214
215+ class InputSerializer (serializers .Serializer ):
216+ auth_service = serializers .JSONField (validators = [validate_auth_service ])
217+
218+ class Meta :
219+ model = Authentication
220+ fields = ['username' , 'auth_service' ]
221+
207222 permission_classes = [IsAuthenticated ,]
208223
209224 schema = openapi .Schema (
@@ -240,8 +255,8 @@ class AddAuthenticationApi(APIView):
240255 )
241256
242257 def post (self , request ):
243- """
244- """
258+ """"""
259+
245260 result = validate_auth_service (request .data )
246261
247262 if result != 1 :
0 commit comments