Skip to content

Commit

Permalink
fix: rename class
Browse files Browse the repository at this point in the history
  • Loading branch information
craigyu committed Sep 13, 2024
1 parent 1b63d6a commit e7b1133
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions server/backend/api/app/crud/crud_permission_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
from sqlalchemy import and_
from typing import List
from api.app.models.model import FamPrivilegeChangeAudit
from api.app.schemas import PermissionAuditHistoryResDto
from api.app.schemas import PermissionAduitHistoryRes


def read_permission_audit_history_by_user_and_application(
user_id: int, application_id: int, db: Session
) -> List[PermissionAuditHistoryResDto]:
) -> List[PermissionAduitHistoryRes]:
"""
Retrieve the permission audit history for a given user and application,
ordered by the date of the change.
:param user_id: The ID of the user whose permission changes are being queried.
:param application_id: The ID of the application associated with the permission changes.
:param db: The database session used for querying.
:return: A list of PermissionAuditHistoryResDto instances representing the audit history records.
:return: A list of PermissionAduitHistoryRes instances representing the audit history records.
"""

# Query the FamPrivilegeChangeAudit table for records matching the user_id and application_id,
Expand All @@ -34,7 +34,7 @@ def read_permission_audit_history_by_user_and_application(

# Convert the ORM model instances to Pydantic DTO instances
audit_history_dto = [
PermissionAuditHistoryResDto.model_validate(record)
PermissionAduitHistoryRes.model_validate(record)
for record in audit_history_records
]

Expand Down
6 changes: 3 additions & 3 deletions server/backend/api/app/routers/router_permission_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from api.app import database
from api.app.routers.router_guards import authorize_by_app_id
from api.app.schemas import PermissionAuditHistoryResDto
from api.app.schemas import PermissionAduitHistoryRes
from api.app.crud.crud_permission_audit import (
read_permission_audit_history_by_user_and_application,
)
Expand All @@ -16,7 +16,7 @@

@router.get(
"",
response_model=List[PermissionAuditHistoryResDto],
response_model=List[PermissionAduitHistoryRes],
status_code=200,
dependencies=[Depends(authorize_by_app_id)],
)
Expand All @@ -33,7 +33,7 @@ async def get_permission_audit_history_by_user_and_application(
applicationId (int): The ID of the application associated with the audit history.
Returns:
List[PermissionAuditHistoryResDto]: A list of audit history records for the given user and application.
List[PermissionAduitHistoryRes]: A list of audit history records for the given user and application.
"""
return read_permission_audit_history_by_user_and_application(
user_id=user_id, application_id=application_id, db=db
Expand Down
2 changes: 1 addition & 1 deletion server/backend/api/app/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
# ---------- Permission Audit History Schemas ---------- #
from .privilege_details import PrivilegeDetailsSchema
from .privilege_change_performer import PrivilegeChangePerformerSchema
from .permission_audit_history import PermissionAuditHistoryResDto
from .permission_audit_history import PermissionAduitHistoryRes
2 changes: 1 addition & 1 deletion server/backend/api/app/schemas/permission_audit_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .privilege_change_performer import PrivilegeChangePerformerSchema


class PermissionAuditHistoryResDto(BaseModel):
class PermissionAduitHistoryRes(BaseModel):
"""
This class is used to transfer data related to the changes made to a user's permissions,
typically in the context of an audit trail. It encapsulates details about the change,
Expand Down
2 changes: 1 addition & 1 deletion server/backend/testspg/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from api.app import constants as fam_constants
from api.app.models.model import FamPrivilegeChangeAudit
from api.app.schemas.permission_audit_history import PermissionAuditHistoryResDto
from api.app.schemas.permission_audit_history import PermissionAduitHistoryRes


# --------------------- Testing application ---------------------------- #
Expand Down
4 changes: 2 additions & 2 deletions server/backend/testspg/fixture/permission_audit_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
)
from api.app.models.model import FamPrivilegeChangeAudit
from api.app.schemas import (
PermissionAuditHistoryResDto,
PermissionAduitHistoryRes,
PrivilegeChangePerformerSchema,
PrivilegeDetailsSchema,
)
Expand Down Expand Up @@ -99,7 +99,7 @@
)

MOCKED_PERMISSION_HISTORY_RESPONSE = [
PermissionAuditHistoryResDto(
PermissionAduitHistoryRes(
change_date=CHANGE_DATE_1,
change_performer_user_details=PERFORMER_DETAILS_1,
change_performer_user_id=1,
Expand Down

0 comments on commit e7b1133

Please sign in to comment.