Example #1
0
def post_comment():
    data = request.json
    message = data['comment']
    user_id = data['userId']
    expense_id = data['expenseId']

    new_comment = Comment(message=message,
                          user_id=user_id,
                          expense_id=expense_id)
    db.session.add(new_comment)
    db.session.commit()

    return jsonify(new_comment.to_dict())
def post_comment():
    data = request.json
    new_comment = Comment(comments=data['comments'])
    db.session()
    db.session.add(new_comment)
    db.session.commit()
    return jsonify('Your comment was posted')
	def create(self, payloads):
		response = ResponseBuilder()
		comment = Comment()
		comment.content = payloads['content']
		comment.feed_id = payloads['feed_id']
		comment.user_id = payloads['user_id']
		db.session.add(comment)
		try:
			db.session.commit()
			user = comment.user.include_photos().as_dict()
			del user['fcmtoken']
			data = comment.as_dict()
			data['user'] = user
			fcm_result = self.fcmservice.send_single_notification('Comment Notification', user['username'] + ' commented on your post', comment.feed.user_id, 1, comment.feed_id)
			return response.set_data(data).build()
		except SQLAlchemyError as e:
			data = e.orig.args
			return response.set_data(data).set_error(True).build()
def delete_comment():
    delete_comment = Comment(comment=data['comment'])
    db.session()
    db.session.delete(delete_comment)
    db.session.commit()
    return jsonify('Comment was deleted')
Example #5
0
        creator_id=7,
        message="By far the most OP thing in the game rn...",
        loot_id=2,
        level=62)

    like1 = Like(liker_id=1, loot_drop_id=1, loot_drop_creator_id=7)
    like2 = Like(liker_id=2, loot_drop_id=1, loot_drop_creator_id=7)
    like3 = Like(liker_id=3, loot_drop_id=1, loot_drop_creator_id=7)
    like4 = Like(liker_id=4, loot_drop_id=1, loot_drop_creator_id=7)
    like5 = Like(liker_id=1, loot_drop_id=2, loot_drop_creator_id=7)
    like6 = Like(liker_id=2, loot_drop_id=2, loot_drop_creator_id=7)
    like7 = Like(liker_id=3, loot_drop_id=2, loot_drop_creator_id=7)
    like8 = Like(liker_id=4, loot_drop_id=2, loot_drop_creator_id=7)
    like9 = Like(liker_id=5, loot_drop_id=2, loot_drop_creator_id=7)

    comment1 = Comment(comment='Great Find', loot_drop_id=1, commentor_id=1)
    comment2 = Comment(comment='super cool bruh',
                       loot_drop_id=1,
                       commentor_id=2)
    comment3 = Comment(
        comment="Yeah you'll be seein' dead soon fool. JK I love you boo.",
        loot_drop_id=1,
        commentor_id=1)

    db.session.add(ian)
    db.session.add(javier)
    db.session.add(dean)
    db.session.add(angela)
    db.session.add(soonmi)
    db.session.add(alissa)
    db.session.add(demouser)
Example #6
0
from app.models.comments import Comment
from random import randint
from . import fake

seed_comments = [
    Comment(message=fake.paragraph(),
            user_id=randint(1, 300),
            expense_id=randint(1, 1500)) for i in range(2000)
]
Example #7
0
    for i in range(1, 50):
        num_posts = randint(10, 20)
        for j in range(1, num_posts):
            randint(1, 1000000)
            image = f'https://picsum.photos/seed/{secrets.token_hex(10)}/1000/1000'
            posts.append(Post(user_id=i, caption=fake.text(), image_url=image))

    comments = []

    for i in range(1, 50):
        comment_count = randint(10, 40)
        for j in range(1, comment_count):
            postId = randint(1, len(posts))
            comments.append(
                Comment(user_id=i, content=fake.text(), post_id=postId))

    likes = []

    for i in range(1, 658):
        users_liked_set = set()
        like_post_count = randint(0, 15)
        while len(users_liked_set) < like_post_count:
            userId = randint(1, len(users))
            if userId in users_liked_set:
                continue
            likes.append(
                Like(user_id=userId, likeable_id=i, likeable_type='post'))
            users_liked_set.add(userId)

    for user in users: