From 8d0e312b7706a95a88980a2f2d7bcb92c71e54b3 Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Date: Dec 26 2016 18:37:04 +0000 Subject: [PATCH 1/3] Updated issues progress bar count status. --- diff --git a/pagure/templates/issues.html b/pagure/templates/issues.html index 66b73ad..de15abe 100644 --- a/pagure/templates/issues.html +++ b/pagure/templates/issues.html @@ -12,9 +12,9 @@

{% if status|lower in ['open', 'true'] %} - {{ issues|count }} Open Issues (of {{ issues_cnt }}) + {{ issues|count }} Open Issues (of {{ total_issues_cnt }}) {% elif status|lower not in ['open', 'true', 'all', 'none'] %} - {{ issues|count }} Closed Issues (of {{ issues_cnt }}) + {{ issues|count }} Closed Issues (of {{ total_issues_cnt }}) {% else %} {{ issues|count }} Issues {% endif %} @@ -51,8 +51,8 @@ {% if oth_issues %}
{% if (issues | length + oth_issues) %} - - {{ (100.0 * (1 - issues_cnt / (issues_cnt + oth_issues)))|round|int }}% + + {{ (100.0 * (issues_cnt / total_issues_cnt))|round|int }}% {% endif %}
diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index e611fc0..0e385c2 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -506,6 +506,9 @@ def view_issues(repo, username=None, namespace=None): status = None oth_issues = None + total_issues_cnt = pagure.lib.search_issues( + SESSION, repo, tags=tags, assignee=assignee, + author=author, private=private, priority=priority, count=True) if status is not None: issues = pagure.lib.search_issues( SESSION, @@ -557,9 +560,7 @@ def view_issues(repo, username=None, namespace=None): search_pattern=search_pattern, custom_search=custom_search, ) - issues_cnt = pagure.lib.search_issues( - SESSION, repo, tags=tags, assignee=assignee, - author=author, private=private, priority=priority, count=True) + issues_cnt = total_issues_cnt tag_list = pagure.lib.get_tags_of_project(SESSION, repo) @@ -574,6 +575,7 @@ def view_issues(repo, username=None, namespace=None): status=status, issues=issues, issues_cnt=issues_cnt, + total_issues_cnt=total_issues_cnt, oth_issues=oth_issues, tags=tags, assignee=assignee, From a254423a22ae0a9f2e2b01aca69088fdff483e09 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 31 2016 14:48:15 +0000 Subject: [PATCH 2/3] Attempt to fix running the tests on jenkins with a newer flask version --- diff --git a/tests/test_pagure_flask_internal.py b/tests/test_pagure_flask_internal.py index 4959faa..709a78e 100644 --- a/tests/test_pagure_flask_internal.py +++ b/tests/test_pagure_flask_internal.py @@ -123,10 +123,14 @@ class PagureFlaskInternaltests(tests.Modeltests): self.assertEqual(len(request.discussion), 1) # Check the @localonly - pagure.APP.config['IP_ALLOWED_INTERNAL'].remove(None) + before = pagure.APP.config['IP_ALLOWED_INTERNAL'][:] + pagure.APP.config['IP_ALLOWED_INTERNAL'] = [] + output = self.app.put('/pv/pull-request/comment/', data=data) self.assertEqual(output.status_code, 403) + pagure.APP.config['IP_ALLOWED_INTERNAL'] = before[:] + @patch('pagure.lib.notify.send_email') def test_ticket_add_comment(self, send_email): """ Test the ticket_add_comment function. """ @@ -198,9 +202,14 @@ class PagureFlaskInternaltests(tests.Modeltests): # Check the @localonly pagure.APP.config['IP_ALLOWED_INTERNAL'].remove(None) + before = pagure.APP.config['IP_ALLOWED_INTERNAL'][:] + pagure.APP.config['IP_ALLOWED_INTERNAL'] = [] + output = self.app.put('/pv/ticket/comment/', data=data) self.assertEqual(output.status_code, 403) + pagure.APP.config['IP_ALLOWED_INTERNAL'] = before[:] + @patch('pagure.lib.notify.send_email') def test_private_ticket_add_comment(self, send_email): """ Test the ticket_add_comment function on a private ticket. """ @@ -281,10 +290,14 @@ class PagureFlaskInternaltests(tests.Modeltests): self.assertEqual(len(issue.comments), 1) # Check the @localonly - pagure.APP.config['IP_ALLOWED_INTERNAL'].remove(None) + before = pagure.APP.config['IP_ALLOWED_INTERNAL'][:] + pagure.APP.config['IP_ALLOWED_INTERNAL'] = [] + output = self.app.put('/pv/ticket/comment/', data=data) self.assertEqual(output.status_code, 403) + pagure.APP.config['IP_ALLOWED_INTERNAL'] = before[:] + @patch('pagure.lib.notify.send_email') def test_mergeable_request_pull_FF(self, send_email): """ Test the mergeable_request_pull endpoint with a fast-forward diff --git a/tests/test_pagure_flask_ui_login.py b/tests/test_pagure_flask_ui_login.py index 88c790f..966a35f 100644 --- a/tests/test_pagure_flask_ui_login.py +++ b/tests/test_pagure_flask_ui_login.py @@ -21,6 +21,7 @@ import sys import tempfile import os +import flask import pygit2 from mock import patch @@ -232,9 +233,16 @@ class PagureFlaskLogintests(tests.Modeltests): self.assertIn( '', output.data) - self.assertIn( - 'Could not set the session in the db, please report this error ' - 'to an admin', output.data) + + # I'm not sure if the change was in flask or werkzeug, but in older + # version flask.request.remote_addr was returning None, while it + # now returns 127.0.0.1 making our logic pass where it used to + # partly fail + if hasattr(flask, '__version__') and \ + tuple(flask.__version__.split('.')) <= (0,12,0): + self.assertIn( + 'Could not set the session in the db, please report ' + 'this error to an admin', output.data) # Make the password invalid item = pagure.lib.search_user(self.session, username='foouser') @@ -284,9 +292,16 @@ class PagureFlaskLogintests(tests.Modeltests): self.assertIn( '', output.data) - self.assertIn( - 'Could not set the session in the db, please report this error ' - 'to an admin', output.data) + + # I'm not sure if the change was in flask or werkzeug, but in older + # version flask.request.remote_addr was returning None, while it + # now returns 127.0.0.1 making our logic pass where it used to + # partly fail + if hasattr(flask, '__version__') and \ + tuple(flask.__version__.split('.')) <= (0,12,0): + self.assertIn( + 'Could not set the session in the db, please report ' + 'this error to an admin', output.data) def test_confirm_user(self): """ Test the confirm_user endpoint. """ From 4b7c667dc85ded148a7503708d59799f394d296c Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Date: Dec 31 2016 14:50:57 +0000 Subject: [PATCH 3/3] Modifications for progress bar percentage. --- diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 1941395..a8abce1 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -488,11 +488,19 @@ a.notblue:hover { background-color: #FDD; } +.addrem_bar.closed { + background-color: #DBFFDB; +} + .addrem_bar > span { display: block; background-color: #DBFFDB; } +.addrem_bar.closed > span { + background-color: #FDD; +} + .comment_body img { max-width: 100%; border: 5px solid #fff; diff --git a/pagure/templates/issues.html b/pagure/templates/issues.html index de15abe..f12ac27 100644 --- a/pagure/templates/issues.html +++ b/pagure/templates/issues.html @@ -12,9 +12,9 @@

