updated login/select

This commit is contained in:
2025-01-27 21:43:36 +03:00
parent b88f910a43
commit c0bd9c1685
18 changed files with 257 additions and 275 deletions

View File

@@ -59,11 +59,10 @@ class OccupantToken(BaseModel):
responsible_employee_uuid: Optional[str] = None
reachable_event_codes: Optional[list[str]] = None # ID list of reachable modules
reachable_event_endpoints: Optional[list[str]] = None
class CompanyToken(BaseModel): # Required Company Object for an employee
class CompanyToken(BaseModel):
# Selection of the company for an employee is made by the user
company_id: int
company_uu_id: str
@@ -82,14 +81,12 @@ class CompanyToken(BaseModel): # Required Company Object for an employee
bulk_duties_id: int
reachable_event_codes: Optional[list[str]] = None # ID list of reachable modules
reachable_event_endpoints: Optional[list[str]] = None
class OccupantTokenObject(ApplicationToken):
# Occupant Token Object -> Requires selection of the occupant type for a specific build part
available_occupants: dict = None
selected_occupant: Optional[OccupantToken] = None # Selected Occupant Type
@property

View File

@@ -21,7 +21,7 @@ class BaseEndpointResponse:
return {"message": f"{self.code} -> Language model not found"}
class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
@@ -30,7 +30,7 @@ class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
)
class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
@@ -39,7 +39,7 @@ class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
)
class EndpointAcceptedResponse(BaseEndpointResponse): # 202 Accepted
class EndpointAcceptedResponse(BaseEndpointResponse): # 202 Accepted
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
@@ -48,7 +48,16 @@ class EndpointAcceptedResponse(BaseEndpointResponse): # 202 Accepted
)
class EndpointBadRequestResponse(BaseEndpointResponse): # 400 Bad Request
class EndpointNotModifiedResponse(BaseEndpointResponse): # 304 Not Modified
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_304_NOT_MODIFIED,
content=dict(completed=False, **self.response, lang=self.lang),
)
class EndpointBadRequestResponse(BaseEndpointResponse): # 400 Bad Request
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
@@ -57,7 +66,7 @@ class EndpointBadRequestResponse(BaseEndpointResponse): # 400 Bad Reques
)
class EndpointUnauthorizedResponse(BaseEndpointResponse): # 401 Unauthorized
class EndpointUnauthorizedResponse(BaseEndpointResponse): # 401 Unauthorized
def as_dict(self):
return JSONResponse(
@@ -66,16 +75,7 @@ class EndpointUnauthorizedResponse(BaseEndpointResponse): # 401 Unauthoriz
)
class EndpointNotFoundResponse(BaseEndpointResponse): # 404 Not Found
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_404_NOT_FOUND,
content=dict(completed=False, **self.response, lang=self.lang),
)
class EndpointForbiddenResponse(BaseEndpointResponse): # 403 Forbidden
class EndpointForbiddenResponse(BaseEndpointResponse): # 403 Forbidden
def as_dict(self):
return JSONResponse(
@@ -84,7 +84,34 @@ class EndpointForbiddenResponse(BaseEndpointResponse): # 403 Forbidden
)
class EndpointConflictResponse(BaseEndpointResponse): # 409 Conflict
class EndpointNotFoundResponse(BaseEndpointResponse): # 404 Not Found
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_404_NOT_FOUND,
content=dict(completed=False, **self.response, lang=self.lang),
)
class EndpointMethodNotAllowedResponse(BaseEndpointResponse): # 405 Method Not Allowed
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
content=dict(completed=False, **self.response, lang=self.lang),
)
class EndpointNotAcceptableResponse(BaseEndpointResponse): # 406 Not Acceptable
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_406_NOT_ACCEPTABLE,
content=dict(completed=False, **self.response, lang=self.lang),
)
class EndpointConflictResponse(BaseEndpointResponse): # 409 Conflict
def as_dict(self):
return JSONResponse(
@@ -93,7 +120,16 @@ class EndpointConflictResponse(BaseEndpointResponse): # 409 Conflict
)
class EndpointTooManyRequestsResponse(BaseEndpointResponse): # 429 Too Many Requests
class EndpointUnprocessableEntityResponse(BaseEndpointResponse): # 422 Unprocessable Entity
def as_dict(self, data: Optional[dict] = None):
return JSONResponse(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
content=dict(completed=False, **self.response, lang=self.lang, data=data),
)
class EndpointTooManyRequestsResponse(BaseEndpointResponse): # 429 Too Many Requests
def __init__(self, retry_after: int, lang: str, code: str):
super().__init__(lang=lang, code=code)
@@ -107,19 +143,10 @@ class EndpointTooManyRequestsResponse(BaseEndpointResponse): # 429 Too Many R
)
class EndpointInternalErrorResponse(BaseEndpointResponse): # 500 Internal Server Error
class EndpointInternalErrorResponse(BaseEndpointResponse): # 500 Internal Server Error
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
content=dict(completed=False, **self.response, lang=self.lang),
)
class EndpointErrorResponse(BaseEndpointResponse):
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_304_NOT_MODIFIED,
content=dict(completed=False, **self.response, lang=self.lang),
)