示例#1
0
文件: index.py 项目: five3/weblog
 def comment(self):
     userInput= self.getInput()
     cmsObj = model.cms()
     cmsId = userInput['cmsId']
     condition = {'status':1,'id':cmsId}
     atl = cmsObj.getOne('*',condition)
     if atl == None:
         return self.error('文章不存在')
     from web import form
     validList=(
         form.Textbox("name",form.regexp(r".{3,100}$", '姓名需为3~100个字符')),
         form.Textbox("content",form.regexp(r".{1,100}$", '评论内容需为3~100个字符')),
         form.Textbox("email", form.regexp(r".*@.*", '邮箱格式错误')),
         form.Textbox("email",form.regexp(r".{5,100}$", '邮箱需为5~100个字符')),
         )
     if not self.validates(validList):
         return self.error(self.errorMessage)
     date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
     HTTP_X_REAL_IP =  web.ctx.env.get('HTTP_X_REAL_IP')
     ip=HTTP_X_REAL_IP if HTTP_X_REAL_IP else web.ctx.ip
     data={
         'cmsId':cmsId,
         'content':userInput['content'],
         'name':userInput['name'],
         'email':userInput['email'],
         'createTime':date,
         'ip':ip,
         'status':1
     }
     model.comment().insert(data)
     data = {'commentCount':atl['commentCount']+1}
     model.cms().update(data,condition)
     return self.success('评论成功',self.referer)
示例#2
0
文件: index.py 项目: five3/weblog
 def comment(self):
     userInput = self.getInput()
     cmsObj = model.cms()
     cmsId = userInput['cmsId']
     condition = {'status': 1, 'id': cmsId}
     atl = cmsObj.getOne('*', condition)
     if atl == None:
         return self.error('文章不存在')
     from web import form
     validList = (
         form.Textbox("name", form.regexp(r".{3,100}$", '姓名需为3~100个字符')),
         form.Textbox("content", form.regexp(r".{1,100}$",
                                             '评论内容需为3~100个字符')),
         form.Textbox("email", form.regexp(r".*@.*", '邮箱格式错误')),
         form.Textbox("email", form.regexp(r".{5,100}$", '邮箱需为5~100个字符')),
     )
     if not self.validates(validList):
         return self.error(self.errorMessage)
     date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
     HTTP_X_REAL_IP = web.ctx.env.get('HTTP_X_REAL_IP')
     ip = HTTP_X_REAL_IP if HTTP_X_REAL_IP else web.ctx.ip
     data = {
         'cmsId': cmsId,
         'content': userInput['content'],
         'name': userInput['name'],
         'email': userInput['email'],
         'createTime': date,
         'ip': ip,
         'status': 1
     }
     model.comment().insert(data)
     data = {'commentCount': atl['commentCount'] + 1}
     model.cms().update(data, condition)
     return self.success('评论成功', self.referer)
示例#3
0
def comment():
    # Als de gebruiker via POST kwam.
    if request.method == "POST":

        # Comment plaatsen als er op post geklikt is.
        if request.form.get("post"):

            # Comment opslaan in database.
            if len(request.form.get("comment")) > 0:

                comment = request.form.get("comment")
                image_id = session.get("image_id")
                model.comment(comment, image_id)

                return redirect(url_for("homepage"))

            else:
                return redirect(url_for("homepage"))

        # Teruggaan naar homepage als er op cancel gedrukt is.
        elif request.form.get("cancel"):
            return redirect(url_for("homepage"))

    # Als de gebruiker via GET de route bereikt heeft.
    else:
        return render_template("comment.html")
示例#4
0
文件: auth.py 项目: aulicksah/Streamz
 def POST(self):
         data=web.data()
         vid=json.loads(data)['videoid']
         un=json.loads(data)['username']
         cmt=json.loads(data)['comment']
         s=model.comment(vid,un,cmt)
         return s
