From 8215093698f313fc9bd48b8fe1a88effe9e467ed Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 1/10] Remove flashed message when creating a new project Fixes https://pagure.io/pagure/issue/925 --- diff --git a/pagure/ui/app.py b/pagure/ui/app.py index c0a34ee..00b4b1a 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -388,7 +388,6 @@ def new_project(): ) SESSION.commit() pagure.lib.git.generate_gitolite_acls() - flask.flash(message) return flask.redirect(flask.url_for('view_repo', repo=name)) except pagure.exceptions.PagureException as err: flask.flash(str(err), 'error') From a829428fe624f0350951d5bfb12f10f8539586a2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 2/10] Fix unit-tests for the drop the flashed message when creating a new project --- diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index d911f03..7853894 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -149,7 +149,8 @@ class PagureFlaskApptests(tests.Modeltests): with tests.user_set(pagure.APP, user): output = self.app.get('/new/') self.assertEqual(output.status_code, 200) - self.assertIn('Create new Project', output.data) + self.assertIn( + u'Create new Project', output.data) csrf_token = output.data.split( 'name="csrf_token" type="hidden" value="')[1].split('">')[0] @@ -160,9 +161,10 @@ class PagureFlaskApptests(tests.Modeltests): output = self.app.post('/new/', data=data) self.assertEqual(output.status_code, 200) - self.assertIn('Create new Project', output.data) self.assertIn( - '\n This field is required. \n' + u'Create new Project', output.data) + self.assertIn( + u'\n This field is required. \n' ' ', output.data) data['name'] = 'project-1' @@ -170,7 +172,7 @@ class PagureFlaskApptests(tests.Modeltests): self.assertEqual(output.status_code, 200) self.assertIn('Create new Project', output.data) self.assertNotIn( - '\n This field is required. \n' + u'\n This field is required. \n' ' ', output.data) data['csrf_token'] = csrf_token @@ -178,7 +180,7 @@ class PagureFlaskApptests(tests.Modeltests): self.assertEqual(output.status_code, 200) self.assertIn('Create new Project', output.data) self.assertIn( - '\n No user ' + u'\n No user ' '"username" found\n ', output.data) @@ -188,11 +190,11 @@ class PagureFlaskApptests(tests.Modeltests): output = self.app.post('/new/', data=data, follow_redirects=True) self.assertEqual(output.status_code, 200) self.assertIn( - '
\nProject #1
', + u'
\nProject #1
', output.data) + self.assertIn(u'

This repo is brand new!

