Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rating_api/models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def order_by_mark(self, query: str, asc_order: bool) -> UnaryExpression[float] |
def search_by_lectorer_id(self, query: int) -> bool:
if not query:
return true()
return Comment.lecturer_id == query
return and_(Comment.review_status == ReviewStatus.APPROVED, Comment.lecturer_id == query)

@hybrid_method
def search_by_user_id(self, query: int) -> bool:
Expand All @@ -149,7 +149,7 @@ def search_by_user_id(self, query: int) -> bool:
def search_by_subject(self, query: str) -> bool:
if not query:
return true()
return func.lower(Comment.subject).contains(query.lower())
return and_(Comment.review_status == ReviewStatus.APPROVED, func.lower(Comment.subject).contains(query))


class LecturerUserComment(BaseDbModel):
Expand Down
2 changes: 1 addition & 1 deletion rating_api/routes/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ async def review_comment(
`approved` - комментарий одобрен и возвращается при запросе лектора
`dismissed` - комментарий отклонен, не отображается в запросе лектора
"""

check_comment: Comment = Comment.query(session=db.session).filter(Comment.uuid == uuid).one_or_none()

if not check_comment:
raise ObjectNotFound(Comment, uuid)

Expand Down
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import uuid

import pytest
from fastapi.testclient import TestClient
from sqlalchemy import create_engine
Expand Down Expand Up @@ -46,6 +48,7 @@ def lecturer(dbsession):
@pytest.fixture
def comment(dbsession, lecturer):
_comment = Comment(
uuid=uuid.uuid4(),
user_id=0,
create_ts="2025-04-25T19:38:56.408Z",
subject="test_subject",
Expand Down