示例#5
0
 def comment(self):
     userInput= self.getInput()
     cmsObj = model.cms()
     cmsId = userInput['cmsId']
     condition = {'status':1,'id':cmsId}
     atl = cmsObj.getOne('*',condition)
     if atl == None:
         return self.error('not exist')
     from web import form
     validList=(
         form.Textbox("name",form.regexp(r".{3,100}$", 'name length 3-100')),
         form.Textbox("content",form.regexp(r".{1,200}$", 'comment length 1-200')),
         form.Textbox("email", form.regexp(r".*@.*", 'error email format')),
         form.Textbox("email",form.regexp(r".{5,100}$", 'email length 5-100')),
         )
     if not self.validates(validList):
         return self.error(self.errorMessage)
     date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
     ip=web.ctx.ip
     data={
         'cmsId':cmsId,
         'content':userInput['content'],
         'name':userInput['name'],
         'email':userInput['email'],
         'createTime':date,
         'ip':ip,
         'status':1
     }
     commentid = model.comment().insert(data)
     data = {'commentCount':atl['commentCount']+1}
     model.cms().update(data,condition)
     return self.success('comment success, comment id '+str(commentid)+'~',self.referer)
示例#6
0
 def delete(self):
     inputParams = self.getInput()
     if not inputParams.has_key('id'):
         settings = self.getSettings()
         web.seeother(settings.WEB_URL)
     id = inputParams['id']
     condition = {'id': str(id)}
     result = model.comment().delete(condition)
     if result:
         return self.success('删除成功', self.makeUrl('comment', 'list'))
     else:
         return self.error('删除失败')
示例#7
0
 def delete(self):
     inputParams = self.getInput()
     if not inputParams.has_key('id') :
         settings = self.getSettings()
         web.seeother(settings.WEB_URL)
     id=inputParams['id']
     condition={'id':str(id)}
     result=model.comment().delete(condition)
     if result:
         return self.success('删除成功',self.makeUrl('comment','list'))
     else:
         return self.error('删除失败')
示例#8
0
 def index(self):
     settings = self.getSettings()
     count = settings.PER_PAGE_COUNT
     inputParams = self.getInput()
     page = int(inputParams['page']) if inputParams.has_key('page') else 1
     offset= (page-1)*count if page > 0 else 0
     cmsObj = model.cms()
     condition = {'status':1}
     listData = cmsObj.getOne('COUNT(*) AS `total`',condition)
     totalCount = listData['total']
     cmsList = cmsObj.getList('*',condition,'orders desc,createTime desc',str(offset)+','+str(count))
     self.assign('cmsList',cmsList)
     pageString = self.getPageStr(self.makeUrl('index','index'),page,count,totalCount)
     self.assign('pageString',pageString)
     commentObj=model.comment()
     commentList = commentObj.getList('*',{'status':1},'id desc',str(offset)+','+str(count))
     self.assign('commentList',commentList)
     return self.display('index')
示例#9
0
文件: index.py 项目: five3/weblog
 def show(self):
     inputParams = self.getPars()
     if not inputParams.has_key('id'):
         settings = self.getSettings()
         web.seeother(settings.WEB_URL)
     id = inputParams['id']
     cmsObj = model.cms()
     condition = {'status': 1, 'id': str(id)}
     atl = cmsObj.getOne('*', condition)
     #         print atl
     if not atl:
         raise web.notfound('not found')
     atl['views'] += 1
     updateData = {'views': (atl['views'])}
     #view count
     cmsObj.update(updateData, condition)
     commentList = model.comment().getList('*', {
         'status': 1,
         'cmsId': int(id)
     })
     atl['categoryList'] = self.getCate()
     atl['tags'] = atl['tags'].split(u',')
     self.assign('atl', atl)
     self.assign('commentList', commentList)
     self.assignSEO(atl['name'], atl['keywords'], atl['description'])
     if atl['category']:
         cate_id = atl['category']
         cate_name = self.tplData['categoryList'].get(cate_id)
         self.assign('webTitle',
                     '%s_%s' % (self.tplData['webTitle'], cate_name))
     unioObj = model.unio()
     topNewList = unioObj.fetchAll(
         'select cms.id, cms.name, cms.preview_image_src from cms order by createTime desc limit 0,10'
     )
     self.assign('topNewList', topNewList)  ##最新文章列表
     categoryArtList = unioObj.fetchAll(
         'select category.id, category.name, count(cms.id) as num from cms,category where category.id=cms.category GROUP BY cms.category order by num desc limit 0,10'
     )
     self.assign('categoryArtList', categoryArtList)  ##分类归档列表
     tagArtList = []
     self.assign('tagArtList', tagArtList)  ##标签归档列表
     dateArtList = []
     self.assign('dateArtList', dateArtList)  ##日期归档列表
     return self.display('show')
