Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 3
0
 def validate_coursetime(self, field):
     t = transline2times(self.coursetime.data)
     if t is None or t == False:
         raise ValueError(u"时间格式不正确!")
Exemplo n.º 4
0
 def validate_coursetime(self, field):
     t = transline2times(self.coursetime.data)
     if t is None or t == False:
         raise ValueError(u'时间格式不正确!')