From 1b083056fe62ceb93655f721b05151d4322f7576 Mon Sep 17 00:00:00 2001 From: Tdxdxoz Date: Tue, 9 Nov 2021 21:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E4=B8=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 7 +++---- templates/story.html | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 123c2c0..a265442 100644 --- a/app.py +++ b/app.py @@ -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)) diff --git a/templates/story.html b/templates/story.html index e5d3553..75ae4bb 100644 --- a/templates/story.html +++ b/templates/story.html @@ -184,8 +184,6 @@