Skip to content

Commit

Permalink
Fix (#875)
Browse files Browse the repository at this point in the history
* Minor issue

* Minor issue
  • Loading branch information
Dmi4er4 committed Sep 8, 2024
1 parent 8030e73 commit 94f77fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions apps/admission/management/commands/create_partner_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def handle(self, *args, **options):
else datetime.strptime(row["Дата подтверждения согласий (дата и время)"], "%d.%m.%Y %H:%M:%S")
birth_date = datetime.strptime(row["Дата рождения"], "%d.%m.%Y").date()
phone, telegram_username, email = row["Номер телефона"], row["ТГ"].replace("@", ""), row["Почта"]
academic_discipline = AcademicDiscipline.objects.get(name=row["Направление"])
academic_discipline = AcademicDiscipline.objects.get(name=value) if ( value := row[
"Направление"]) else None
try:
user = User.objects.get(email__iexact=email)
mismatched_fields = {
Expand All @@ -136,14 +137,14 @@ def handle(self, *args, **options):
}
mismatches = {field: (current, expected)
for field, (current, expected) in mismatched_fields.items()
if current != expected}
if expected and current != expected}
for field, (current, expected) in mismatches.items():
if trust_csv or not current:
print(f"Changed field '{field}' of user '{user}' from '{current}' to '{expected}'")
setattr(user, field, expected)
user.save()
elif input(f"Change field '{field}' of user '{user}' from '{current}' to '{expected}'?\n"
f"y/[n]: ") == "y":
f"y/[n]: ") == "y":
setattr(user, field, expected)
user.save()
found_counter += 1
Expand All @@ -152,7 +153,7 @@ def handle(self, *args, **options):
try:
user = User.objects.get(last_name=last_name, first_name=first_name)
raise CommandError(f"STUDENT {last_name} {first_name} {patronymic} HAS ACCOUNT WITH EMAIL '"
f"{user.email}', but '{email}' was provided")
f"{user.email}', but '{email}' was provided")
except User.DoesNotExist:
raise CommandError(f"NO PERMISSION FOR NEW STUDENT: {last_name} {first_name} {patronymic}")
user = create_account(username=generate_username_from_email(email),
Expand Down Expand Up @@ -185,14 +186,15 @@ def handle(self, *args, **options):
type=StudentTypes.PARTNER,
partner=partner).exists()
student_profile = create_student_profile(**profile_fields)
student_profile.academic_disciplines.add(academic_discipline)
student_profile.save()
if academic_discipline:
student_profile.academic_disciplines.add(academic_discipline)
student_profile.save()

log_entry = StudentAcademicDisciplineLog(academic_discipline=academic_discipline,
student_profile=student_profile,
entry_author=entry_author,
changed_at=changed_at)
log_entry.save()
log_entry = StudentAcademicDisciplineLog(academic_discipline=academic_discipline,
student_profile=student_profile,
entry_author=entry_author,
changed_at=changed_at)
log_entry.save()

print(f"Found students: {found_counter}")
print(f"Created students: {created_counter}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<div class="left">
<p>
<b>Руководитель академических программ</b><br>
<span style="float: left;">По доверенности от 4 мая 2023г.</span>
<span style="float: left;">По доверенности от 8 августа 2024г.</span>
<span style="float: right;"><b>Бронер В. И.</b></span>
</p>
</div>
Expand Down

0 comments on commit 94f77fd

Please sign in to comment.