From c327f4a29d49e1564c86e09e873720e988b27c27 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 25 2016 10:08:25 +0000 Subject: [PATCH 1/3] Be consistent on when we show the edit button From now on it will be shown only when authenticated and only to the admin of the repo or the author of the comment --- diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index 84f14f5..8631ccd 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -138,11 +138,15 @@ + {% if id != 0 and g.fas_user and ( + (comment.parent.status in [True, 'Open'] and g.fas_user.username == comment.user.username) + or repo_admin) %} + {% endif %} {% if id != 0 and g.fas_user and ( (comment.parent.status in [True, 'Open'] and g.fas_user.username == comment.user.username) or repo_admin) %} @@ -151,6 +155,7 @@ title="Remove comment"> + {% endif %} @@ -177,7 +182,8 @@ reply - {% if repo_admin or (g.fas_user.username == comment.user.username) %} + {% if repo_admin or ( + g.fas_user and g.fas_user.username == comment.user.username) %} edit From be8411e78d79aabcdee1c2253d10098556d724f2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 25 2016 10:09:05 +0000 Subject: [PATCH 2/3] Adjust unit-tests for the change on when the edit button is displayed --- diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index bd34b53..7ccf118 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -308,7 +308,8 @@ class PagureFlaskIssuestests(tests.Modeltests): output = self.app.get('/test/issue/1') self.assertEqual(output.status_code, 200) - self.assertIn( + # Not authentified = No edit + self.assertNotIn( '', output.data) self.assertTrue( @@ -320,7 +321,8 @@ class PagureFlaskIssuestests(tests.Modeltests): with tests.user_set(pagure.APP, user): output = self.app.get('/test/issue/1') self.assertEqual(output.status_code, 200) - self.assertIn( + # Not author nor admin = No edit + self.assertNotIn( '', output.data) self.assertFalse( From 995f746e0755898ce2b4c236961e5bdd572995f1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 25 2016 10:09:19 +0000 Subject: [PATCH 3/3] Fix displaying the content of the initial comment --- diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index 8631ccd..93d49ff 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -170,11 +170,7 @@
{% autoescape false %} - {% if id == 0 %} {{ comment.content | markdown }} - {% else %} - {{ comment.comment | markdown }} - {% endif %} {% endautoescape %}