def article(id): article = db.blog().getArticlebyid(id) categroy = db.sorted().getSort() if('username' in session): return render_template('article.html',username=session['username'],categroy=categroy,article=article) else: return render_template('article.html',categroy=categroy,article=article)
def sort(id,num=1): sort = 'sort' categroy = db.sorted().getSort() count = db.blog().getCount(id) pagenum = (count/(pagecount+1))+1 if (num==1): article = db.blog().getSortArticle(id).limit(pagecount).all() else: article = db.blog().getSortArticle(id).limit(pagecount).offset((num-1)*pagecount).all() x = min(6,pagenum + 1) y = min(pagenum + 1,num + 4) if('username' in session): return render_template('list.html',username=session['username'],categroy=categroy,article=article,count=pagenum,page=num,x=x,y=y,sort=sort,id=id) else: return render_template('list.html',categroy=categroy,article=article,count=pagenum,page=num,x=x,y=y,sort=sort,id=id)
def updateAr(id): title = request.form['title'] sortedValue = request.form['sorted'] if( db.sorted().getSortid(sortedValue)): sortedValue = db.sorted().getSortid(sortedValue) else: return 'False' content = request.form['content'] date = request.form['date'] if(not (title and sortedValue and content)): return 'False' if(db.blog().updateArticle(id,title,date,content,sortedValue)): return 'True' else: return 'False'
def addarticle(): title = request.form['title'] sortedValue = request.form['sorted'] if( db.sorted().getSortid(sortedValue)): sortedValue = db.sorted().getSortid(sortedValue) else: return 'False' content = request.form['content'] #content = content.replace('\n','<br/>') #content = content.replace(' ',' ') date = request.form['date'] if(not (title and sortedValue and content)): return 'False' if(db.blog().addArticle(title,session['username'],date,content,sortedValue)): return 'True' else: return 'False'
def update(id): categroy = db.sorted().getSort() article = db.blog().getArticlebyid(id) sort = db.sorted().getSortname(article.sorted).name return render_template('update.html',username=session['username'],categroy=categroy,article=article,sorted=sort)
def delete(id): if(db.blog().deleteArticle(id)): return "True" else: return "False"
def write(): categroy = db.sorted().getSort() article = db.blog().getallArticle() return render_template('write.html',username=session['username'],categroy=categroy,article=article)