Skip to content

Commit

Permalink
fix teacher properties
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jun 21, 2024
1 parent b00d7de commit 1f19565
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 0 additions & 3 deletions codeforlife/user/models/teacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ def teacher_as_type(
Returns:
An instance of the typed teacher.
"""
# TODO: remove in new schema
if teacher is None:
return None

return typed_teacher_class(
pk=teacher.pk,
Expand Down
18 changes: 14 additions & 4 deletions codeforlife/user/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ def teacher(self):
# pylint: disable-next=import-outside-toplevel
from .teacher import SchoolTeacher, teacher_as_type

return teacher_as_type(super().teacher, SchoolTeacher)
teacher = super().teacher

return teacher_as_type(teacher, SchoolTeacher) if teacher else None


# pylint: disable-next=missing-class-docstring,too-few-public-methods
Expand Down Expand Up @@ -341,7 +343,9 @@ def teacher(self):
# pylint: disable-next=import-outside-toplevel
from .teacher import AdminSchoolTeacher, teacher_as_type

return teacher_as_type(super().teacher, AdminSchoolTeacher)
teacher = super().teacher

return teacher_as_type(teacher, AdminSchoolTeacher) if teacher else None


# pylint: disable-next=missing-class-docstring,too-few-public-methods
Expand Down Expand Up @@ -369,7 +373,11 @@ def teacher(self):
# pylint: disable-next=import-outside-toplevel
from .teacher import NonAdminSchoolTeacher, teacher_as_type

return teacher_as_type(super().teacher, NonAdminSchoolTeacher)
teacher = super().teacher

return (
teacher_as_type(teacher, NonAdminSchoolTeacher) if teacher else None
)


# pylint: disable-next=missing-class-docstring,too-few-public-methods
Expand All @@ -395,7 +403,9 @@ def teacher(self):
# pylint: disable-next=import-outside-toplevel
from .teacher import NonSchoolTeacher, teacher_as_type

return teacher_as_type(super().teacher, NonSchoolTeacher)
teacher = super().teacher

Check warning on line 406 in codeforlife/user/models/user.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/user/models/user.py#L406

Added line #L406 was not covered by tests

return teacher_as_type(teacher, NonSchoolTeacher) if teacher else None

Check warning on line 408 in codeforlife/user/models/user.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/user/models/user.py#L408

Added line #L408 was not covered by tests


# pylint: disable-next=missing-class-docstring,too-few-public-methods
Expand Down

0 comments on commit 1f19565

Please sign in to comment.