Resolve member objects in lockout auth update script
This commit is contained in:
parent
86f4862dbe
commit
9ad64cbf5a
|
@ -10,11 +10,20 @@ from apiserver.api import models, utils
|
||||||
print("Updating member orientation dates")
|
print("Updating member orientation dates")
|
||||||
sessions = models.Session.objects.filter(course = 249)
|
sessions = models.Session.objects.filter(course = 249)
|
||||||
|
|
||||||
|
def get_member(obj):
|
||||||
|
# same as in serialzers.py -> get_cards for example
|
||||||
|
if obj.user:
|
||||||
|
member = obj.user.member
|
||||||
|
else:
|
||||||
|
member = models.Member.objects.get(id=obj.member_id)
|
||||||
|
return member
|
||||||
|
|
||||||
|
|
||||||
for session in sessions:
|
for session in sessions:
|
||||||
students = models.Training.objects.filter(session = session)
|
students = models.Training.objects.filter(session = session)
|
||||||
for student in students:
|
for student in students:
|
||||||
if student.member_id and student.attendance_status == "Attended":
|
if student.attendance_status == "Attended":
|
||||||
member = models.Member.objects.get(pk=student.member_id)
|
member = get_member(student)
|
||||||
if not member.orientation_date:
|
if not member.orientation_date:
|
||||||
member.orientation_date = session.datetime
|
member.orientation_date = session.datetime
|
||||||
member.save()
|
member.save()
|
||||||
|
@ -26,8 +35,8 @@ sessions = models.Session.objects.filter(course = 281)
|
||||||
for session in sessions:
|
for session in sessions:
|
||||||
students = models.Training.objects.filter(session = session)
|
students = models.Training.objects.filter(session = session)
|
||||||
for student in students:
|
for student in students:
|
||||||
if student.member_id and student.attendance_status == "Attended":
|
if student.attendance_status == "Attended":
|
||||||
member = models.Member.objects.get(pk=student.member_id)
|
member = get_member(student)
|
||||||
if not member.lathe_cert_date:
|
if not member.lathe_cert_date:
|
||||||
member.lathe_cert_date = session.datetime
|
member.lathe_cert_date = session.datetime
|
||||||
member.save()
|
member.save()
|
||||||
|
@ -39,8 +48,8 @@ sessions = models.Session.objects.filter(course = 283)
|
||||||
for session in sessions:
|
for session in sessions:
|
||||||
students = models.Training.objects.filter(session = session)
|
students = models.Training.objects.filter(session = session)
|
||||||
for student in students:
|
for student in students:
|
||||||
if student.member_id and student.attendance_status == "Attended":
|
if student.attendance_status == "Attended":
|
||||||
member = models.Member.objects.get(pk=student.member_id)
|
member = get_member(student)
|
||||||
if not member.mill_cert_date:
|
if not member.mill_cert_date:
|
||||||
member.mill_cert_date = session.datetime
|
member.mill_cert_date = session.datetime
|
||||||
member.save()
|
member.save()
|
||||||
|
@ -53,8 +62,8 @@ sessions = models.Session.objects.filter(course = 261)
|
||||||
for session in sessions:
|
for session in sessions:
|
||||||
students = models.Training.objects.filter(session = session)
|
students = models.Training.objects.filter(session = session)
|
||||||
for student in students:
|
for student in students:
|
||||||
if student.member_id and student.attendance_status == "Attended":
|
if student.attendance_status == "Attended":
|
||||||
member = models.Member.objects.get(pk=student.member_id)
|
member = get_member(student)
|
||||||
if not member.wood_cert_date:
|
if not member.wood_cert_date:
|
||||||
member.wood_cert_date = session.datetime
|
member.wood_cert_date = session.datetime
|
||||||
member.save()
|
member.save()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user