Skip to content

Commit

Permalink
quick save
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jan 23, 2025
1 parent 64d068f commit 632d0d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/api/views/auth_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def check_if_exists(self, request: Request[User]):
serializer.is_valid(raise_exception=True)

return Response(
self.get_queryset().filter(**serializer.validated_data).exists()
{
"auth_factor_exists": self.get_queryset()
.filter(**serializer.validated_data)
.exists()
}
)

@action(detail=False, methods=["get"])
Expand Down
2 changes: 1 addition & 1 deletion src/api/views/auth_factor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def test_check_if_exists(self):
},
)

assert response.json() is True
self.assertDictEqual(response.json(), {"auth_factor_exists": True})

def test_get_otp_secret(self):
"""Can successfully generate a OTP provisioning URI."""
Expand Down
4 changes: 4 additions & 0 deletions src/api/views/klass.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class ClassViewSet(_ClassViewSet):
http_method_names = ["get", "post", "patch", "delete"]

# pylint: disable-next=missing-function-docstring
def get_permissions(self):
# Only bulk-partial-update allowed for classes.
if self.action == "bulk":
Expand All @@ -31,12 +32,14 @@ def get_permissions(self):

return super().get_permissions()

# pylint: disable-next=missing-function-docstring
def get_serializer_class(self):
if self.action in ["create", "partial_update", "bulk"]:
return WriteClassSerializer

return ReadClassSerializer

# pylint: disable-next=missing-function-docstring
def get_queryset(self):
if self.action in ["retrieve", "list"]:
return super().get_queryset()
Expand All @@ -48,6 +51,7 @@ def get_queryset(self):
else teacher.classes.filter(teacher=teacher)
)

# pylint: disable-next=missing-function-docstring
def destroy(self, request, *args, **kwargs):
klass = self.get_object()

Expand Down

0 comments on commit 632d0d6

Please sign in to comment.