|
|
@ -37,24 +37,10 @@ class Candidate(db.Model): |
|
|
|
|
|
|
|
db.create_all() |
|
|
|
|
|
|
|
@app.route('/js/<path:path>') |
|
|
|
def send_js(path): |
|
|
|
return send_from_directory('static/js', path) |
|
|
|
@app.route('/img/<path:path>') |
|
|
|
def send_img(path): |
|
|
|
return send_from_directory('static/img', path) |
|
|
|
|
|
|
|
@app.route('/ordinary/') |
|
|
|
def inbox(): |
|
|
|
|
|
|
|
cans = [{ |
|
|
|
'content': c.content, |
|
|
|
'url' : c.url, |
|
|
|
'toot': c.toot, |
|
|
|
'time': c.time.replace(tzinfo=tzlocal()) |
|
|
|
} for c in Candidate.query.all() |
|
|
|
] |
|
|
|
|
|
|
|
def list(): |
|
|
|
pag = Candidate.query.order_by(db.desc('id')).paginate(max_per_page=100) |
|
|
|
|
|
|
|
vs = [{ |
|
|
|
'name': name, |
|
|
|
'ques': ques, |
|
|
@ -62,7 +48,7 @@ def inbox(): |
|
|
|
} for name, ques, hint, ans in C.verify |
|
|
|
] |
|
|
|
|
|
|
|
return render_template('inbox.html', cans=cans, vs=vs) |
|
|
|
return render_template('list.html', pagination=pag, vs=vs) |
|
|
|
|
|
|
|
@app.route('/ordinary/new', methods=['POST']) |
|
|
|
@limiter.limit("5 / hour; 1 / 2 second") |
|
|
@ -78,10 +64,9 @@ def new_one(): |
|
|
|
if url and not re.match('https://(cloud\.tsinghua\.edu\.cn/f/[0-9a-z]+/(\?dl=1)?)|(closed\.social/safeShare/\d([a-zA-Z]+)?)', url): abort(422) |
|
|
|
|
|
|
|
if not Candidate.query.filter_by(content=content).first(): |
|
|
|
|
|
|
|
toot = th.status_post( |
|
|
|
f"叮~ 有新的自荐报名(大家可以直接在此处评论):\n\n{content}", |
|
|
|
visibility='unlisted' |
|
|
|
visibility='unlisted' |
|
|
|
) |
|
|
|
|
|
|
|
c = Candidate(content=content, url=url, toot=toot.id, time = datetime.now()) |
|
|
|