Exemple #1
0
    def validate_stuid(self,field):

        if Student.query.get(field.data) is None:
            raise ValueError(u'该学生不存在!')
        else:
        #验证时间是否冲突
            sc=Course.query.get(self.code.data)
            allc=Course.query.join(Xk, Xk.code==Course.code).filter(Xk.stuid==self.stuid.data)
            if check_if_conflict(allc,sc):
                raise ValueError(u'该课程与学生当前课程时间冲突!')
Exemple #2
0
    def validate_stuid(self, field):

        if Student.query.get(field.data) is None:
            raise ValueError(u'该学生不存在!')
        else:
            #验证时间是否冲突
            sc = Course.query.get(self.code.data)
            allc = Course.query.join(
                Xk, Xk.code == Course.code).filter(Xk.stuid == self.stuid.data)
            if check_if_conflict(allc, sc):
                raise ValueError(u'该课程与学生当前课程时间冲突!')
Exemple #3
0
 def validate_code(self, field):
     code = field.data
     if Xk.query.filter(Xk.stuid == self.stuid.data).filter(Xk.code == code).count():
         raise ValueError(u"该课程已选择")
     # check if time conflict
     allcourses = Course.query.join(Xk, Course.code == Xk.code).filter(Xk.stuid == self.stuid.data).all()
     selectcourse = Course.query.filter(Course.code == code).first()
     if not selectcourse:
         raise ValueError(u"该课程不存在")
     ####TO########
     # 时间冲突判断--ok
     # 人数是否满判断
     if check_if_conflict(allcourses, selectcourse):
         raise ValueError(u"时间冲突")
Exemple #4
0
 def validate_code(self, field):
     code = field.data
     if Xk.query.filter(Xk.stuid == self.stuid.data).filter(
             Xk.code == code).count():
         raise ValueError(u'该课程已选择')
     #check if time conflict
     allcourses = Course.query.join(
         Xk,
         Course.code == Xk.code).filter(Xk.stuid == self.stuid.data).all()
     selectcourse = Course.query.filter(Course.code == code).first()
     if not selectcourse:
         raise ValueError(u'该课程不存在')
     ####TO########
     #时间冲突判断--ok
     #人数是否满判断
     if check_if_conflict(allcourses, selectcourse):
         raise ValueError(u'时间冲突')