def edit_comment(paste_id, hash_id): comment = Comment.objects.get_or_404(hash_id=hash_id) form = CommentForm(request.form) if request.method == 'POST': if form.validate(): comment.content = form.content.data comment.save() return redirect(url_for('paste_app.view_paste', hash_id=paste_id)) return render_template('pastes/edit_comment.html', paste_id=paste_id, comment=comment)
def comments(hash_id): paste = Paste.objects.get_or_404(hash_id=hash_id) form = CommentForm(request.form) if form.validate(): comment = Comment(user=current_user.user, paste=paste, content=form.content.data) comment.save() if comment.user != paste.user: content = NEW_COMMENT.format(user_username=current_user.user.username, user_url=url_for('user_app.view', username=current_user.user.username), paste_title=paste.title, paste_url=url_for('paste_app.view_paste', hash_id=paste.hash_id)) message = Message(user=paste.user, who=current_user.user, content=content) message.save() return redirect(url_for('paste_app.view_paste', hash_id=hash_id))
def comments(hash_id): paste = Paste.objects.get_or_404(hash_id=hash_id) form = CommentForm(request.form) if form.validate(): comment = Comment(user=current_user.user, paste=paste, content=form.content.data) comment.save() if comment.user != paste.user: content = NEW_COMMENT.format( user_username=current_user.user.username, user_url=url_for('user_app.view', username=current_user.user.username), paste_title=paste.title, paste_url=url_for('paste_app.view_paste', hash_id=paste.hash_id)) message = Message(user=paste.user, who=current_user.user, content=content) message.save() return redirect(url_for('paste_app.view_paste', hash_id=hash_id))