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