From a225965cd09ccc16a82c37da0f45a298912a73ed Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 31 2019 20:04:48 +0000 Subject: [PATCH 1/2] Fix not showing the edit and delete buttons when they won't work If there is no identifier (which is the case when the comment is added using ajax rather than being received by SSE), the edit and delete buttons on the comment won't work, so there is no point in showing them, the users will just have to refresh the page to see them. In addition, this commit removes the link to the comment itself, for the same reason. Fixes https://pagure.io/pagure/issue/4210 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/static/request_ev.js b/pagure/static/request_ev.js index 7c39e6d..4fb56b7 100644 --- a/pagure/static/request_ev.js +++ b/pagure/static/request_ev.js @@ -41,23 +41,25 @@ add_comment = function(data, username) { + ' '+data.comment_user+'' + ' ' - + ' commented seconds ago' + if (data.comment_id) { + _data += ' href="#comment-' + data.comment_id + '"'; + } + _data += '>commented seconds ago' + ' ' + ' '; - if ( data.comment_user == username && data.comment_id !== 'undefined') { - _data = _data - + '
' - + ' ' - + ' ' - + ' ' - + ' ' - + '
' + if ( data.comment_user == username && data.comment_id !== undefined) { + _data = _data + + '
' + + ' ' + + ' ' + + ' ' + + ' ' + + '
'; } _data = _data From 4104e6c4ba0f101953481e49c8275075c44e8582 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 31 2019 20:04:48 +0000 Subject: [PATCH 2/2] Small black fixes Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index a1c1927..060c7b7 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -2295,7 +2295,7 @@ class PullRequestFlag(BASE): token_id = sa.Column( sa.String(64), sa.ForeignKey("tokens.id", ondelete="CASCADE", onupdate="CASCADE"), - nullable=True + nullable=True, ) status = sa.Column(sa.String(32), nullable=False) user_id = sa.Column( @@ -3008,7 +3008,10 @@ class Token(BASE): """ Return a string representation of this object. """ return "Token: %s - name %s - expiration: %s" % ( - self.id, self.description, self.expiration) + self.id, + self.description, + self.expiration, + ) @property def expired(self):