Exemple #1
0
 def save(self):
     cour = Course.query.get(self.code.data)
     if cour is None:
         cour = Course(
             code=self.code.data,
             desp=self.desp.data,
             major=self.major.data,
             additional=self.additional.data,
             num=self.num.data,
             credit=self.credit.data,
         )
     else:
         cour.modify(
             code=self.code.data,
             desp=self.desp.data,
             major=self.major.data,
             additional=self.additional.data,
             num=self.num.data,
             credit=self.credit.data,
         )
     cour.save()
     t = transline2times(self.coursetime.data)
     if t != False and t is not None and len(t) != 0:
         cdel = Timeplace.query.filter(Timeplace.code == self.code.data)
         cdel.delete()
         for st in t:
             ta = Timeplace(
                 code=self.code.data, weekday=st[0], starttime=st[1], durtime=st[2], place=st[3], additional=st[4]
             )
             ta.save()
     tea = transline2tea(self.teas.data)
     if tea is not None and len(tea) != 0:
         tdel = Emp.query.filter(Emp.code == self.code.data)
         tdel.delete()
         for st in tea:
             ta = Emp(code=self.code.data, teaid=st)
             ta.save()
     return cour
Exemple #2
0
 def save(self):
     cour = Course.query.get(self.code.data)
     if cour is None:
         cour = Course(code=self.code.data,
                       desp=self.desp.data,
                       major=self.major.data,
                       additional=self.additional.data,
                       num=self.num.data,
                       credit=self.credit.data)
     else:
         cour.modify(code=self.code.data,
                     desp=self.desp.data,
                     major=self.major.data,
                     additional=self.additional.data,
                     num=self.num.data,
                     credit=self.credit.data)
     cour.save()
     t = transline2times(self.coursetime.data)
     if t != False and t is not None and len(t) != 0:
         cdel = Timeplace.query.filter(Timeplace.code == self.code.data)
         cdel.delete()
         for st in t:
             ta = Timeplace(code=self.code.data,
                            weekday=st[0],
                            starttime=st[1],
                            durtime=st[2],
                            place=st[3],
                            additional=st[4])
             ta.save()
     tea = transline2tea(self.teas.data)
     if tea is not None and len(tea) != 0:
         tdel = Emp.query.filter(Emp.code == self.code.data)
         tdel.delete()
         for st in tea:
             ta = Emp(code=self.code.data, teaid=st)
             ta.save()
     return cour
Exemple #3
0
 def validate_teas(self, field):
     tea = transline2tea(field.data)
     for i in tea:
         if not Teacher.query.get(i):
             raise ValueError(u"教师编号%s不存在!" % i)
Exemple #4
0
 def validate_teas(self, field):
     tea = transline2tea(field.data)
     for i in tea:
         if not Teacher.query.get(i):
             raise ValueError(u'教师编号%s不存在!' % i)