page list 업데이트
This commit is contained in:
28
app.py
28
app.py
@@ -265,6 +265,34 @@ def delete_post(id):
|
||||
else:
|
||||
return jsonify(success=False, message='Could not delete the post'), 500
|
||||
|
||||
@app.route('/list')
|
||||
@app.route('/list/<string:cate>')
|
||||
def list(cate=None):
|
||||
params = ()
|
||||
cate_condition = ""
|
||||
|
||||
if cate:
|
||||
cate_condition = "AND `category` = %s"
|
||||
params = (cate,)
|
||||
|
||||
if 'user_info' in session: # 로그인된 사용자
|
||||
query = f"""SELECT `id`, `title`, `category`, `thumbnail_img`, `contents`, `add_date`
|
||||
FROM `blog`
|
||||
WHERE `use_yn` = 'Y' {cate_condition}
|
||||
ORDER BY `add_date` DESC;"""
|
||||
else:
|
||||
query = f"""SELECT `id`, `title`, `category`, `thumbnail_img`, `contents`, `add_date`
|
||||
FROM `blog`
|
||||
WHERE `use_yn` = 'Y' AND `public_yn` = 'Y' {cate_condition}
|
||||
ORDER BY `add_date` DESC;"""
|
||||
|
||||
r, posts = sql_execute(query, params, is_data=True)
|
||||
|
||||
# 태그 제거 후 150자로 제한
|
||||
for post in posts:
|
||||
post['contents'] = remove_html_tags(post['contents'])[:150]
|
||||
|
||||
return render_template('list.html', posts=posts)
|
||||
|
||||
# ============================================
|
||||
# 관리자 페이지
|
||||
|
||||
Reference in New Issue
Block a user