示例#10
0
 def show(self):
     inputParams = self.getInput()
     if not inputParams.has_key('id') :
         settings = self.getSettings()
         web.seeother(settings.WEB_URL)
     id = inputParams['id']
     cmsObj = model.cms()
     condition = {'status':1,'id':str(id)}
     atl = cmsObj.getOne('*',condition)
     if atl == None:
         raise web.notfound('not found')
     atl['views']+=1
     updateData = {'views':(atl['views'])}
     #view count incr
     cmsObj.update(updateData,condition)
     commentList=model.comment().getList('*',{'status':1,'cmsId':int(id)})
     self.assign('atl',atl)
     self.assign('commentList',commentList)
     return self.display('show')
示例#11
0
    def list(self):
        inputParams = self.getInput()
        page = int(inputParams['page']) if inputParams.has_key('page') else 1
        settings = self.getSettings()
        count = settings.PER_PAGE_COUNT
        offset= (page-1)*count if page > 0 else 0
        commentObj = model.comment()
        condition = {}
        listData = commentObj.getOne('COUNT(*) AS `total`',condition)
        totalCount = listData['total']
        commentList = commentObj.getList('*',condition,'id desc',str(offset)+','+str(count))
        cmsObj = model.cms()
        for k,v in enumerate(commentList):
            atl=cmsObj.getOne('name,id',{'id':v['cmsId']})
            commentList[k]['atl'] =atl

        self.assign('commentList',commentList)
        pageString = self.getPageStr(self.makeUrl('comment','list'),page,count,totalCount)
        self.assign('pageString',pageString)
        return self.display('commentList')
示例#12
0
    def list(self):
        inputParams = self.getInput()
        page = int(inputParams['page']) if inputParams.has_key('page') else 1
        settings = self.getSettings()
        count = settings.PER_PAGE_COUNT
        offset= (page-1)*count if page > 0 else 0
        commentObj = model.comment()
        condition = {}
        listData = commentObj.getOne('COUNT(*) AS `total`',condition)
        totalCount = listData['total']
        commentList = commentObj.getList('*',condition,'id desc',str(offset)+','+str(count))
        cmsObj = model.cms()
        for k,v in enumerate(commentList):
            atl=cmsObj.getOne('name,id',{'id':v['cmsId']})
            commentList[k]['atl'] =atl

        self.assign('commentList',commentList)
        pageString = self.getPageStr(self.makeUrl('comment','list'),page,count,totalCount)
        self.assign('pageString',pageString)
        return self.display('commentList')
示例#13
0
 def index(self):
     settings = self.getSettings()
     count = settings.PER_PAGE_COUNT
     inputParams = self.getInput()
     page = int(inputParams['page']) if inputParams.has_key('page') else 1
     offset = (page - 1) * count if page > 0 else 0
     cmsObj = model.cms()
     condition = {'status': 1}
     listData = cmsObj.getOne('COUNT(*) AS `total`', condition)
     totalCount = listData['total']
     cmsList = cmsObj.getList('*', condition, 'orders desc,createTime desc',
                              str(offset) + ',' + str(count))
     self.assign('cmsList', cmsList)
     pageString = self.getPageStr(self.makeUrl('index', 'index'), page,
                                  count, totalCount)
     self.assign('pageString', pageString)
     commentObj = model.comment()
     commentList = commentObj.getList('*', {'status': 1}, 'id desc',
                                      str(offset) + ',' + str(count))
     self.assign('commentList', commentList)
     return self.display('index')
