Utility to add missing user info to training record
This commit is contained in:
parent
e07cb9a1af
commit
163d0eff55
25
apiserver/training_record_fix.py
Normal file
25
apiserver/training_record_fix.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import django, sys, os
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'apiserver.settings'
|
||||
django.setup()
|
||||
|
||||
import datetime
|
||||
import json
|
||||
from apiserver.api import models, utils
|
||||
|
||||
sessions = models.Session.objects.all()
|
||||
|
||||
for session in sessions:
|
||||
print("ID: {}".format(session.id))
|
||||
students = models.Training.objects.filter(session = session)
|
||||
for student in students:
|
||||
if not student.user and student.member_id:
|
||||
member = models.Member.objects.get(pk=student.member_id)
|
||||
student.user = member.user
|
||||
student.save()
|
||||
if student.user and not student.member_id:
|
||||
member = models.Member.objects.get(user=student.user)
|
||||
student.member_id = member.id
|
||||
student.save()
|
||||
print("\tStudent: {} ({})".format(student.user,student.member_id))
|
||||
|
||||
print('Done.')
|
Loading…
Reference in New Issue
Block a user