Browse Source

向管理员展示被举报 & 管理员关注解除举报

master
hole-thu 4 years ago
parent
commit
ea20779913
  1. 21
      hole.py
  2. 1
      utils.py

21
hole.py

@ -399,15 +399,13 @@ def attention():
if username[:4] == 'tmp_':
abort(403)
s = request.form.get('switch')
if s not in ['0', '1']:
s = request.form.get('switch', type=int)
if s not in [0, 1]:
abort(422)
pid = get_num(request.form.get('pid'))
pid = request.form.get('pid', type=int)
post = Post.query.get(pid)
if not post:
abort(404)
post = Post.query.get_or_404(pid)
at = Attention.query.filter_by(
name_hash=hash_name(username), pid=pid
@ -419,16 +417,19 @@ def attention():
if post.hot_score != -1:
post.hot_score += 2
if(at.disabled != (s == '0')):
at.disabled = (s == '0')
post.likenum += 1 - 2 * int(s == '0')
if at.disabled == bool(s):
at.disabled = not bool(s)
post.likenum += 2 * s - 1
if is_admin(username) and s:
post.is_reported = False
db.session.commit()
return {
'code': 0,
'likenum': post.likenum,
'attention': (s == '1')
'attention': bool(s)
}

1
utils.py

@ -82,6 +82,7 @@ def map_post(p, name, mc=50):
if rds.sismember(RDS_KEY_DANGEROUS_USERS, p.name_hash):
r['dangerous_user'] = p.name_hash[:4]
r['blocked_count'] = rds.hget(RDS_KEY_BLOCKED_COUNT, p.name_hash)
r['is_reported'] = p.is_reported
return r

Loading…
Cancel
Save