Ejemplo n.º 1
0
    def get_by_slug(self, slug):



        tt = CabPage.select().where(CabPage.slug == slug).count()
        if tt == 0:
            return None
        else:
            return CabPage.get(CabPage.slug == slug)
Ejemplo n.º 2
0
    def get_by_slug(self, slug):

        entry = CabPage.update(view_count=CabPage.view_count +
                               1, ).where(CabPage.slug == slug)
        entry.execute()

        tt = CabPage.select().where(CabPage.slug == slug).count()
        if tt == 0:
            return None
        else:
            return CabPage.get(CabPage.slug == slug)
Ejemplo n.º 3
0
    def get_by_slug(self, slug):

        entry = CabPage.update(
            view_count=CabPage.view_count + 1,
        ).where(CabPage.slug == slug)
        entry.execute()

        tt = CabPage.select().where(CabPage.slug == slug).count()
        if tt == 0:
            return None
        else:
            return CabPage.get(CabPage.slug == slug)
Ejemplo n.º 4
0
    def insert_data(self, post_data):
        slug =  post_data['slug'][0]
        uu = self.get_by_slug(slug)
        if uu is None:
            pass
        else:
            return (False)
        if 'id_spec' in post_data:
            id_spec = int(post_data['id_spec'][0])
        else:
            id_spec = 0

        try:
            entry = CabPage.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            slug= slug,
            cnt_html=self.md2html(post_data['cnt_md'][0]),
            # id_post=id_post,
            time_create=time.time(),
            id_user='',
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=time.time(),
            view_count=1,
            )
        except:
            return ''
        return slug
Ejemplo n.º 5
0
 def update(self, slug, post_data):
     entry = CabPage.update(
         title=post_data['title'][0],
         date=datetime.datetime.now(),
         cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
         id_user='',
         cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
         time_update=time.time(),
     ).where(CabPage.slug == slug)
     entry.execute()
Ejemplo n.º 6
0
 def update(self, slug, post_data):
     entry = CabPage.update(
         title=post_data['title'][0],
         date=datetime.datetime.now(),
         cnt_html=self.md2html(post_data['cnt_md'][0]),
         id_user='',
         cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
         time_update=time.time(),
     ).where(CabPage.slug == slug)
     entry.execute()
Ejemplo n.º 7
0
    def insert_data(self, post_data):
        slug = post_data['slug'][0]
        uu = self.get_by_slug(slug)
        if uu is None:
            pass
        else:
            return (False)

        try:
            CabPage.create(
                title=post_data['title'][0],
                date=datetime.datetime.now(),
                slug=slug,
                cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
                time_create=time.time(),
                id_user='',
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                time_update=time.time(),
                view_count=1,
            )
            return slug
        except:
            return ''
Ejemplo n.º 8
0
    def insert_data(self, post_data):
        slug = post_data['slug'][0]
        uu = self.get_by_slug(slug)
        if uu is None:
            pass
        else:
            return (False)

        try:
            CabPage.create(
                title=post_data['title'][0],
                date=datetime.datetime.now(),
                slug=slug,
                cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
                time_create=time.time(),
                id_user='',
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                time_update=time.time(),
                view_count=1,
            )
            return slug
        except:
            return ''
Ejemplo n.º 9
0
 def __init__(self):
     self.tab = CabPage
     try:
         CabPage.create_table()
     except:
         pass
Ejemplo n.º 10
0
 def query_recent(self):
     tt = CabPage.select().where(CabPage.type == 1).order_by(CabPage.time_update.desc()).limit(10)
     return tt
Ejemplo n.º 11
0
 def query_by_cat(self, cat_str):
     tt = CabPage.select().where((CabPage.id_cats.contains(str(cat_str))) & ((CabPage.type == 1))).order_by(
         'time_update')
     return tt
Ejemplo n.º 12
0
 def get_by_id(self, in_uid):
     return CabPage.get(id_post=in_uid)
Ejemplo n.º 13
0
 def get_by_id(self, input):
     return CabPage.get(uid=input)
Ejemplo n.º 14
0
    def __init__(self):
        try:

            CabPage.create_table()
        except:
            pass
Ejemplo n.º 15
0
 def get_by_id(self, in_uid):
     tt = CabPage.get(CabPage.id_post == in_uid)
     return tt
Ejemplo n.º 16
0
 def query_by_cat(self, cat_str):
     tt = CabPage.select().where((CabPage.id_cats.contains(str(cat_str))) & ((CabPage.type == 1))).order_by(
         'time_update')
     return tt
Ejemplo n.º 17
0
 def query_all(self):
     return CabPage.select().order_by('time_update')
Ejemplo n.º 18
0
    def view_count_plus(self, slug):

        entry = CabPage.update(
            view_count=CabPage.view_count + 1,
        ).where(CabPage.slug == slug)
        entry.execute()