Browse Source

点赞不需要登录

pull/5/head
欧醚 3 years ago
parent
commit
1b083056fe
2 changed files with 3 additions and 6 deletions
  1. +3
    -4
      app.py
  2. +0
    -2
      templates/story.html

+ 3
- 4
app.py View File

@ -79,7 +79,7 @@ class Paragraph(db.Model):
return self.time.strftime("%m-%d %H:%M")
def reaction_status(self):
user = session.get('username')
user = session['uid']
return list(zip(
'👍😡🤣😅👎',
[self.like_num, self.angry_num, self.fun_num, self.sweat_num, 0],
@ -95,7 +95,7 @@ class Reaction(db.Model):
id = db.Column(db.Integer, primary_key=True)
kind = db.Column(db.SmallInteger) # 1: like 2: angry 3: funny 4: sweat 5:dislike
pid = db.Column(db.Integer, index=True) # id of paragraph
user = db.Column(db.String(30)) # username of user
user = db.Column(db.String(30)) # str(uid)
def choose_new_next(min_like_num=MIN_LIKE_NUM):
@ -291,7 +291,6 @@ def create():
@bp.route('/react', methods=['POST'])
@login_required
@limiter.limit("100 / minute")
def react():
kind = request.form.get('kind', type=int)
@ -300,7 +299,7 @@ def react():
abort(422)
p = Paragraph.query.get_or_404(pid)
d = dict(kind=kind, user=session['username'], pid=pid)
d = dict(kind=kind, user=session['uid'], pid=pid)
if Reaction.query.filter_by(**d).first():
return ''
db.session.add(Reaction(**d))

+ 0
- 2
templates/story.html View File

@ -184,8 +184,6 @@
<script>
$('.can-react').click(function (e) {
if (check_login())
return;
$this = $(this);
$.post(
'react',

Loading…
Cancel
Save