Use migration without helper class
This commit is contained in:
parent
61458b7761
commit
b705e68e3b
|
|
@ -5,12 +5,13 @@ from django.db import migrations
|
|||
|
||||
def set_default_school_class(apps, schema_editor):
|
||||
Project = apps.get_model('portfolio', 'Project')
|
||||
User = apps.get_model('users', 'User')
|
||||
UserSetting = apps.get_model('users', 'UserSetting')
|
||||
projects = Project.objects.all()
|
||||
bulk_projects = []
|
||||
for project in projects:
|
||||
owner = User.objects.get(id=project.student.id)
|
||||
selected_class = owner._get_selected_class()
|
||||
owner = project.student
|
||||
settings = UserSetting.objects.get(user=owner)
|
||||
selected_class = settings.selected_class
|
||||
if selected_class is not None:
|
||||
project.school_class = selected_class
|
||||
bulk_projects.append(project)
|
||||
|
|
|
|||
Loading…
Reference in New Issue