예제 #1
0
    def update(self, instance, validated_data):
        try:
            update_account(instance.account, validated_data.pop('account'))
        except KeyError:
            pass

        try:
            update_person(instance.person, validated_data.pop('person'))
        except KeyError:
            pass

        try:
            if instance.health is None:
                health = create_health(validated_data.pop('health'))
                assign_health(instance, health)
            else:
                update_health(instance, validated_data.pop('health'))
        except:
            pass

        instance.classroom_id = validated_data.get('classroom_id',
                                                   instance.classroom_id)
        instance.status = validated_data.get('status', instance.status)
        instance.admission_year = validated_data.get('admission_year',
                                                     instance.admission_year)
        instance.save()
        return instance
예제 #2
0
    def update(self, instance, validated_data):
        try:
            update_person(instance.person, validated_data.pop('person'))
        except KeyError:
            pass

        instance.save()
        return instance
예제 #3
0
    def update(self, instance, validated_data):
        try:
            update_person(instance.person, validated_data.pop('person'))
        except KeyError:
            pass

        instance.students.clear()
        for student in validated_data.pop('students'):
            instance.students.add(student)

        instance.save()
        return instance