add achievements field to user model

This commit is contained in:
Timur
2025-03-02 15:17:38 +03:00
parent b631b09648
commit 05f8300976
4 changed files with 44 additions and 1 deletions
@@ -0,0 +1,20 @@
from http import HTTPStatus as status
from ninja import Router
from apps.achievement.models import Achievement
from api.v1.achievement.schemas import AchievementSchema
from api.v1.schemas import UnauthorizedError
router = Router()
@router.get(
"",
response={
status.OK: list[AchievementSchema],
status.UNAUTHORIZED: UnauthorizedError,
}
)
def get_all_achievements(request):
return Achievement.objects.all()
+1 -1
View File
@@ -22,4 +22,4 @@ class LoginSchema(ModelSchema):
class UserSchema(ModelSchema):
class Meta:
model = User
fields = ["id", "email", "username", "created_at",]
fields = ["id", "email", "username", "created_at", "achievements"]