def validate(self): # if our validators do not pass if not super(NewCourseForm, self).validate(): return False # Ensure the name has the right format: if not utils.is_valid_endpoint(self.offering.data, COURSE_ENDPOINT_FORMAT): self.offering.errors.append(("The name should like univ/course101/semYY")) return False course = Course.query.filter_by(offering=self.offering.data).first() if course: self.offering.errors.append("That offering already exists.") return False return True
def validate(self): # if our validators do not pass if not super(NewCourseForm, self).validate(): return False # Ensure the name has the right format: if not utils.is_valid_endpoint(self.offering.data, COURSE_ENDPOINT_FORMAT): self.offering.errors.append(('The name should look like univ/course101/semYY where "sem" is one of (fa, su, sp, au, wi)')) return False course = Course.query.filter_by(offering=self.offering.data).first() if course: self.offering.errors.append('That offering already exists.') return False return True
def validate(self): # if our validators do not pass if not super(AssignmentForm, self).validate(): return False # Ensure the name has the right format: is_valid_endpoint = utils.is_valid_endpoint(self.name.data, ASSIGNMENT_ENDPOINT_FORMAT) has_course_endpoint = self.name.data.startswith(self.course.offering) if not has_course_endpoint or not is_valid_endpoint: self.name.errors.append("The name should be of the form {0}/<name>".format(self.course.offering)) return False assgn = Assignment.query.filter_by(name=self.name.data).first() if assgn and (self.obj and assgn.id != self.obj.id): self.name.errors.append("That offering already exists.") return False return True
def validate(self): # if our validators do not pass if not super(AssignmentForm, self).validate(): return False # Ensure the name has the right format: is_valid_endpoint = utils.is_valid_endpoint(self.name.data, ASSIGNMENT_ENDPOINT_FORMAT) has_course_endpoint = self.name.data.startswith(self.course.offering) if not has_course_endpoint or not is_valid_endpoint: self.name.errors.append( 'The name should be of the form {0}/<name>'.format(self.course.offering)) return False assgn = Assignment.query.filter_by(name=self.name.data).first() if assgn and (self.obj and assgn.id != self.obj.id): self.name.errors.append('That offering already exists.') return False return True
def validate(self): check_validate = super(AssignmentForm, self).validate() # if our validators do not pass if not check_validate: return False # Ensure the name has the right format: is_valid_endpoint = utils.is_valid_endpoint(self.name.data, ASSIGNMENT_ENDPOINT_FORMAT) has_course_endpoint = self.name.data.startswith(self.course.offering) if not has_course_endpoint or not is_valid_endpoint: self.name.errors.append( 'The endpoint should be of the form {0}/<name>'.format(self.course.offering)) return False # If the name is changed, ensure assignment offering is unique assgn = Assignment.query.filter_by(name=self.name.data).first() if assgn: self.name.errors.append('That endpoint already exists') return False return True