{% if status|lower in ['open', 'true'] %} - {{ issues|count }} Open Issues (of {{ total_issues_cnt }}) + {{ issues|count }} Open Issues (of {{ issues_cnt }}) {% elif status|lower not in ['open', 'true', 'all', 'none'] %} - {{ issues|count }} Closed Issues (of {{ total_issues_cnt }}) + {{ issues|count }} Closed Issues (of {{ issues_cnt }}) {% else %} {{ issues|count }} Issues {% endif %} @@ -49,9 +49,9 @@

{% if oth_issues %} -
+
{% if (issues | length + oth_issues) %} - + {{ (100.0 * (issues_cnt / total_issues_cnt))|round|int }}% {% endif %} diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index 0e385c2..fe9ba1c 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -506,6 +506,7 @@ def view_issues(repo, username=None, namespace=None): status = None oth_issues = None + oth_issues_cnt = None total_issues_cnt = pagure.lib.search_issues( SESSION, repo, tags=tags, assignee=assignee, author=author, private=private, priority=priority, count=True) @@ -552,6 +553,7 @@ def view_issues(repo, username=None, namespace=None): search_pattern=search_pattern, custom_search=custom_search, ) + oth_issues_cnt = total_issues_cnt ^ issues_cnt else: issues = pagure.lib.search_issues( SESSION, repo, tags=tags, assignee=assignee, @@ -577,6 +579,7 @@ def view_issues(repo, username=None, namespace=None): issues_cnt=issues_cnt, total_issues_cnt=total_issues_cnt, oth_issues=oth_issues, + oth_issues_cnt=oth_issues_cnt, tags=tags, assignee=assignee, author=author,