in django_airavata/apps/auth/models.py [0:0]
def valid(self):
# if the field is deleted, whatever the value, consider it valid
if self.ext_user_profile_field.deleted:
return True
if self.ext_user_profile_field.required:
if self.value_type == 'text':
return self.text.text_value and len(self.text.text_value.strip()) > 0
if self.value_type == 'single_choice':
choice_exists = (self.single_choice.choice and
self.ext_user_profile_field.single_choice.choices
.filter(id=self.single_choice.choice).exists())
has_other = (self.ext_user_profile_field.single_choice.other and
self.single_choice.other_value and
len(self.single_choice.other_value.strip()) > 0)
return choice_exists or has_other
if self.value_type == 'multi_choice':
choice_ids = list(map(lambda c: c.value, self.multi_choice.choices.all()))
choice_exists = self.ext_user_profile_field.multi_choice.choices.filter(id__in=choice_ids).exists()
has_other = (self.ext_user_profile_field.multi_choice.other and
self.multi_choice.other_value and
len(self.multi_choice.other_value.strip()) > 0)
return choice_exists or has_other
if self.value_type == 'user_agreement':
return self.user_agreement.agreement_value is True
return True