From 4088d10d4d4a6fb0f75ee6a6eb736ebd6bfc4f9c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 14 2015 16:08:54 +0000 Subject: Fix async editing on a comments of an issue --- diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index 89a9306..a572b78 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -413,6 +413,8 @@ function try_async_comment(form) { if(data == 'ok') { {# The event-source server will automatically refresh the UI #} $('#comment').val(''); + $('#comments').find('.comment_body').show(); + $('#comments').find('.edit_comment').remove(); } else { // Make the browser submit the form sync $(form).off('submit'); diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index 64618ce..8f8959e 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -829,17 +829,26 @@ def edit_comment_issue(repo, issueid, commentid, username=None): folder=APP.config['TICKETS_FOLDER'], ) SESSION.commit() - flask.flash(message) + if not is_js: + flask.flash(message) except SQLAlchemyError, err: # pragma: no cover SESSION.rollback() LOG.error(err) + if is_js: + return 'error' flask.flash( 'Could not edit the comment: %s' % commentid, 'error') + if is_js: + return 'ok' + return flask.redirect(flask.url_for( 'view_issue', username=username, repo=project.name, issueid=issueid)) + if is_js and flask.request.method == 'POST': + return 'failed' + return flask.render_template( 'comment_update.html', select='requests',