Skip to content

Commit

Permalink
refactor(console): remove excessive comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Nov 14, 2024
1 parent 6470fb0 commit a838821
Show file tree
Hide file tree
Showing 28 changed files with 0 additions and 168 deletions.
6 changes: 0 additions & 6 deletions console/api/database/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from .generic import exists


# --- FETCH --- #
def fetch_group(_id: str) -> Dict:
try:
with conn.cursor() as curs:
Expand Down Expand Up @@ -102,8 +101,3 @@ def fetch_groups(page=1, size=10) -> Tuple[Iterable[Dict], int]:

except DatabaseError as error:
raise error


# --- CREATE --- #

# --- DELETE --- #
32 changes: 0 additions & 32 deletions console/api/database/invitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from ..errors import EmptyDataException, NotFoundException


# --- FETCH --- #
def fetch_invitation(_id: str) -> Dict | None:
try:
with conn.cursor() as curs:
Expand Down Expand Up @@ -84,7 +83,6 @@ def fetch_invitations(page=1, size=10) -> Tuple[Iterable[Dict], int]:
raise error


# --- UPDATE --- #
def update_invitation(data: dict) -> None:
try:
data = {
Expand All @@ -95,33 +93,3 @@ def update_invitation(data: dict) -> None:
curs.execute(parse_sql_update_query("invitation", data))
except DatabaseError as error:
raise error


# def accept_invitation(data: dict):
# try:
# with conn.cursor() as curs:
# user = curs.execute(f'SELECT id FROM "user" WHERE email = \'{data.get('email')}\'').fetchone()
# if len(user) != 1:
# ...
#
# inv = fetch_invitation(_id=data.get('id'))
# if inv is None:
# ...
#
# if inv.get('status') != 'pending':
# ...
#
# update_invitation(data=data)
# curs.execute(f'INSERT INTO "organization_user" (organization_id, user_id) '
# f'VALUES {inv.get("organization_id")}, {user.get("id")}')
#
# curs.execute(f'INSERT INTO "userpermission" (id, user_id, resource_id, permission) '
# f'VALUES ({}) ON CONFLICT (user_id, resource_id) '
# f'DO UPDATE SET permission = ?')
#
# except DatabaseError as error:
# raise error

# --- CREATE --- #

# --- DELETE --- #
6 changes: 0 additions & 6 deletions console/api/database/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from ..errors import EmptyDataException, NotFoundException


# --- FETCH --- #
def fetch_organization(organization_id: str) -> Dict:
try:
with conn.cursor() as curs:
Expand Down Expand Up @@ -171,8 +170,3 @@ def fetch_organization_groups(
return data, count["count"]
except DatabaseError as error:
raise error


# --- CREATE --- #

# --- DELETE --- #
8 changes: 0 additions & 8 deletions console/api/database/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from ..errors import EmptyDataException, NotFoundException


# --- FETCH --- #
def fetch_snapshot(_id: str) -> Dict:
try:
with conn.cursor() as curs:
Expand Down Expand Up @@ -60,10 +59,3 @@ def fetch_snapshots(page=1, size=10) -> Tuple[Iterable[Dict], int]:
return data, count["count"]
except DatabaseError as error:
raise error


# --- UPDATE --- #

# --- CREATE --- #

# --- DELETE --- #
8 changes: 0 additions & 8 deletions console/api/database/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from ..errors import EmptyDataException, NotFoundException


# --- FETCH --- #
def fetch_task(_id: str) -> Dict:
try:
with conn.cursor() as curs:
Expand Down Expand Up @@ -58,10 +57,3 @@ def fetch_tasks(page=1, size=10) -> Tuple[Iterable[Dict], int]:
return data, count["count"]
except DatabaseError as error:
raise error


# --- UPDATE --- #

# --- CREATE --- #

# --- DELETE --- #
10 changes: 0 additions & 10 deletions console/api/database/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
from ..errors import EmptyDataException, NotFoundException


# --- FETCH --- #


def fetch_user_organizations(
user_id: str, page=1, size=10
) -> Tuple[Iterable[Dict], int]:
Expand Down Expand Up @@ -141,10 +138,3 @@ def fetch_user_groups(user_id: str, page=1, size=10) -> Tuple[Iterable[Dict], in
return data, count["count"]
except DatabaseError as error:
raise error


# --- UPDATE --- #

# --- CREATE --- #

# --- DELETE --- #
6 changes: 0 additions & 6 deletions console/api/database/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from ..errors import EmptyDataException, NotFoundException


# --- FETCH --- #
def fetch_workspace(_id: str) -> Dict:
try:
with conn.cursor() as curs:
Expand Down Expand Up @@ -107,8 +106,3 @@ def fetch_workspaces(page=1, size=10) -> Tuple[Iterable[Dict], int]:

except DatabaseError as error:
raise error


# --- CREATE --- #

# --- DELETE --- #
4 changes: 0 additions & 4 deletions console/api/errors/api_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@
from .error_codes import errors


# --- REQUIRED FOR AUTHORIZATION --- #
class GenericForbiddenException(HTTPException):
def __init__(
self, status_code: int = status.HTTP_403_FORBIDDEN, detail="Forbidden"
):
super().__init__(status_code=status_code, detail=detail)


# /--- REQUIRED FOR AUTHORIZATION ---/ #


class GenericError(JSONResponse):
def __init__(
self,
Expand Down
10 changes: 0 additions & 10 deletions console/api/models/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@
from pydantic import BaseModel, Field


# --- REQUEST MODELS --- #
class GenericRequest(BaseModel):
id: str = Field(...)

# @model_validator(mode='after')
# def not_null(self) -> Self:
# if not any(self.model_dump(exclude={'id'}).values()):
# raise ValueError('At lease one value must be set!')
#
# return self


class GenericPaginationRequest(BaseModel):
page: int | None = Field(default=1)
Expand All @@ -36,7 +28,6 @@ class GenericSearchRequest(GenericPaginationRequest):
query: str | None = Field("")


# --- RESPONSE MODELS --- #
class GenericResponse(BaseModel):
id: str

Expand Down Expand Up @@ -85,7 +76,6 @@ class GenericAcceptedResponse(BaseModel):
pass


# --- TOKEN SPECIFIC --- #
class GenericTokenPayload(BaseModel):
sub: str
iat: datetime.datetime
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
)


# --- REQUEST MODELS --- #
class GroupRequest(GenericRequest):
pass

Expand All @@ -36,7 +35,6 @@ class GroupSearchRequest(GenericSearchRequest):
pass


# --- RESPONSE MODELS --- #
class GroupResponse(GenericResponse):
name: str
organization: OrganizationResponse
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/grouppermission.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)


# --- REQUEST MODELS --- #
class GroupPermissionRequest(GenericRequest):
pass

Expand All @@ -28,7 +27,6 @@ class GroupPermissionListRequest(GenericPaginationRequest):
pass


# --- RESPONSE MODELS --- #
class GroupPermissionResponse(GenericResponse):
group_id: str
user_id: str
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/groupuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)


# --- REQUEST MODELS --- #
class UserGroupRequest(GenericRequest):
pass

Expand All @@ -28,7 +27,6 @@ class UserGroupListRequest(GenericPaginationRequest):
pass


# --- RESPONSE MODELS --- #
class UserGroupResponse(GenericResponse):
group_id: str
user_id: str
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/invitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
)


