def mentorChoicesForOrg(task, org): """Builds the tuple of mentor choice 2-tuples for the Django choice field. Args: task: GCITask entity for which the create page is being created org: The organization entity for which the mentor choices should be constructed. """ mentors = profile_logic.queryAllMentorsForOrg(org) return ((str(m.key()), m.name()) for m in mentors)
def clean_mentors(self): mentor_key_strs = set(self.data.getlist("mentors")) if not mentor_key_strs: raise django_forms.ValidationError(ugettext("At least one mentor should be assigned to the task.")) org_mentors_keys = profile_logic.queryAllMentorsForOrg(self.organization, keys_only=True) mentor_keys = [] for m_str in mentor_key_strs: if not m_str: break mentor_key = db.Key(m_str) if mentor_key not in org_mentors_keys: raise django_forms.ValidationError( ugettext("One of the mentors doesn't belong to the organization " "that this task belongs to.") ) mentor_keys.append(mentor_key) return mentor_keys
def clean_mentors(self): mentor_key_strs = set(self.data.getlist('mentors')) if not mentor_key_strs: raise django_forms.ValidationError( ugettext("At least one mentor should be assigned to the task.")) org_mentors_keys = profile_logic.queryAllMentorsForOrg( self.organization, keys_only=True) mentor_keys = [] for m_str in mentor_key_strs: if not m_str: break mentor_key = db.Key(m_str) if mentor_key not in org_mentors_keys: raise django_forms.ValidationError( ugettext("One of the mentors doesn't belong to the organization " "that this task belongs to.")) mentor_keys.append(mentor_key) return mentor_keys