diff --git a/client/src/components/content-blocks/ImageBlock.vue b/client/src/components/content-blocks/ImageBlock.vue index 0e706ea0..bbbd985c 100644 --- a/client/src/components/content-blocks/ImageBlock.vue +++ b/client/src/components/content-blocks/ImageBlock.vue @@ -13,7 +13,6 @@ width: 100%; max-width: 100%; border-radius: 13px; - margin-bottom: 30px; } diff --git a/server/core/management/commands/dummy_data.py b/server/core/management/commands/dummy_data.py index f1692970..95d573e5 100644 --- a/server/core/management/commands/dummy_data.py +++ b/server/core/management/commands/dummy_data.py @@ -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): @@ -696,7 +733,7 @@ class Command(BaseCommand): is_superuser=True ) - create_school_with_users('skillbox') + create_school_with_users('skillbox', user_data) for book_idx, book_data in enumerate(data): book = BookFactory.create(parent=site.root_page, **self.filter_data(book_data, 'topics')) diff --git a/server/users/services.py b/server/users/services.py index 555f2ac6..90b1e660 100644 --- a/server/users/services.py +++ b/server/users/services.py @@ -3,15 +3,46 @@ from users.factories import SchoolClassFactory 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) 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) - 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) + + if data is None: + teacher = UserFactory(username='teacher') + 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' + )