', output.data) self.assertIn( - '\n Project "project-1" created', - output.data) + u'Overview - project-1 - Pagure', output.data) # After projects = pagure.lib.search_projects(self.session) From c8fd0da88af1c58e79dd30fbaf5174e511c9edae Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 3/10] Fix ExplicitForkIssuePattern and ExplicitMainIssuePattern These two methods had not been updated to work with the new code. This is now fixed --- diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py index e458053..16c5a6f 100644 --- a/pagure/pfmarkdown.py +++ b/pagure/pfmarkdown.py @@ -64,10 +64,11 @@ class ExplicitForkIssuePattern(markdown.inlinepatterns.Pattern): idx = markdown.util.AtomicString(m.group(4)) text = '%s/%s#%s' % (user, repo, idx) - if not _issue_exists(user, repo, idx): + issue = _issue_exists(user, repo, idx) + if not issue: return text - return _issue_anchor_tag(user, repo, idx, text) + return _obj_anchor_tag(user, repo, issue, text) class ExplicitMainIssuePattern(markdown.inlinepatterns.Pattern): @@ -79,10 +80,11 @@ class ExplicitMainIssuePattern(markdown.inlinepatterns.Pattern): idx = markdown.util.AtomicString(m.group(3)) text = ' %s#%s' % (repo, idx) - if not _issue_exists(None, repo, idx): + issue = _issue_exists(None, repo, idx) + if not issue: return text - return _issue_anchor_tag(None, repo, idx, text) + return _obj_anchor_tag(None, repo, issue, text) class ImplicitIssuePattern(markdown.inlinepatterns.Pattern): From 1a226fd7fd139c13b909838f26b019ade6d429d0 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 4/10] Add markdown support for making of PR# a link to the corresponding PR Fixes https://pagure.io/pagure/issue/940 --- diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py index 16c5a6f..6f25464 100644 --- a/pagure/pfmarkdown.py +++ b/pagure/pfmarkdown.py @@ -34,6 +34,7 @@ MENTION_RE = r'@(\w+)' EXPLICIT_FORK_ISSUE_RE = r'(\w+)/(\w+)#([0-9]+)' EXPLICIT_MAIN_ISSUE_RE = r'[^|\w](? Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 5/10] Include the priority in the JSON representation of a ticket Fixes https://pagure.io/pagure/issue/943 --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index b446d25..77eed21 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -580,6 +580,7 @@ class Issue(BASE): 'blocks': [str(item) for item in self.blocks_text], 'assignee': self.assignee.to_json( public=public) if self.assignee else None, + 'priority': self.priority, } comments = [] diff --git a/tests/test_pagure_flask_api_issue.py b/tests/test_pagure_flask_api_issue.py index 0675beb..84e8f73 100644 --- a/tests/test_pagure_flask_api_issue.py +++ b/tests/test_pagure_flask_api_issue.py @@ -162,6 +162,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 1, + "priority": None, "private": False, "status": "Open", "tags": [], @@ -213,6 +214,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 1, + "priority": None, "private": False, "status": "Open", "tags": [], @@ -267,6 +269,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 1, + "priority": None, "private": False, "status": "Open", "tags": [], @@ -307,6 +310,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 1, + "priority": None, "private": False, "status": "Open", "tags": [], @@ -324,6 +328,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 2, + "priority": None, "private": True, "status": "Open", "tags": [], @@ -398,6 +403,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 1, + "priority": None, "private": False, "status": "Open", "tags": [], @@ -415,6 +421,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 2, + "priority": None, "private": True, "status": "Open", "tags": [], @@ -471,6 +478,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 1, + "priority": None, "private": False, "status": "Open", "tags": [], @@ -564,6 +572,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 2, + "priority": None, "private": True, "status": "Open", "tags": [], @@ -590,6 +599,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): "date_created": "1431414800", "depends": [], "id": 2, + "priority": None, "private": True, "status": "Open", "tags": [], diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index 77abed5..8bbe457 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -468,7 +468,7 @@ new file mode 100644 index 0000000..60f7480 --- /dev/null +++ b/456 -@@ -0,0 +1,22 @@ +@@ -0,0 +1,23 @@ +{ + "assignee": null, + "blocks": [], @@ -477,6 +477,7 @@ index 0000000..60f7480 + "date_created": null, + "depends": [], + "id": 1, ++ "priority": null, + "private": false, + "status": "Open", + "tags": [], From 14bde249c6abe1cb6d2896f4fab249e554055ff0 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 6/10] Include the priorities in the JSON representation of a project --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 77eed21..601a644 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -439,6 +439,7 @@ class Project(BASE): 'date_created': self.date_created.strftime('%s'), 'user': self.user.to_json(public=public), 'tags': self.tags_text, + 'priorities': self.priorities, } if not api: output['settings'] = self.settings diff --git a/tests/test_pagure_flask_api_fork.py b/tests/test_pagure_flask_api_fork.py index c175ae4..eb2185c 100644 --- a/tests/test_pagure_flask_api_fork.py +++ b/tests/test_pagure_flask_api_fork.py @@ -119,6 +119,7 @@ class PagureFlaskApiForktests(tests.Modeltests): "id": 1, "name": "test", "parent": None, + "priorities": {}, "tags": [], "user": { "fullname": "PY C", @@ -132,6 +133,7 @@ class PagureFlaskApiForktests(tests.Modeltests): "id": 1, "name": "test", "parent": None, + "priorities": {}, "tags": [], "user": { "fullname": "PY C", @@ -243,6 +245,7 @@ class PagureFlaskApiForktests(tests.Modeltests): "id": 1, "name": "test", "parent": None, + "priorities": {}, "tags": [], "user": { "fullname": "PY C", @@ -256,6 +259,7 @@ class PagureFlaskApiForktests(tests.Modeltests): "id": 1, "name": "test", "parent": None, + "priorities": {}, "tags": [], "user": { "fullname": "PY C", diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index f7abe34..a2675e0 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -147,6 +147,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): "id": 1, "name": "test", "parent": None, + "priorities": {}, "tags": ["infra"], "user": { "fullname": "PY C", @@ -172,6 +173,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): "id": 1, "name": "test", "parent": None, + "priorities": {}, "tags": ["infra"], "user": { "fullname": "PY C", @@ -184,6 +186,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): "id": 2, "name": "test2", "parent": None, + "priorities": {}, "tags": [], "user": { "fullname": "PY C", @@ -208,6 +211,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): "id": 1, "name": "test", "parent": None, + "priorities": {}, "tags": ["infra"], "user": { "fullname": "PY C", diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index 8bbe457..7284356 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -696,7 +696,7 @@ new file mode 100644 index 0000000..60f7480 --- /dev/null +++ b/456 -@@ -0,0 +1,81 @@ +@@ -0,0 +1,83 @@ +{ + "assignee": null, + "branch": "master", @@ -715,6 +715,7 @@ index 0000000..60f7480 + "id": 1, + "name": "test_ticket_repo", + "parent": null, ++ "priorities": {}, + "settings": { + "Enforce_signed-off_commits_in_pull-request": false, + "Minimum_score_to_merge_pull-request": -1, @@ -743,6 +744,7 @@ index 0000000..60f7480 + "id": 1, + "name": "test_ticket_repo", + "parent": null, ++ "priorities": {}, + "settings": { + "Enforce_signed-off_commits_in_pull-request": false, + "Minimum_score_to_merge_pull-request": -1, From e5eb0b21dd54de8827defe38302c9b5d4f99176a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 7/10] Fix the default choices in the forms Fixes https://pagure.io/pagure/issue/890 --- diff --git a/pagure/forms.py b/pagure/forms.py index 007cc35..f2f83d3 100644 --- a/pagure/forms.py +++ b/pagure/forms.py @@ -72,7 +72,7 @@ class IssueForm(IssueFormSimplied): status = wtforms.SelectField( 'Status', [wtforms.validators.Required()], - choices=[(item, item) for item in []] + choices=[] ) def __init__(self, *args, **kwargs): @@ -129,7 +129,7 @@ class StatusForm(wtf.Form): status = wtforms.SelectField( 'Status', [wtforms.validators.Required()], - choices=[(item, item) for item in []] + choices=[] ) def __init__(self, *args, **kwargs): @@ -149,7 +149,7 @@ class NewTokenForm(wtf.Form): acls = wtforms.SelectMultipleField( 'ACLs', [wtforms.validators.Required()], - choices=[(item, item) for item in []] + choices=[] ) def __init__(self, *args, **kwargs): @@ -188,12 +188,12 @@ class UpdateIssueForm(wtf.Form): status = wtforms.SelectField( 'Status', [wtforms.validators.Optional()], - choices=[(item, item) for item in []] + choices=[] ) priority = wtforms.SelectField( 'Priority', [wtforms.validators.Optional()], - choices=[(item, item) for item in []] + choices=[] ) def __init__(self, *args, **kwargs): @@ -330,7 +330,7 @@ class NewGroupForm(wtf.Form): group_type = wtforms.SelectField( 'Group type', [wtforms.validators.Required()], - choices=[(item, item) for item in []] + choices=[] ) def __init__(self, *args, **kwargs): @@ -355,7 +355,7 @@ class EditFileForm(wtf.Form): 'Commit message', [wtforms.validators.optional()]) email = wtforms.SelectField( 'Email', [wtforms.validators.Required()], - choices=[(item, item) for item in []] + choices=[] ) branch = wtforms.TextField( 'Branch', [wtforms.validators.Required()]) @@ -377,7 +377,7 @@ class DefaultBranchForm(wtf.Form): branches = wtforms.SelectField( 'default_branch', [wtforms.validators.Required()], - choices=[(item, item) for item in []] + choices=[] ) def __init__(self, *args, **kwargs): From a0eddb3a9c65d876538bcb12ea97af134aa4342c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 8/10] Fix the links to the commit introduced by the pagure git hook Fixes https://pagure.io/pagure/issue/944 --- diff --git a/pagure/hooks/files/pagure_hook.py b/pagure/hooks/files/pagure_hook.py index 8531320..53bcd8f 100755 --- a/pagure/hooks/files/pagure_hook.py +++ b/pagure/hooks/files/pagure_hook.py @@ -64,7 +64,7 @@ def relates_commit(commitid, issue, app_url=None): project = issue.project.fullname if issue.project.is_fork: project = 'fork/%s' % project - url = '%s/%s/%s' % (app_url, project, commitid[:8]) + url = '%s/%s/c/%s' % (app_url, project, commitid[:8]) comment = ''' Commit [%s](%s) relates to this ticket''' % ( commitid[:8], url) From 297fec37398abe8d5a030deb24d710d71e3315a7 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 9/10] Do not update the assignee if the person who commented isn't an admin --- diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index e70d8c2..5642016 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -170,19 +170,21 @@ def update_issue(repo, issueid, username=None): for message in messages: flask.flash(message) - # Assign or update assignee of the ticket - message = pagure.lib.add_issue_assignee( - SESSION, - issue=issue, - assignee=assignee or None, - user=flask.g.fas_user.username, - ticketfolder=APP.config['TICKETS_FOLDER'], - ) - if message and not is_js: + # The meta-data can only be changed by admins, which means they + # will be missing for non-admin and thus reset if we let them + if repo_admin: + # Assign or update assignee of the ticket + message = pagure.lib.add_issue_assignee( + SESSION, + issue=issue, + assignee=assignee or None, + user=flask.g.fas_user.username, + ticketfolder=APP.config['TICKETS_FOLDER'], + ) SESSION.commit() - flask.flash(message) + if message and not is_js: + flask.flash(message) - if repo_admin: # Update status if new_status in status: message = pagure.lib.edit_issue( From bbe431ffd3f4c8dfed81ae28edc96e520e3da7a9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2016 18:20:05 +0000 Subject: [PATCH 10/10] Include the content of the comment in the form if there is one Fixes https://pagure.io/pagure/issue/945 --- diff --git a/pagure/templates/pull_request_comment.html b/pagure/templates/pull_request_comment.html index 882bba8..f3f6f2b 100644 --- a/pagure/templates/pull_request_comment.html +++ b/pagure/templates/pull_request_comment.html @@ -14,7 +14,9 @@
+ title="comment" style="width:100%;"> + {{- form.comment.data if form.comment.data else '' -}} +