Skip to content

Commit

Permalink
Quality flake/black
Browse files Browse the repository at this point in the history
  • Loading branch information
boot-sandre committed Oct 20, 2023
1 parent 0e82c8d commit 9ef23ea
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion main/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
DJANGO_LOG_LEVEL = os.environ.get(
"DJANGO_LOG_LEVEL", default="DEBUG" if DEBUG else "INFO"
)
LOGGING.update( # noqa
LOGGING.update( # noqa
{ # noqa
"root": {
"handlers": ["console"],
Expand Down
4 changes: 1 addition & 3 deletions main/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@

DJANGO_LOG_LEVEL = "INFO"
DJANGO_LOG_SQL_LEVEL = "INFO"
DJANGO_LOG_LEVEL = os.environ.get(
"DJANGO_LOG_LEVEL", default=DJANGO_LOG_LEVEL
)
DJANGO_LOG_LEVEL = os.environ.get("DJANGO_LOG_LEVEL", default=DJANGO_LOG_LEVEL)
DJANGO_LOG_SQL_LEVEL = os.environ.get(
"DJANGO_LOG_SQL_LEVEL", default=DJANGO_LOG_SQL_LEVEL
)
Expand Down
1 change: 0 additions & 1 deletion skii/endpoint/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ def custom_expression(self) -> Q:
stop__lte=self.stop
) # Filter for lessons stopping less than or equal to self.stop
return q_filter

7 changes: 4 additions & 3 deletions skii/endpoint/routers/agenda.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from skii.endpoint.schemas.response import StudentLessonContract
from skii.endpoint.schemas.identifier import IntStrUUID4
from skii.platform.models.event import LessonEvent
from skii.platform.schemas.event import LessonContract

UserModel = get_user_model()
MsgErrorStudent = _(
Expand Down Expand Up @@ -78,8 +77,10 @@ def student_lessons(
# If the logged user is a Student (filter(user=request.user).exist())
# and different than the requested one (request.user)
# Raise a Permission error.
if (request.user != agent.user and
StudentAgent.objects.filter(user=request.user).exists()):
if (
request.user != agent.user
and StudentAgent.objects.filter(user=request.user).exists()
):
raise PermissionError(MsgErrorStudent)

lessons = filters.filter(LessonEvent.objects.filter(students__pk=agent.pk))
Expand Down
2 changes: 1 addition & 1 deletion skii/endpoint/schemas/response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Type

from ninja import Schema, Field
from ninja import Schema
from django.db.models import Model

from skii.platform.schemas.agent import TeacherContract
Expand Down
40 changes: 20 additions & 20 deletions tests/endpoint/test_api_agenda.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def test_cross_teacher_lesson(self):
def test_teacher_lesson_range_start_to_stop(self):
"""Can fetch teacher lesson with range start/stop filter."""
self.client_auth(self._teacher)
lesson_ref_start: LessonEvent = LessonEvent.objects.filter(
teacher=self._teacher
).order_by("start").last()
lesson_ref_stop: LessonEvent = LessonEvent.objects.filter(
teacher=self._teacher
).order_by("stop").last()
lesson_ref_start: LessonEvent = (
LessonEvent.objects.filter(teacher=self._teacher).order_by("start").last()
)
lesson_ref_stop: LessonEvent = (
LessonEvent.objects.filter(teacher=self._teacher).order_by("stop").last()
)
res = self.client.get(
"skii:teacher_lessons",
dict(start=lesson_ref_start.start, stop=lesson_ref_stop.stop),
Expand All @@ -110,7 +110,7 @@ def test_teacher_lesson_range_start_to_stop(self):
len(result["lessons_assigned"]),
1,
msg=f"Needs fetch lesson start after {lesson_ref_start.start} "
f"and stop before {lesson_ref_stop.stop}",
f"and stop before {lesson_ref_stop.stop}",
)

def test_student_lessons_required_keys(self):
Expand Down Expand Up @@ -176,12 +176,12 @@ def test_teacher_can_fetch_student_lesson(self):
def test_student_lesson_range_start_to_stop(self):
"""Can fetch student lesson with range start/stop filter."""
self.client_auth(self._student)
lesson_ref_start: LessonEvent = LessonEvent.objects.filter(
students=self._student
).order_by("start").last()
lesson_ref_stop: LessonEvent = LessonEvent.objects.filter(
students=self._student
).order_by("stop").last()
lesson_ref_start: LessonEvent = (
LessonEvent.objects.filter(students=self._student).order_by("start").last()
)
lesson_ref_stop: LessonEvent = (
LessonEvent.objects.filter(students=self._student).order_by("stop").last()
)
res = self.client.get(
"skii:student_lessons",
dict(start=lesson_ref_start.start, stop=lesson_ref_stop.stop),
Expand All @@ -192,15 +192,15 @@ def test_student_lesson_range_start_to_stop(self):
len(result["lessons_subscribed"]),
1,
msg=f"Needs fetch lesson start after {lesson_ref_start.start} "
f"and stop before {lesson_ref_stop.stop}",
f"and stop before {lesson_ref_stop.stop}",
)

def test_student_lesson_filter_only_start(self):
"""Can fetch student lesson with only start filter."""
self.client_auth(self._student)
lesson_ref: LessonEvent = LessonEvent.objects.filter(
students=self._student
).order_by("start").last()
lesson_ref: LessonEvent = (
LessonEvent.objects.filter(students=self._student).order_by("start").last()
)
res = self.client.get(
"skii:student_lessons",
dict(start=lesson_ref.start),
Expand All @@ -216,9 +216,9 @@ def test_student_lesson_filter_only_start(self):
def test_student_lesson_filter_only_stop(self):
"""Can fetch student lesson with only stop filter."""
self.client_auth(self._student)
lesson_ref: LessonEvent = LessonEvent.objects.filter(
students=self._student
).order_by("stop").first()
lesson_ref: LessonEvent = (
LessonEvent.objects.filter(students=self._student).order_by("stop").first()
)
res = self.client.get(
"skii:student_lessons",
dict(stop=lesson_ref.stop),
Expand Down

0 comments on commit 9ef23ea

Please sign in to comment.