def sd_admin_article_insert(): if request.method == 'POST': data = {} article_content = request.form.get('article_content') article_name = request.form.get('article_name') article_type = request.form.get('article_type') if article_content.replace(' ', '').replace(' ', '') == '': return jsonify({'code': 201, 'msg': '文章不能为空'}) article = Article() article.article_name = article_name article.type_id = article_type article.article_content = article_content try: db.session.add(article) db.session.commit() return jsonify({'code': 200, 'msg': '新增文章成功'}) except: db.session.rollback() db.session.flush() return jsonify({'code': 201, 'msg': '新增文章失败'}) elif request.method == 'GET': data = get_info() types = Type.query.filter(Type.id != 1) data['types'] = types return render_template('admin/article_insert.html', **data)
def sd_admin_announce_detail(id): if request.method == 'POST': data = {} id = request.form.get('id') article_content = request.form.get('article_content') article_name = request.form.get('article_name') article_type = request.form.get('article_type') article = Article.query.get(id) article.article_name = article_name article.type_id = article_type article.article_content = article_content try: db.session.add(article) db.session.commit() return jsonify({'code': 200, 'msg': '成功'}) except: db.session.rollback() db.session.flush() return jsonify({'code': 201, 'msg': '失败'}) elif request.method == 'GET': data = get_info() types = Type.query.filter(Type.id == 1) article = Article.query.get(int(id)) data['article'] = article data['types'] = types # 所有文章的分类 data['type'] = '公告' # 当前文章的分类 return render_template('admin/article_detail.html', **data)
def sd_admin_testdetail(id): if request.method == 'POST': data = {} id = request.form.get('id') test_content = request.form.get('test_content') test_name = request.form.get('test_name') if test_content.replace(' ', '').replace(' ', '') == '': return jsonify({'code': 201, 'msg': '测试内容不能为空'}) test = Test_question.query.get(int(id)) test.test_title = test_name test.test_content = test_content try: db.session.add(test) db.session.commit() return jsonify({'code': 200, 'msg': '成功'}) except: db.session.rollback() db.session.flush() return jsonify({'code': 201, 'msg': '失败'}) elif request.method == 'GET': data = get_info() test = Test_question.query.get(int(id)) data['test'] = test return render_template('admin/test_detail.html', **data)
def sd_admin_type_list(): data = get_info() return render_template('admin/type_list.html', **data)
def sd_admin_announce_list(): data = get_info() data['type'] = '公告' return render_template('admin/article_list.html', **data)
def sd_admin_test_list(): data = get_info() data['type'] = '文章' return render_template('admin/test_list.html', **data)
def sd_admin_index(): data = get_info() return render_template('admin/index.html', **data)
def sd_admin_admin(): data = get_info() data['type'] = '管理员' return render_template('admin/people_list.html', **data)
def sd_admin_reservation_list(): data = get_info() return render_template('admin/reservation_list.html', **data)
def sd_admin_message(): data = get_info() return render_template('admin/user_message.html', **data)