Beispiel #1
0
 def __init__(self):
     self.tab_post2catalog = CabPost2Catalog
     self.tab_catalog = CabCatalog
     self.tab_post = CabPost
     try:
         CabPost2Catalog.create_table()
     except:
         pass
Beispiel #2
0
 def __init__(self):
     self.tab = CabPost2Catalog
     self.tab_post2catalog = CabPost2Catalog
     self.tab_catalog = CabCatalog
     self.tab_post = CabPost
     try:
         CabPost2Catalog.create_table()
     except:
         pass
Beispiel #3
0
 def get_by_info(self, post_id, catalog_id):
     recs = CabPost2Catalog.select().where(
         (CabPost2Catalog.post == post_id) & (CabPost2Catalog.catalog == catalog_id))
     if recs.count() > 1:
         for rec in recs:
             self.delete_by_id(rec.uid)
         return False
     elif recs.count() == 1:
         return CabPost2Catalog.get((CabPost2Catalog.post == post_id) & (CabPost2Catalog.catalog == catalog_id))
     else:
         return False
Beispiel #4
0
 def get_by_info(self, post_id, catalog_id):
     recs = CabPost2Catalog.select().where(
         (CabPost2Catalog.post == post_id)
         & (CabPost2Catalog.catalog == catalog_id))
     if recs.count() > 1:
         for rec in recs:
             self.delete_by_id(rec.uid)
         return False
     elif recs.count() == 1:
         return CabPost2Catalog.get((CabPost2Catalog.post == post_id) &
                                    (CabPost2Catalog.catalog == catalog_id))
     else:
         return False
Beispiel #5
0
    def add_record(self, post_id, catalog_id, order=1):

        tt = self.get_by_info(post_id, catalog_id)
        if tt == False:
            print('a')
            entry = CabPost2Catalog.create(
                uid=str(uuid.uuid1()),
                post=post_id,
                catalog=catalog_id,
                order=order,
            )
        else:
            entry = CabPost2Catalog.update(
                order=order, ).where(CabPost2Catalog.uid == tt.uid)
            entry.execute()
Beispiel #6
0
    def add_record(self, post_id, catalog_id, order=1):

        tt = self.get_by_info(post_id, catalog_id)
        if tt == False:
            print('a')
            entry = CabPost2Catalog.create(
                uid=str(uuid.uuid1()),
                post=post_id,
                catalog=catalog_id,
                order=order,
            )
        else:
            entry = CabPost2Catalog.update(
                order=order,
            ).where(CabPost2Catalog.uid == tt.uid)
            entry.execute()
Beispiel #7
0
 def query_count(self):
     recs = CabPost2Catalog.select(CabPost2Catalog.catalog,
                                   peewee.fn.COUNT(CabPost2Catalog.catalog).alias('num')).group_by(
         CabPost2Catalog.catalog)
     return (recs)
Beispiel #8
0
 def query_by_id(self, idd):
     return CabPost2Catalog.select().join(CabCatalog).where(CabPost2Catalog.post == idd)
Beispiel #9
0
 def query_by_catid(self, catid):
     return CabPost2Catalog.select().where(CabPost2Catalog.catalog == catid)
Beispiel #10
0
 def query_all(self):
     recs = CabPost2Catalog.select().order_by(CabPost2Catalog.order)
     return (recs)
Beispiel #11
0
 def query_by_catid(self, catid):
     return CabPost2Catalog.select().where(CabPost2Catalog.catalog == catid)
Beispiel #12
0
 def catalog_record_number(self, cat_id):
     return CabPost2Catalog.select().where(CabPost2Catalog.catalog == cat_id).count()
Beispiel #13
0
 def query_catalog(self, post_id):
     return CabPost2Catalog.select().where(CabPost2Catalog.post == post_id)
Beispiel #14
0
 def catalog_record_number(self, cat_id):
     return CabPost2Catalog.select().where(
         CabPost2Catalog.catalog == cat_id).count()
Beispiel #15
0
 def delete_by_id(self, uid):
     entry = CabPost2Catalog.delete().where(CabPost2Catalog.uid == uid)
     entry.execute()
Beispiel #16
0
 def query_count(self):
     recs = CabPost2Catalog.select(
         CabPost2Catalog.catalog,
         peewee.fn.COUNT(CabPost2Catalog.catalog).alias('num')).group_by(
             CabPost2Catalog.catalog)
     return (recs)
Beispiel #17
0
 def query_by_id(self, idd):
     return CabPost2Catalog.select().join(CabCatalog).where(
         CabPost2Catalog.post == idd)
Beispiel #18
0
    def __init__(self):

        try:
            CabPost2Catalog.create_table()
        except:
            pass
Beispiel #19
0
 def delete_by_id(self, uid):
     entry = CabPost2Catalog.delete().where(CabPost2Catalog.uid == uid)
     entry.execute()
Beispiel #20
0
    def __init__(self):

        try:
            CabPost2Catalog.create_table()
        except:
            pass
Beispiel #21
0
 def query_catalog(self, post_id):
     return CabPost2Catalog.select().where(CabPost2Catalog.post == post_id)
Beispiel #22
0
 def query_all(self):
     recs = CabPost2Catalog.select().order_by(CabPost2Catalog.order)
     return (recs)