Skip to content
Merged
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
24 changes: 8 additions & 16 deletions auth_backend/auth_plugins/lkmsu.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ async def _auth_url(cls):
def get_student(cls, data: dict[str, Any]) -> list[dict[str | Any]]:
student: dict[str, Any] = data.get("student", {})
first_name, last_name, middle_name = '', '', ''
if 'first_name' in data.keys() and data['first_name'] is not None:
first_name = data['first_name']
if 'last_name' in data.keys() and data['last_name'] is not None:
last_name = data['last_name']
if 'middle_name' in data.keys() and data['middle_name'] is not None:
middle_name = data['middle_name']
if 'first_name' in student.keys() and student['first_name'] is not None:
first_name = student['first_name']
if 'last_name' in student.keys() and student['last_name'] is not None:
last_name = student['last_name']
if 'middle_name' in student.keys() and student['middle_name'] is not None:
middle_name = student['middle_name']
full_name = concantenate_strings([first_name, last_name, middle_name])
if not full_name:
full_name = None
Expand All @@ -197,14 +197,8 @@ def get_student(cls, data: dict[str, Any]) -> list[dict[str | Any]]:
@classmethod
def get_entrants(cls, data: dict[str, Any]) -> list[dict[str, Any]]:
student: dict[str, Any] = data.get("student", {})
faculties_names = []
for entrant in student.get('entrants'):
faculties_names.append(entrant.get('faculty', {}).get("name"))
for entrant in student.get('entrants'):
if (
cls.settings.LKMSU_FACULTY_NAME in faculties_names
and entrant.get('faculty', {}).get("name") != cls.settings.LKMSU_FACULTY_NAME
):
for entrant in reversed(student.get('entrants', [])):
if entrant.get('faculty', {}).get("name") != cls.settings.LKMSU_FACULTY_NAME:
continue
if not (group := entrant.get("groups")):
group = [{}]
Expand All @@ -231,8 +225,6 @@ def get_entrants(cls, data: dict[str, Any]) -> list[dict[str, Any]]:
"value": group[0].get("name"),
},
]
if cls.settings.LKMSU_FACULTY_NAME not in faculties_names:
break
return items

@classmethod
Expand Down
Loading