示例#14
0
 def show(self):
     inputParams = self.getInput()
     if not inputParams.has_key('id'):
         settings = self.getSettings()
         web.seeother(settings.WEB_URL)
     id = inputParams['id']
     cmsObj = model.cms()
     condition = {'status': 1, 'id': str(id)}
     atl = cmsObj.getOne('*', condition)
     if atl == None:
         raise web.notfound('not found')
     atl['views'] += 1
     updateData = {'views': (atl['views'])}
     #view count incr
     cmsObj.update(updateData, condition)
     commentList = model.comment().getList('*', {
         'status': 1,
         'cmsId': int(id)
     })
     self.assign('atl', atl)
     self.assign('commentList', commentList)
     return self.display('show')
示例#15
0
 def comment(self):
     userInput = self.getInput()
     cmsObj = model.cms()
     cmsId = userInput['cmsId']
     condition = {'status': 1, 'id': cmsId}
     atl = cmsObj.getOne('*', condition)
     if atl == None:
         return self.error('not exist')
     from web import form
     validList = (
         form.Textbox("name", form.regexp(r".{3,100}$",
                                          'name length 3-100')),
         form.Textbox("content",
                      form.regexp(r".{1,200}$", 'comment length 1-200')),
         form.Textbox("email", form.regexp(r".*@.*", 'error email format')),
         form.Textbox("email",
                      form.regexp(r".{5,100}$", 'email length 5-100')),
     )
     if not self.validates(validList):
         return self.error(self.errorMessage)
     date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
     ip = web.ctx.ip
     data = {
         'cmsId': cmsId,
         'content': userInput['content'],
         'name': userInput['name'],
         'email': userInput['email'],
         'createTime': date,
         'ip': ip,
         'status': 1
     }
     commentid = model.comment().insert(data)
     data = {'commentCount': atl['commentCount'] + 1}
     model.cms().update(data, condition)
     return self.success(
         'comment success, comment id ' + str(commentid) + '~',
         self.referer)
示例#16
0
文件: index.py 项目: five3/weblog
    def show(self):
        inputParams = self.getPars()
        if not inputParams.has_key('id') :
            settings = self.getSettings()
            web.seeother(settings.WEB_URL)
        id=inputParams['id']
        cmsObj = model.cms()
        condition = {'status':1,'id':str(id)}
        atl = cmsObj.getOne('*',condition)
#         print atl
        if not atl:
            raise web.notfound('not found')
        atl['views']+=1
        updateData = {'views':(atl['views'])}
        #view count 
        cmsObj.update(updateData,condition)
        commentList=model.comment().getList('*',{'status':1,'cmsId':int(id)})
        atl['categoryList'] = self.getCate()
        atl['tags'] = atl['tags'].split(u',')
        self.assign('atl',atl)
        self.assign('commentList',commentList)
        self.assignSEO(atl['name'], atl['keywords'], atl['description'])
        if atl['category']:
            cate_id = atl['category']
            cate_name = self.tplData['categoryList'].get(cate_id)
            self.assign('webTitle', '%s_%s' % (self.tplData['webTitle'], cate_name)) 
        unioObj = model.unio() 
        topNewList = unioObj.fetchAll('select cms.id, cms.name, cms.preview_image_src from cms order by createTime desc limit 0,10')
        self.assign('topNewList', topNewList)  ##最新文章列表 
        categoryArtList = unioObj.fetchAll('select category.id, category.name, count(cms.id) as num from cms,category where category.id=cms.category GROUP BY cms.category order by num desc limit 0,10')
        self.assign('categoryArtList', categoryArtList)  ##分类归档列表 
        tagArtList = []
        self.assign('tagArtList', tagArtList)  ##标签归档列表 
        dateArtList = []
        self.assign('dateArtList', dateArtList)  ##日期归档列表 
        return self.display('show')  
示例#17
0
 def post(self):
   team_key = self.request.get('team_key')
   text = self.request.get('text')
   user = users.get_current_user()
   comment(user, team_key, text)
   self.redirect('/', {})