Beispiel #1
0
 def post(self, replyId):
     user = request.user
     reply = Reply.query.filter_by(id=replyId).first_or_404()
     reply.likers.append(user)
     reply.save()
     MessageClient.like(reply)
     serializer = Serializer(reply, many=False)
     return HTTPResponse(
         HTTPResponse.NORMAL_STATUS, data=serializer.data).to_response()
Beispiel #2
0
 def post(self, replyId):
     user = request.user
     reply = Reply.query.filter_by(id=replyId).first_or_404()
     reply.likers.append(user)
     reply.save()
     MessageClient.like(reply)
     serializer = Serializer(reply, many=False)
     return HTTPResponse(
         HTTPResponse.NORMAL_STATUS, data=serializer.data).to_response()
Beispiel #3
0
 def post(self):
     user = request.user
     post_data = request.data
     user_id = post_data.pop('userId', None)
     if user_id is not None:
         f_user = User.query.filter_by(id=user_id).first_or_404()
         if not f_user.is_followed(user):
             user.following_users.append(f_user)
             user.save()
         MessageClient.follow(f_user)
     return HTTPResponse(HTTPResponse.NORMAL_STATUS).to_response()
Beispiel #4
0
 def post(self):
     user = request.user
     post_data = request.data
     user_id = post_data.pop('userId', None)
     if user_id is not None:
         f_user = User.query.filter_by(id=user_id).first_or_404()
         if not f_user.is_followed(user):
             user.following_users.append(f_user)
             user.save()
         MessageClient.follow(f_user)
     return HTTPResponse(HTTPResponse.NORMAL_STATUS).to_response()
Beispiel #5
0
 def post(self):
     user = request.user
     post_data = request.data
     topic_id = post_data.pop('topicId', None)
     if topic_id is not None and not User.query.filter_by(
             following_topics__id=topic_id).exists():
         topic = Topic.query.filter_by(id=topic_id).first_or_404()
         user.following_topics.append(topic)
         user.save()
         # notice
         MessageClient.follow(topic)
     return HTTPResponse(HTTPResponse.NORMAL_STATUS).to_response()
Beispiel #6
0
 def post(self):
     user = request.user
     post_data = request.data
     topic_id = post_data.pop('topicId', None)
     if topic_id is not None and not User.query.filter_by(
             following_topics__id=topic_id).exists():
         topic = Topic.query.filter_by(id=topic_id).first_or_404()
         user.following_topics.append(topic)
         user.save()
         # notice
         MessageClient.follow(topic)
     return HTTPResponse(HTTPResponse.NORMAL_STATUS).to_response()
Beispiel #7
0
 def post(self, topicId):
     user = request.user
     form = request.form.getlist('add-to-collect')
     topic = Topic.query.filter_by(id=topicId).first_or_404()
     for cid in form:
         '''This has a problem'''
         collect = Collect.query.filter_by(id=cid).first_or_404()
         if not Collect.query.filter_by(
                 topics__id=topic.id, author_id=user.id).exists():
             collect.topics.append(topic)
             collect.save()
         MessageClient.collect(topic)
     return redirect(url_for('topic.topic', topicId=topic.id))
Beispiel #8
0
 def post(self, topicId):
     user = request.user
     form = request.form.getlist('add-to-collect')
     topic = Topic.query.filter_by(id=topicId).first_or_404()
     for cid in form:
         '''This has a problem'''
         collect = Collect.query.filter_by(id=cid).first_or_404()
         if not Collect.query.filter_by(topics__id=topic.id,
                                        author_id=user.id).exists():
             collect.topics.append(topic)
             collect.save()
         MessageClient.collect(topic)
     return redirect(url_for('topic.topic', topicId=topic.id))
Beispiel #9
0
 def post(self, topicId):
     topic = Topic.query.filter_by(id=topicId).first_or_404()
     post_data = request.data
     user = request.user
     content = post_data.pop('content', None)
     reply = Reply(content=content, topic_id=topic.id)
     reply.author = user
     reply.save()
     # notice
     MessageClient.topic(reply)
     # count
     topic.board.post_count = 1
     reply.author.reply_count = 1
     return redirect(url_for('topic.topic', topicId=topic.id))
Beispiel #10
0
 def post(self, topicId):
     topic = Topic.query.filter_by(id=topicId).first_or_404()
     post_data = request.data
     user = request.user
     content = post_data.pop('content', None)
     reply = Reply(content=content, topic_id=topic.id)
     reply.author = user
     reply.save()
     # notice
     MessageClient.topic(reply)
     # count
     topic.board.post_count = 1
     reply.author.reply_count = 1
     return redirect(url_for('topic.topic', topicId=topic.id))