From 3ccaba6da83e553bdf456d3b8742bc1737782502 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 28 2018 12:54:52 +0000 Subject: [PATCH 1/3] Move the api keys settings into their own template Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index 33925c5..4bdb9ac 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -208,134 +208,7 @@ {% endif %}
-

- API Keys - - - -

-
-
-

- API keys are tokens used to authenticate you on pagure. They can also - be used to grant access to 3rd party application to behave on this - project on your name. -

-

- These are your personal tokens; they are not visible to the other - admins of this repository. -

-

- These keys are valid for 60 days. -

-

- These keys are private to your project, make sure to store in a safe - place and do not share it. -

- {% if repo.tokens %} - {% for token in repo.tokens %} - {% if token.user.username == g.fas_user.username %} -
-
-
- - - {{ token.description or '' }} - -
-
- - - {{token.acls_list_pretty|length}} ACLs - - - -
- - - - {% if token.expired %} - - - Expired on {{ token.expiration.date() }} - - - {% else %} - - - Active until {{ token.expiration.date() }} - - - {% endif %} - {% if not token.expired %} -
- - {{ form.csrf_token }} -
- {% else %} -
- - {{ form.csrf_token }} -
- {% endif %} -
-
- {% endif %} - {% endfor %} - {% endif %} -
-
+ {% include 'settings_api_keys.html' %}
diff --git a/pagure/templates/settings_api_keys.html b/pagure/templates/settings_api_keys.html new file mode 100644 index 0000000..470a63b --- /dev/null +++ b/pagure/templates/settings_api_keys.html @@ -0,0 +1,128 @@ + +

+ API Keys + + + +

+
+
+

+ API keys are tokens used to authenticate you on pagure. They can also + be used to grant access to 3rd party application to behave on this + project on your name. +

+

+ These are your personal tokens; they are not visible to the other + admins of this repository. +

+

+ These keys are valid for 60 days. +

+

+ These keys are private to your project, make sure to store in a safe + place and do not share it. +

+ {% if repo.tokens %} + {% for token in repo.tokens %} + {% if token.user.username == g.fas_user.username %} +
+
+
+ + + {{ token.description or '' }} + +
+
+ + + {{token.acls_list_pretty|length}} ACLs + + + +
+ + + {% if token.expired %} + + + Expired on {{ token.expiration.date() }} + + + {% else %} + + + Active until {{ token.expiration.date() }} + + + {% endif %} + {% if not token.expired %} +
+ + {{ form.csrf_token }} +
+ {% else %} +
+ + {{ form.csrf_token }} +
+ {% endif %} +
+
+ {% endif %} + {% endfor %} + {% endif %} +
+
From 23fa8e458c4cd308b57750554d84792ccc114d24 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 28 2018 12:54:52 +0000 Subject: [PATCH 2/3] Hide expired API keys by default but add a button to show them Fixes https://pagure.io/pagure/issue/3687 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 025b390..621db34 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -242,7 +242,7 @@ th[data-sort] { margin-left:2em; } -.hidden, .milestone_inactive{ +.hidden, .milestone_inactive, .expired_api_keys{ display: none; } @@ -338,4 +338,4 @@ th[data-sort] { .line-height-1{ line-height: 1em; -} \ No newline at end of file +} diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index 4bdb9ac..45e772f 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -1309,6 +1309,17 @@ $('.milestone_order_bottom').click(function(e) { } }); +$('#show_old_keys').click(function(e) { + var _el = $('.expired_api_keys') + if (_el.css('display') == 'none'){ + _el.css('display', 'flex'); + $('#show_old_keys').text('Hide old API keys'); + } else { + $('#show_old_keys').text('Show old API keys'); + _el.hide(); + } +}); + {% if config.get('ENABLE_GIVE_PROJECTS', True) and repo.user.user == g.fas_user.username and not repo.is_fork %} diff --git a/pagure/templates/settings_api_keys.html b/pagure/templates/settings_api_keys.html index 470a63b..c78f1c5 100644 --- a/pagure/templates/settings_api_keys.html +++ b/pagure/templates/settings_api_keys.html @@ -1,17 +1,29 @@ -

- API Keys - - -

+ +
+ + +

@@ -33,7 +45,7 @@ {% if repo.tokens %} {% for token in repo.tokens %} {% if token.user.username == g.fas_user.username %} -

+
From ff299a5213e5708f6c6423b60b40c459f175feab Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 28 2018 12:54:52 +0000 Subject: [PATCH 3/3] Adjust indentation in the milestones settings template Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/settings_milestones.html b/pagure/templates/settings_milestones.html index 3c995bb..6ee133b 100644 --- a/pagure/templates/settings_milestones.html +++ b/pagure/templates/settings_milestones.html @@ -7,76 +7,76 @@ possible to create a roadmap for your project. Below you can create the milestones and optionally set dates for them.

-
- {{ tag_form.csrf_token }} -
-
- Milestone -
-
- Date (optional) -
-
- Reorder -
-
- Active -
-
-
- {% for milestone in (repo.milestones_keys or repo.milestones or [""]) %} -
-
- -
-
- -
-
- - -
-
- -
-
- {% endfor %} -
- -
-
- -
-
-
+
+ {{ tag_form.csrf_token }} +
+
+ Milestone +
+
+ Date (optional) +
+
+ Reorder +
+
+ Active +
+
+
+ {% for milestone in (repo.milestones_keys or repo.milestones or [""]) %} +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ {% endfor %} +
+ +
+
+ +
+
+
diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index f60746a..7c31536 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -1433,25 +1433,25 @@ class PagureFlaskRepotests(tests.Modeltests): # Check that the milestones have their empty fields self.assertIn( '''
-
-
- -
-
- -
-
- - -
-
- -
-
''', output_text) +
+
+ +
+
+ +
+
+ + +
+
+ +
+
''', output_text) # Check that the close_status have its empty field self.assertIn( @@ -4318,7 +4318,6 @@ index 0000000..fb7093d output_text = output.get_data(as_text=True) self.assertIn('0.0.1', output_text) self.assertIn('
', output_text) - print(output_text) self.assertEqual( output_text.count(''), 1) @@ -5051,9 +5050,9 @@ index 0000000..fb7093d self.assertIn('
Project Settings
', output_text) self.assertIn(' Test token', output_text) self.assertIn( - '\n ' - 'Active until', - output_text) + '' + '\n ' + 'Active until', output_text) @patch('pagure.decorators.admin_session_timedout') def test_revoke_api_token(self, ast): diff --git a/tests/test_pagure_flask_ui_repo_milestones.py b/tests/test_pagure_flask_ui_repo_milestones.py index 26b7714..b57dd7d 100644 --- a/tests/test_pagure_flask_ui_repo_milestones.py +++ b/tests/test_pagure_flask_ui_repo_milestones.py @@ -67,25 +67,25 @@ class PagureFlaskRepoMilestonestests(tests.Modeltests): # Check that the milestones have their empty fields self.assertIn( '''
-
-
- -
-
- -
-
- - -
-
- -
-
''', output.get_data(as_text=True)) +
+
+ +
+
+ +
+
+ + +
+
+ +
+
''', output.get_data(as_text=True)) @patch('pagure.decorators.admin_session_timedout', MagicMock(return_value=False))