Ejemplo n.º 1
0
    def create(self, validated_data):
        committees = validated_data.pop('committeepriority_set')
        application = CommitteeApplication(**validated_data)
        try:
            application.clean()
        except DjangoValidationError as django_error:
            raise serializers.ValidationError(django_error.message)
        application.save()

        for committee in committees:
            CommitteePriority.objects.create(committee_application=application, **committee)

        return CommitteeApplication.objects.get(pk=application.pk)
Ejemplo n.º 2
0
 def test_anon_can_not_apply(self):
     application = CommitteeApplication()
     application.application_text = 'something'
     with self.assertRaises(ValidationError):
         application.clean()