示例#1
0
 def validate(self, attrs):
     """
     Validators for this serializer
     """
     attrs["program"] = get_object_or_404(Program, pk=attrs["program_id"])
     if not attrs["program"].financial_aid_availability:
         raise ValidationError("Financial aid not available for this program.")
     if not ProgramEnrollment.objects.filter(program=attrs["program"], user=self.context["request"].user).exists():
         raise ValidationError("User not in program.")
     if not is_profile_filled_out(self.context["request"].user.profile):
         raise ValidationError("Profile is not complete")
     return attrs
示例#2
0
 def validate(self, attrs):
     """
     Validators for this serializer
     """
     attrs["program"] = get_object_or_404(Program, pk=attrs["program_id"])
     if not attrs["program"].financial_aid_availability:
         raise ValidationError(
             "Financial aid not available for this program.")
     if not ProgramEnrollment.objects.filter(
             program=attrs["program"],
             user=self.context["request"].user).exists():
         raise ValidationError("User not in program.")
     if not is_profile_filled_out(self.context["request"].user.profile):
         raise ValidationError("Profile is not complete")
     return attrs
示例#3
0
 def test_is_profile_filled_out(self):
     """tests is_profile_filled_out method when column is filled out"""
     assert util.is_profile_filled_out(self.profile) is True
示例#4
0
 def test_is_profile_filled_out_when_blank(self, column):
     """tests is_profile_filled_out method when column is blank"""
     setattr(self.profile, column, "")
     self.profile.save()
     assert util.is_profile_filled_out(self.profile) is False
示例#5
0
 def test_is_profile_filled_out_when_none(self, column):
     """tests is_profile_filled_out method when column is None"""
     setattr(self.profile, column, None)
     self.profile.save()
     assert util.is_profile_filled_out(self.profile) is False
示例#6
0
 def test_is_profile_filled_out(self):
     """tests is_profile_filled_out method when column is filled out"""
     assert util.is_profile_filled_out(self.profile) is True
示例#7
0
 def test_is_profile_filled_out_when_blank(self, column):
     """tests is_profile_filled_out method when column is blank"""
     setattr(self.profile, column, "")
     self.profile.save()
     assert util.is_profile_filled_out(self.profile) is False
示例#8
0
 def test_is_profile_filled_out_when_none(self, column):
     """tests is_profile_filled_out method when column is None"""
     setattr(self.profile, column, None)
     self.profile.save()
     assert util.is_profile_filled_out(self.profile) is False