Beispiel #1
0
    def handle(self, *args, **options):

        import codecs
        fp = codecs.open('sch2.txt', encoding='utf-8')

        for line in fp:
            parts = [x.strip() for x in line.split('\t')]

            grade_raw = parts[0]
            gender_raw = parts[5]
            gender = 'W'
            if gender_raw == '0':
                gender = 'M'
            pdata = dict(
                first_name=parts[2],
                last_name=parts[1],
                gender=gender,
                #birthday
            )

            grade = Grade.objects.get(name=grade_raw)
            print pdata['first_name'], pdata['last_name']
            print grade.name

            pupil = Pupil(**pdata)
            pupil.save()
            participation = GradeParticipant(pupil=pupil, grade=grade)
            participation.save()
    def create_objects(self):
        test_school = School(name="Test_School",
                             domain="something",
                             address="something",
                             contact_person="someone")
        test_school.save()
        self.register(School, test_school)

        test_teacher = Teacher(gender='m',
                               phone="123123123",
                               school=test_school)
        test_teacher.save()
        self.register(Teacher, test_teacher)

        test_grade = Grade(name="test_Grade", school=test_school)
        test_grade.save()
        self.register(Grade, test_grade)

        test_pupil = Pupil(first_name="Markus",
                           last_name="Mueller",
                           gender='m',
                           birthday=datetime.now(),
                           school=test_school)
        test_pupil.save()
        self.register(Pupil, test_pupil)

        test_skill = Skill(name="test_skill", weight=0)
        test_skill.save()
        self.register(Skill, test_skill)
    def handle(self, *args, **options):

        import codecs
        fp = codecs.open('sch2.txt', encoding='utf-8')
        
        for line in fp:
            parts = [x.strip() for x in line.split('\t')]
            
            grade_raw=parts[0]
            gender_raw=parts[5]
            gender='W'
            if gender_raw=='0':
                gender='M'
            pdata = dict(
                first_name=parts[2],
                last_name=parts[1],
                gender=gender,
                #birthday
            )
            
            grade = Grade.objects.get(name=grade_raw)
            print pdata['first_name'], pdata['last_name']
            print grade.name
            
            
            
            pupil = Pupil(**pdata)
            pupil.save()
            participation = GradeParticipant(
                pupil=pupil,
                grade=grade
            )
            participation.save()
Beispiel #4
0
    def create_objects(self):
        test_school = School(name="Test_School",domain="something",address="something",contact_person="someone")
        test_school.save()
        self.register(School,test_school)
        
        test_teacher = Teacher(gender='m',phone="123123123",school=test_school)
        test_teacher.save()
        self.register(Teacher,test_teacher)
        
        test_grade = Grade(name="test_Grade",school=test_school)
        test_grade.save()
        self.register(Grade,test_grade)

        test_pupil = Pupil(first_name="Markus",last_name="Mueller",gender='m',birthday=datetime.now(),school=test_school)
        test_pupil.save()
        self.register(Pupil,test_pupil)
        
        test_skill = Skill(name="test_skill",weight=0)
        test_skill.save()
        self.register(Skill,test_skill)