Exemple #1
0
 def delete_rel(self, noteid, tag):
     t = tag.first()
     session.query(Relate).filter(
         and_(Relate.marknoteid == noteid, Relate.tagid == t.id)).delete()
     session.commit()
     self.query_update(Tag, t.id, {'count': t.count - 1})
     if t.count <= 0:
         tag.delete()
         session.commit()
Exemple #2
0
 def delete_rel(self,noteid,tag):
     t = tag.first()
     session.query(Relate).filter(and_(Relate.marknoteid==noteid,
                                       Relate.tagid==t.id)).delete()
     session.commit()
     self.query_update(Tag,t.id,{'count':t.count-1})
     if t.count <= 0:
         tag.delete()
         session.commit()
Exemple #3
0
 def delete(self,id):
     note = self.query_byid(MarkNote,id)
     tags = {}
     for t in note.first().tags.split(','):
         if t != '':
             tags[t] = t
     for t in tags.keys():
         print("tag:"+t)
         tag = self.query_bytitle(Tag,t)
         self.delete_rel(id,tag)
     note.delete()
     session.commit()
Exemple #4
0
 def delete(self, id):
     note = self.query_byid(MarkNote, id)
     tags = {}
     for t in note.first().tags.split(','):
         if t != '':
             tags[t] = t
     for t in tags.keys():
         print("tag:" + t)
         tag = self.query_bytitle(Tag, t)
         self.delete_rel(id, tag)
     note.delete()
     session.commit()
Exemple #5
0
def getCurrentDay():
    lastDay = getLastDay()
    oneDay = timedelta(days=1)
    if (lastDay!= None):
        while (lastDay.dateofconsum != date.today()):
            lastDay=Day(dateofconsum=lastDay.dateofconsum+oneDay)
            session.add(lastDay)
            print(lastDay.dateofconsum)
    else:
        lastDay=Day(dateofconsum=date.today())
        session.add(lastDay)
        print(lastDay.dateofconsum)
    session.commit()
    return getLastDay()
Exemple #6
0
 def add(self):
     session.add(self)
     session.commit()
Exemple #7
0
 def query_update(self,table,id,update):
     data = session.query(table).filter(table.id==id).update(update)
     session.commit()
Exemple #8
0
def addMeal(day,name,kcal,price=None):
    session.add(Meal(day= day, name=name, kcal = kcal,price=price))
    session.commit()
Exemple #9
0
 def query_update(self, table, id, update):
     data = session.query(table).filter(table.id == id).update(update)
     session.commit()