已完成全部功能
This commit is contained in:
11
routes.py
11
routes.py
@@ -4,6 +4,7 @@ from flask_login import login_user, logout_user, login_required, current_user
|
||||
from __init__ import app, db
|
||||
from models import User, Demand, now_shanghai
|
||||
from forms import DemandForm, AnswerForm, LoginForm, RegisterForm
|
||||
from dingtalk import notify_admins_new_demand, notify_asker_answer
|
||||
|
||||
BRANCH_NAMES = {
|
||||
'comprehensive': '综合分会',
|
||||
@@ -125,6 +126,11 @@ def new_demand():
|
||||
)
|
||||
db.session.add(demand)
|
||||
db.session.commit()
|
||||
|
||||
# 通知管理员有新需求提交
|
||||
base_url = request.host_url.rstrip('/').replace('http://', 'https://') + '/requirement-collection'
|
||||
notify_admins_new_demand(demand, base_url)
|
||||
|
||||
flash('需求提交成功', 'success')
|
||||
return redirect(url_for('index'))
|
||||
return render_template('demand_form.html', form=form, title='提交新需求')
|
||||
@@ -164,6 +170,11 @@ def answer_demand(id):
|
||||
demand.answer = form.answer.data
|
||||
demand.answered_at = now_shanghai()
|
||||
db.session.commit()
|
||||
|
||||
# 通知提问者问题已被回答
|
||||
base_url = request.host_url.rstrip('/').replace('http://', 'https://') + '/requirement-collection'
|
||||
notify_asker_answer(demand, base_url)
|
||||
|
||||
flash('回答已保存', 'success')
|
||||
return redirect(url_for('index'))
|
||||
return render_template('answer_form.html', form=form, demand=demand)
|
||||
|
||||
Reference in New Issue
Block a user