Add default users
This commit is contained in:
parent
74f25850f1
commit
72cab13b36
|
|
@ -13,7 +13,6 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
border-radius: 13px;
|
border-radius: 13px;
|
||||||
|
|
||||||
margin-bottom: 30px;
|
margin-bottom: 30px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -661,6 +661,43 @@ data = [
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
user_data = [
|
||||||
|
{
|
||||||
|
'teacher': ('Nico', 'Zickgraf',),
|
||||||
|
'class': 'FLID2018a',
|
||||||
|
'students': [
|
||||||
|
('Robin', 'Abbühl'),
|
||||||
|
('Zeynep', 'Catal'),
|
||||||
|
('Rahel', 'Cueni'),
|
||||||
|
('Ismatou', 'Diallo'),
|
||||||
|
('Mischa', 'Frech'),
|
||||||
|
('Melody', 'Merz'),
|
||||||
|
('Joelle', 'Perren'),
|
||||||
|
('Luca', 'Rutschmann'),
|
||||||
|
('Selina', 'Teuscher'),
|
||||||
|
('Kelly', 'To'),
|
||||||
|
('Deborah', 'Waldmeier'),
|
||||||
|
('Rahel', 'Weiss'),
|
||||||
|
('Nora', 'Zimmermann'),
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'teacher': ('Michael', 'Gurtner',),
|
||||||
|
'class': 'KF1A',
|
||||||
|
'students': [
|
||||||
|
('Lisa', 'Arn'),
|
||||||
|
('Machado', 'Fernandes'),
|
||||||
|
('Sandro', 'Gyger'),
|
||||||
|
('Alain', 'Hofer'),
|
||||||
|
('Adrian', 'Luder'),
|
||||||
|
('Louis', 'Scherer'),
|
||||||
|
('Xhavit', 'Shala'),
|
||||||
|
('Marc', 'Uebersax'),
|
||||||
|
('Roman', 'Weber'),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
|
||||||
|
|
@ -696,7 +733,7 @@ class Command(BaseCommand):
|
||||||
is_superuser=True
|
is_superuser=True
|
||||||
)
|
)
|
||||||
|
|
||||||
create_school_with_users('skillbox')
|
create_school_with_users('skillbox', user_data)
|
||||||
|
|
||||||
for book_idx, book_data in enumerate(data):
|
for book_idx, book_data in enumerate(data):
|
||||||
book = BookFactory.create(parent=site.root_page, **self.filter_data(book_data, 'topics'))
|
book = BookFactory.create(parent=site.root_page, **self.filter_data(book_data, 'topics'))
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,46 @@ from users.factories import SchoolClassFactory
|
||||||
from users.models import School, SchoolRole, UserSchoolRole, DEFAULT_SCHOOL_ID
|
from users.models import School, SchoolRole, UserSchoolRole, DEFAULT_SCHOOL_ID
|
||||||
|
|
||||||
|
|
||||||
def create_school_with_users(school_name):
|
def create_school_with_users(school_name, data=None):
|
||||||
school = School.create_school(school_name, id=DEFAULT_SCHOOL_ID)
|
school = School.create_school(school_name, id=DEFAULT_SCHOOL_ID)
|
||||||
|
|
||||||
teacher_role = SchoolRole.objects.get_default_teacher_role_for_school(school)
|
teacher_role = SchoolRole.objects.get_default_teacher_role_for_school(school)
|
||||||
teacher = UserFactory(username='teacher')
|
|
||||||
UserSchoolRole.objects.create(user=teacher, school_role=teacher_role)
|
|
||||||
|
|
||||||
student_role = SchoolRole.objects.get_default_student_role_for_school(school)
|
student_role = SchoolRole.objects.get_default_student_role_for_school(school)
|
||||||
for i in range(1, 7):
|
|
||||||
student = UserFactory(username='student{}'.format(i))
|
if data is None:
|
||||||
UserSchoolRole.objects.create(user=student, school_role=student_role)
|
teacher = UserFactory(username='teacher')
|
||||||
SchoolClassFactory(users=[teacher, student], school=school)
|
UserSchoolRole.objects.create(user=teacher, school_role=teacher_role)
|
||||||
|
|
||||||
|
for i in range(1, 7):
|
||||||
|
student = UserFactory(username='student{}'.format(i))
|
||||||
|
UserSchoolRole.objects.create(user=student, school_role=student_role)
|
||||||
|
SchoolClassFactory(users=[teacher, student], school=school)
|
||||||
|
|
||||||
|
else:
|
||||||
|
for school_class in data:
|
||||||
|
first, last = school_class.get('teacher')
|
||||||
|
teacher = UserFactory(
|
||||||
|
username='{}.{}'.format(first, last).lower(),
|
||||||
|
first_name=first,
|
||||||
|
last_name=last,
|
||||||
|
email='{}.{}@skillbox.example'.format(first, last).lower()
|
||||||
|
)
|
||||||
|
UserSchoolRole.objects.create(user=teacher, school_role=teacher_role)
|
||||||
|
students = []
|
||||||
|
|
||||||
|
for first, last in school_class.get('students'):
|
||||||
|
student = UserFactory(
|
||||||
|
username='{}.{}'.format(first, last).lower(),
|
||||||
|
first_name=first,
|
||||||
|
last_name=last,
|
||||||
|
email='{}.{}@skillbox.example'.format(first, last).lower()
|
||||||
|
)
|
||||||
|
UserSchoolRole.objects.create(user=student, school_role=student_role)
|
||||||
|
students.append(student)
|
||||||
|
|
||||||
|
SchoolClassFactory(
|
||||||
|
users=students + [teacher],
|
||||||
|
school=school,
|
||||||
|
name=school_class.get('class'),
|
||||||
|
year='2018'
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue