def test_bulk_create_additional_information(self):
     self.teacher_login()
     applicant = self.sample_applicant
     new_custom_field = ApplicantCustomField()
     new_custom_field.save()
     previous_count = ApplicantAdditionalInformation.objects.count()
     response = self.client.post('/api/applicant/', data = applicant)
     applicant_id = response.data["id"]
     data = [
         {"applicant": applicant_id, "custom_field" : new_custom_field.id, "answer" : "world"},
         {"applicant": applicant_id, "custom_field" : new_custom_field.id, "answer" : "still world"}
     ]
     response = self.client.post('/api/applicant-additional-information/', data)
     new_count = ApplicantAdditionalInformation.objects.count()
     self.assertEqual(new_count, previous_count + 2)
    def test_single_create_additional_information(self):
        self.teacher_login()
        applicant = self.sample_applicant
        new_custom_field = ApplicantCustomField()
        new_custom_field.save()
        previous_count = ApplicantAdditionalInformation.objects.count()
        response = self.client.post('/api/applicant/', data=applicant)
        applicant_id = response.data["id"]
        data = {
            "applicant": applicant_id,
            "custom_field": new_custom_field.id,
            "answer": "world"
        }

        response = self.client.post('/api/applicant-additional-information/',
                                    data)
        new_count = ApplicantAdditionalInformation.objects.count()
        self.assertEqual(new_count, previous_count + 1)
Exemple #3
0
    def create_default_admission_application(self):
        if ApplicantCustomField.objects.first():
            raise CommandError('''You have already generated the default 
            application template; this command only works with a fresh db''')
        else:
            default_custom_fields = self.load_default_custom_fields()
            for field in default_custom_fields:
                f = ApplicantCustomField(
                    field_name=field['field_name'],
                    is_field_integrated_with_applicant=field[
                        'is_field_integrated_with_applicant'],
                    field_type=field['field_type'],
                    field_label=field['field_label'],
                    field_choices=field['field_choices'],
                    helptext=field['helptext'],
                    required=field['required'])
                f.id = field['id']
                f.save()

        application_template = self.load_default_application_template()
        self.save_template_as_default_application(application_template)
    def create_default_admission_application(self):
        if ApplicantCustomField.objects.first():
            raise CommandError('''You have already generated the default 
            application template; this command only works with a fresh db''')
        else:
            default_custom_fields = self.load_default_custom_fields()
            for field in default_custom_fields:
                f = ApplicantCustomField(
                    field_name = field['field_name'],
                    is_field_integrated_with_applicant = field['is_field_integrated_with_applicant'],
                    field_type = field['field_type'],
                    field_label = field['field_label'],
                    field_choices = field['field_choices'],
                    helptext = field['helptext'],
                    required = field['required']
                )
                f.id = field['id']
                f.save()

        application_template = self.load_default_application_template()
        self.save_template_as_default_application(application_template)
    def handle(self, *args, **options):
        if ApplicantCustomField.objects.first():
            raise CommandError('You have already generated the default fields')
        else:
            default_custom_fields = self.load_default_custom_fields()
            for field in default_custom_fields:
                f = ApplicantCustomField(
                    field_name=field['field_name'],
                    is_field_integrated_with_applicant=field[
                        'is_field_integrated_with_applicant'],
                    field_type=field['field_type'],
                    field_label=field['field_label'],
                    field_choices=field['field_choices'],
                    helptext=field['helptext'],
                    required=field['required'])
                f.id = field['id']
                f.save()

        default_application = self.load_default_application_template()
        new_application_template = StudentApplicationTemplate(
            name=default_application['name'],
            is_default=default_application['is_default'],
            json_template=default_application['json_template'])
        new_application_template.save()