Removed / from audit routes

This commit is contained in:
Saurab-Shrestha 2024-05-07 15:41:28 +05:45
parent 333a3f3913
commit c6847859b0
7 changed files with 27 additions and 30 deletions

4
.env
View File

@ -1,11 +1,11 @@
PORT=8000 PORT=8000
ENVIRONMENT=dev ENVIRONMENT=dev
DB_HOST=db DB_HOST=localhost
DB_USER=postgres DB_USER=postgres
DB_PORT=5432 DB_PORT=5432
DB_PASSWORD=admin DB_PASSWORD=admin
DB_NAME=QuickGpt DB_NAME=GPT
SUPER_ADMIN_EMAIL=superadmin@email.com SUPER_ADMIN_EMAIL=superadmin@email.com
SUPER_ADMIN_PASSWORD=supersecretpassword SUPER_ADMIN_PASSWORD=supersecretpassword

View File

@ -54,7 +54,7 @@ def create_app(root_injector: Injector) -> FastAPI:
"http://192.168.1.98", "http://192.168.1.98:3000", "http://localhost:3000","https://globaldocquery.gibl.com.np/", "http://127.0.0.1/", "http://localhost/", "http://192.168.1.98", "http://192.168.1.98:3000", "http://localhost:3000","https://globaldocquery.gibl.com.np/", "http://127.0.0.1/", "http://localhost/",
"http://localhost:80", "http://192.168.1.131", 'http://192.168.1.131:3000' "http://localhost:80", "http://192.168.1.131", 'http://192.168.1.131:3000'
, "http://192.168.1.127", 'http://192.168.1.127:3000' , "http://192.168.1.127", 'http://192.168.1.127:3000'
, "http://192.168.1.89", 'http://192.168.1.89:3000' , "http://192.168.1.89", 'http://192.168.1.89:3000',
], ],
allow_methods=["DELETE", "GET", "POST", "PUT", "OPTIONS", "PATCH"], allow_methods=["DELETE", "GET", "POST", "PUT", "OPTIONS", "PATCH"],
allow_headers=["*"], allow_headers=["*"],

View File

@ -232,7 +232,4 @@ async def prompt_completion(
except Exception as e: except Exception as e:
print(traceback.format_exc()) print(traceback.format_exc())
logger.error(f"There was an error: {str(e)}") logger.error(f"There was an error: {str(e)}")
raise HTTPException( raise
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Internal Server Error",
)

View File

@ -40,26 +40,26 @@ def list_auditlog(
logs = crud.audit.get_multi_desc(db, skip=skip, limit=limit) logs = crud.audit.get_multi_desc(db, skip=skip, limit=limit)
return convert_audit_logs(db, logs) return convert_audit_logs(db, logs)
@router.get("filter/", response_model=List[schemas.Audit]) @router.get("/filter", response_model=List[schemas.Audit])
def filter_auditlog( def filter_auditlog(
db: Session = Depends(deps.get_db), db: Session = Depends(deps.get_db),
filter_in= Depends(schemas.AuditFilter), filter_in= Depends(schemas.AuditFilter),
# current_user: models.User = Security( current_user: models.User = Security(
# deps.get_current_user, deps.get_current_user,
# scopes=[Role.SUPER_ADMIN["name"]], scopes=[Role.SUPER_ADMIN["name"]],
# ), ),
) -> List[schemas.Audit]: ) -> List[schemas.Audit]:
logs = crud.audit.filter(db, obj_in=filter_in) logs = crud.audit.filter(db, obj_in=filter_in)
return convert_audit_logs(db, logs) return convert_audit_logs(db, logs)
@router.get("download/") @router.get("/download")
def download_auditlog( def download_auditlog(
db: Session = Depends(deps.get_db), db: Session = Depends(deps.get_db),
filter_in= Depends(schemas.ExcelFilter), filter_in= Depends(schemas.ExcelFilter),
# current_user: models.User = Security( current_user: models.User = Security(
# deps.get_current_user, deps.get_current_user,
# scopes=[Role.SUPER_ADMIN["name"]], scopes=[Role.SUPER_ADMIN["name"]],
# ), ),
): ):
logs = crud.audit.excel_filter(db, obj_in=filter_in) logs = crud.audit.excel_filter(db, obj_in=filter_in)
username = filter_in.username if filter_in.username else None username = filter_in.username if filter_in.username else None

View File

@ -49,7 +49,7 @@ def list_departments(
""" """
try: try:
role = current_user.user_role.role.name if current_user.user_role else None role = current_user.user_role.role.name if current_user.user_role else None
if role == "SUPER_ADMIN": if (role == "SUPER_ADMIN") or (role == "OPERATOR"):
deps = crud.department.get_multi(db) deps = crud.department.get_multi(db)
else: else:
deps = crud.department.get_multi_department( deps = crud.department.get_multi_department(

View File

@ -366,7 +366,7 @@ async def verify_documents(
checker = schemas.DocumentCheckerUpdate( checker = schemas.DocumentCheckerUpdate(
action_type=MakerCheckerActionType.UPDATE, action_type=MakerCheckerActionType.UPDATE,
status=MakerCheckerStatus.APPROVED, status=MakerCheckerStatus.APPROVED,
is_enabled=False, is_enabled=True,
verified_at=datetime.now(), verified_at=datetime.now(),
verified_by=current_user.id, verified_by=current_user.id,
verified=True, verified=True,

View File

@ -5,11 +5,11 @@ from pydantic import BaseModel
class AuditBase(BaseModel): class AuditBase(BaseModel):
id: int id: int
model: str model: Optional[str] = None
user_id: int user_id: Optional[int] = None
action: str action: Optional[str] = None
details: dict details: Optional[dict] = None
ip_address: str ip_address: Optional[str] = None
timestamp: Optional[datetime] timestamp: Optional[datetime]
@ -29,12 +29,12 @@ class AuditInDB(AuditBase):
class Audit(BaseModel): class Audit(BaseModel):
id: int id: int
model: str model: Optional[str] = None
username: str username: Optional[str] = None
action: str action: Optional[str] = None
details: dict details: Optional[dict] = None
timestamp: Optional[datetime] timestamp: Optional[datetime]= None
ip_address: str ip_address: Optional[str] = None
class GetAudit(BaseModel): class GetAudit(BaseModel):