# --- REQUEST MODELS --- #
class InvitationRequest(GenericRequest):
pass

Expand All @@ -36,7 +35,6 @@ class ConfirmInvitationRequest(GenericRequest):
updateTime: datetime.datetime | None = Field(default_factory=datetime.datetime.now)


# --- RESPONSE MODELS --- #
class InvitationResponse(GenericResponse):
organization: OrganizationResponse
ownerId: str
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
)


# --- REQUEST MODELS --- #
class OrganizationRequest(GenericRequest):
pass

Expand All @@ -47,7 +46,6 @@ class OrganizationGroupListRequest(GenericRequest, GenericPaginationRequest):
pass


# --- RESPONSE MODELS --- #
class OrganizationResponse(GenericResponse):
name: str
createTime: datetime.datetime = Field(None)
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
from . import GenericListResponse, GenericRequest


# --- REQUEST MODELS --- #
class VersionRequest(GenericRequest):
pass


# --- RESPONSE MODELS --- #
class VersionResponse(BaseModel):
name: str
currentVersion: str
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)


# --- REQUEST MODELS --- #
class SnapshotRequest(GenericRequest):
pass

Expand All @@ -28,7 +27,6 @@ class SnapshotListRequest(GenericPaginationRequest):
pass


# --- RESPONSE MODELS --- #
class SnapshotResponse(GenericResponse):
version: str
original: dict
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/snapshotfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)


# --- REQUEST MODELS --- #
class SnapshotFileRequest(GenericRequest):
pass

Expand All @@ -28,7 +27,6 @@ class SnapshotFileListRequest(GenericPaginationRequest):
pass


# --- RESPONSE MODELS --- #
class SnapshotFileResponse(GenericResponse):
snapshot_id: str
file_id: str
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)


# --- REQUEST MODELS --- #
class TaskRequest(GenericRequest):
pass

Expand All @@ -28,7 +27,6 @@ class TaskListRequest(GenericPaginationRequest):
pass


# --- RESPONSE MODELS --- #
class TaskResponse(GenericResponse):
name: str
error: str
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
)


# --- REQUEST MODELS --- #
class UserRequest(GenericRequest):
pass

Expand Down Expand Up @@ -54,7 +53,6 @@ class UserGroupListRequest(UserGroupRequest, GenericPaginationRequest):
pass


# --- RESPONSE MODELS --- #
class UserResponse(GenericResponse):
fullName: str
username: str
Expand Down
2 changes: 0 additions & 2 deletions console/api/models/userpermission.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
)


# --- REQUEST MODELS --- #
class UserPermissionRequest(GenericRequest):
pass

Expand All @@ -43,7 +42,6 @@ class UserPermissionRevokeRequest(BaseModel):
resourceType: Literal["file", "group", "organization", "workspace"]


# --- RESPONSE MODELS --- #
class UserPermissionResponse(GenericResponse):
user_id: str
resource_id: str
Expand Down
Loading

0 comments on commit a838821

Please sign in to comment.