From 8cc752c554219140bbc0a33508432f6e26b49cd5 Mon Sep 17 00:00:00 2001 From: Koichi MATSUMOTO Date: Oct 08 2020 19:18:45 +0000 Subject: [PATCH 1/4] Fixed forms' glitches. --- diff --git a/pagure/forms.py b/pagure/forms.py index 366d8ae..5b0ef0f 100644 --- a/pagure/forms.py +++ b/pagure/forms.py @@ -136,7 +136,7 @@ class ProjectFormSimplified(PagureForm): """ Form to edit the description of a project. """ description = wtforms.StringField( - 'Description *', + 'Description', [wtforms.validators.DataRequired()], ) url = wtforms.StringField( @@ -169,7 +169,7 @@ class ProjectFormSimplified(PagureForm): class ProjectForm(ProjectFormSimplified): """ Form to create or edit project. """ - name = wtforms.StringField('Project name *') + name = wtforms.StringField('Project name') mirrored_from = wtforms.StringField( "Mirror from URL", [ @@ -252,11 +252,11 @@ class IssueFormSimplied(PagureForm): """ Form to create or edit an issue. """ title = wtforms.StringField( - 'Title*', + 'Title', [wtforms.validators.DataRequired()], ) issue_content = wtforms.TextAreaField( - 'Content*', + 'Content', [wtforms.validators.DataRequired()], ) private = wtforms.BooleanField( @@ -317,7 +317,7 @@ class RequestPullForm(PagureForm): """ Form to create a pull request. """ title = wtforms.StringField( - 'Title*', + 'Title', [wtforms.validators.DataRequired()], ) initial_comment = wtforms.TextAreaField( @@ -334,18 +334,18 @@ class RemoteRequestPullForm(RequestPullForm): """ Form to create a remote pull request. """ git_repo = wtforms.StringField( - 'Git repo address*', + 'Git repo address', [ wtforms.validators.DataRequired(), wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE), ], ) branch_from = wtforms.StringField( - 'Git branch*', + 'Git branch', [wtforms.validators.DataRequired()], ) branch_to = wtforms.StringField( - 'Git branch to merge in*', + 'Git branch to merge in', [wtforms.validators.DataRequired()], ) @@ -554,7 +554,7 @@ class AddPullRequestCommentForm(PagureForm): requestid = wtforms.HiddenField("requestid") tree_id = wtforms.HiddenField("treeid") comment = wtforms.TextAreaField( - 'Comment*', + 'Comment', [wtforms.validators.DataRequired()], ) @@ -605,7 +605,7 @@ class AddSSHKeyForm(PagureForm): """ Form to add a SSH key to a user. """ ssh_key = wtforms.StringField( - 'SSH Key *', + 'SSH Key', [wtforms.validators.DataRequired()] # TODO: Add an ssh key validator? ) @@ -625,15 +625,15 @@ class AddUserForm(PagureForm): """ Form to add a user to a project. """ user = wtforms.StringField( - 'Username *', + 'Username', [wtforms.validators.DataRequired()], ) access = wtforms.StringField( - 'Access Level *', + 'Access Level', [wtforms.validators.DataRequired()], ) branches = wtforms.StringField( - 'Git branches *', + 'Git branches', [wtforms.validators.Optional()], ) @@ -642,7 +642,7 @@ class AddUserToGroupForm(PagureForm): """ Form to add a user to a pagure group. """ user = wtforms.StringField( - 'Username *', + 'Username', [wtforms.validators.DataRequired()], ) @@ -651,7 +651,7 @@ class AssignIssueForm(PagureForm): """ Form to assign an user to an issue. """ assignee = wtforms.StringField( - 'Assignee *', + 'Assignee', [wtforms.validators.Optional()], ) @@ -660,18 +660,18 @@ class AddGroupForm(PagureForm): """ Form to add a group to a project. """ group = wtforms.StringField( - 'Group *', + 'Group', [ wtforms.validators.DataRequired(), wtforms.validators.Regexp(STRICT_REGEX, flags=re.IGNORECASE), ], ) access = wtforms.StringField( - 'Access Level *', + 'Access Level', [wtforms.validators.DataRequired()], ) branches = wtforms.StringField( - 'Git branches *', + 'Git branches', [wtforms.validators.Optional()], ) @@ -691,7 +691,7 @@ class ModifyACLForm(PagureForm): choices=[("user", "User"), ("group", "Group")], ) name = wtforms.StringField( - 'User- or Groupname *', + 'User- or Groupname', [wtforms.validators.DataRequired()], ) acl = wtforms.SelectField( @@ -773,7 +773,7 @@ class NewGroupForm(EditGroupForm): """ Form to ask for a password change. """ group_name = wtforms.StringField( - 'Group name *', + 'Group name', [ wtforms.validators.DataRequired(), wtforms.validators.Length(max=255), @@ -866,7 +866,7 @@ class EditCommentForm(PagureForm): """ update_comment = wtforms.TextAreaField( - 'Comment*', + 'Comment ', [wtforms.validators.DataRequired()], ) @@ -890,7 +890,7 @@ class AddReportForm(PagureForm): """ report_name = wtforms.TextAreaField( - 'Report name*', + 'Report name', [wtforms.validators.DataRequired()], ) @@ -900,12 +900,12 @@ class PublicNotificationForm(PagureForm): """ issue_notifs = wtforms.TextAreaField( - 'Public issue notification*', + 'Public issue notification', [wtforms.validators.optional(), MultipleEmail()], ) pr_notifs = wtforms.TextAreaField( - 'Public PR notification*', + 'Public PR notification', [wtforms.validators.optional(), MultipleEmail()], ) @@ -953,7 +953,7 @@ class AddGitTagForm(PagureForm): """ Form to create a new git tag. """ tagname = wtforms.StringField( - 'Name of the tag*', + 'Name of the tag', [wtforms.validators.DataRequired()], ) commit_hash = wtforms.StringField( diff --git a/pagure/login_forms.py b/pagure/login_forms.py index 2cd8d5c..53dcfce 100644 --- a/pagure/login_forms.py +++ b/pagure/login_forms.py @@ -43,7 +43,7 @@ class LostPasswordForm(FlaskForm): """ Form to ask for a password change. """ username = wtforms.StringField( - 'username *', + 'username', [wtforms.validators.DataRequired()], ) @@ -52,11 +52,11 @@ class ResetPasswordForm(FlaskForm): """ Form to reset one's password in the local database. """ password = wtforms.PasswordField( - 'Password *', + 'Password', [wtforms.validators.DataRequired()], ) confirm_password = wtforms.PasswordField( - 'Confirm password *', + 'Confirm password', [wtforms.validators.DataRequired(), same_password], ) @@ -65,11 +65,11 @@ class LoginForm(FlaskForm): """ Form to login via the local database. """ username = wtforms.StringField( - 'username *', + 'username', [wtforms.validators.DataRequired()], ) password = wtforms.PasswordField( - 'Password *', + 'Password', [wtforms.validators.DataRequired()], ) @@ -78,22 +78,22 @@ class NewUserForm(FlaskForm): """ Form to add a new user to the local database. """ user = wtforms.StringField( - 'username *', + 'username', [wtforms.validators.DataRequired()], ) fullname = wtforms.StringField( "Full name", [wtforms.validators.Optional()] ) email_address = wtforms.StringField( - 'Email address *', + 'Email address', [wtforms.validators.DataRequired(), wtforms.validators.Email()], ) password = wtforms.PasswordField( - 'Password *', + 'Password', [wtforms.validators.DataRequired()], ) confirm_password = wtforms.PasswordField( - 'Confirm password *', + 'Confirm password', [wtforms.validators.DataRequired(), same_password], ) @@ -102,14 +102,14 @@ class ChangePasswordForm(FlaskForm): """ Form to reset one's password in the local database. """ old_password = wtforms.PasswordField( - 'Old Password *', + 'Old Password', [wtforms.validators.DataRequired()], ) password = wtforms.PasswordField( - 'Password *', + 'Password', [wtforms.validators.DataRequired()], ) confirm_password = wtforms.PasswordField( - 'Confirm password *', + 'Confirm password', [wtforms.validators.DataRequired(), same_password], ) diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index 714211d..67edd26 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -31,7 +31,7 @@ {% endif %} {% else %}
- {{ field.label }} + {{ field.label }} {% if field.errors %} * {% endif %} {% if rightlink %}
{{rightlink['text']}} {% endif %} From 4fcf88e9b286d2143566f2cb22a90468196d79e9 Mon Sep 17 00:00:00 2001 From: Koichi MATSUMOTO Date: Oct 09 2020 12:52:35 +0000 Subject: [PATCH 2/4] Fixed forms' glitches. --- diff --git a/pagure/forms.py b/pagure/forms.py index 366d8ae..5b0ef0f 100644 --- a/pagure/forms.py +++ b/pagure/forms.py @@ -136,7 +136,7 @@ class ProjectFormSimplified(PagureForm): """ Form to edit the description of a project. """ description = wtforms.StringField( - 'Description *', + 'Description', [wtforms.validators.DataRequired()], ) url = wtforms.StringField( @@ -169,7 +169,7 @@ class ProjectFormSimplified(PagureForm): class ProjectForm(ProjectFormSimplified): """ Form to create or edit project. """ - name = wtforms.StringField('Project name *') + name = wtforms.StringField('Project name') mirrored_from = wtforms.StringField( "Mirror from URL", [ @@ -252,11 +252,11 @@ class IssueFormSimplied(PagureForm): """ Form to create or edit an issue. """ title = wtforms.StringField( - 'Title*', + 'Title', [wtforms.validators.DataRequired()], ) issue_content = wtforms.TextAreaField( - 'Content*', + 'Content', [wtforms.validators.DataRequired()], ) private = wtforms.BooleanField( @@ -317,7 +317,7 @@ class RequestPullForm(PagureForm): """ Form to create a pull request. """ title = wtforms.StringField( - 'Title*', + 'Title', [wtforms.validators.DataRequired()], ) initial_comment = wtforms.TextAreaField( @@ -334,18 +334,18 @@ class RemoteRequestPullForm(RequestPullForm): """ Form to create a remote pull request. """ git_repo = wtforms.StringField( - 'Git repo address*', + 'Git repo address', [ wtforms.validators.DataRequired(), wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE), ], ) branch_from = wtforms.StringField( - 'Git branch*', + 'Git branch', [wtforms.validators.DataRequired()], ) branch_to = wtforms.StringField( - 'Git branch to merge in*', + 'Git branch to merge in', [wtforms.validators.DataRequired()], ) @@ -554,7 +554,7 @@ class AddPullRequestCommentForm(PagureForm): requestid = wtforms.HiddenField("requestid") tree_id = wtforms.HiddenField("treeid") comment = wtforms.TextAreaField( - 'Comment*', + 'Comment', [wtforms.validators.DataRequired()], ) @@ -605,7 +605,7 @@ class AddSSHKeyForm(PagureForm): """ Form to add a SSH key to a user. """ ssh_key = wtforms.StringField( - 'SSH Key *', + 'SSH Key', [wtforms.validators.DataRequired()] # TODO: Add an ssh key validator? ) @@ -625,15 +625,15 @@ class AddUserForm(PagureForm): """ Form to add a user to a project. """ user = wtforms.StringField( - 'Username *', + 'Username', [wtforms.validators.DataRequired()], ) access = wtforms.StringField( - 'Access Level *', + 'Access Level', [wtforms.validators.DataRequired()], ) branches = wtforms.StringField( - 'Git branches *', + 'Git branches', [wtforms.validators.Optional()], ) @@ -642,7 +642,7 @@ class AddUserToGroupForm(PagureForm): """ Form to add a user to a pagure group. """ user = wtforms.StringField( - 'Username *', + 'Username', [wtforms.validators.DataRequired()], ) @@ -651,7 +651,7 @@ class AssignIssueForm(PagureForm): """ Form to assign an user to an issue. """ assignee = wtforms.StringField( - 'Assignee *', + 'Assignee', [wtforms.validators.Optional()], ) @@ -660,18 +660,18 @@ class AddGroupForm(PagureForm): """ Form to add a group to a project. """ group = wtforms.StringField( - 'Group *', + 'Group', [ wtforms.validators.DataRequired(), wtforms.validators.Regexp(STRICT_REGEX, flags=re.IGNORECASE), ], ) access = wtforms.StringField( - 'Access Level *', + 'Access Level', [wtforms.validators.DataRequired()], ) branches = wtforms.StringField( - 'Git branches *', + 'Git branches', [wtforms.validators.Optional()], ) @@ -691,7 +691,7 @@ class ModifyACLForm(PagureForm): choices=[("user", "User"), ("group", "Group")], ) name = wtforms.StringField( - 'User- or Groupname *', + 'User- or Groupname', [wtforms.validators.DataRequired()], ) acl = wtforms.SelectField( @@ -773,7 +773,7 @@ class NewGroupForm(EditGroupForm): """ Form to ask for a password change. """ group_name = wtforms.StringField( - 'Group name *', + 'Group name', [ wtforms.validators.DataRequired(), wtforms.validators.Length(max=255), @@ -866,7 +866,7 @@ class EditCommentForm(PagureForm): """ update_comment = wtforms.TextAreaField( - 'Comment*', + 'Comment ', [wtforms.validators.DataRequired()], ) @@ -890,7 +890,7 @@ class AddReportForm(PagureForm): """ report_name = wtforms.TextAreaField( - 'Report name*', + 'Report name', [wtforms.validators.DataRequired()], ) @@ -900,12 +900,12 @@ class PublicNotificationForm(PagureForm): """ issue_notifs = wtforms.TextAreaField( - 'Public issue notification*', + 'Public issue notification', [wtforms.validators.optional(), MultipleEmail()], ) pr_notifs = wtforms.TextAreaField( - 'Public PR notification*', + 'Public PR notification', [wtforms.validators.optional(), MultipleEmail()], ) @@ -953,7 +953,7 @@ class AddGitTagForm(PagureForm): """ Form to create a new git tag. """ tagname = wtforms.StringField( - 'Name of the tag*', + 'Name of the tag', [wtforms.validators.DataRequired()], ) commit_hash = wtforms.StringField( diff --git a/pagure/login_forms.py b/pagure/login_forms.py index 2cd8d5c..53dcfce 100644 --- a/pagure/login_forms.py +++ b/pagure/login_forms.py @@ -43,7 +43,7 @@ class LostPasswordForm(FlaskForm): """ Form to ask for a password change. """ username = wtforms.StringField( - 'username *', + 'username', [wtforms.validators.DataRequired()], ) @@ -52,11 +52,11 @@ class ResetPasswordForm(FlaskForm): """ Form to reset one's password in the local database. """ password = wtforms.PasswordField( - 'Password *', + 'Password', [wtforms.validators.DataRequired()], ) confirm_password = wtforms.PasswordField( - 'Confirm password *', + 'Confirm password', [wtforms.validators.DataRequired(), same_password], ) @@ -65,11 +65,11 @@ class LoginForm(FlaskForm): """ Form to login via the local database. """ username = wtforms.StringField( - 'username *', + 'username', [wtforms.validators.DataRequired()], ) password = wtforms.PasswordField( - 'Password *', + 'Password', [wtforms.validators.DataRequired()], ) @@ -78,22 +78,22 @@ class NewUserForm(FlaskForm): """ Form to add a new user to the local database. """ user = wtforms.StringField( - 'username *', + 'username', [wtforms.validators.DataRequired()], ) fullname = wtforms.StringField( "Full name", [wtforms.validators.Optional()] ) email_address = wtforms.StringField( - 'Email address *', + 'Email address', [wtforms.validators.DataRequired(), wtforms.validators.Email()], ) password = wtforms.PasswordField( - 'Password *', + 'Password', [wtforms.validators.DataRequired()], ) confirm_password = wtforms.PasswordField( - 'Confirm password *', + 'Confirm password', [wtforms.validators.DataRequired(), same_password], ) @@ -102,14 +102,14 @@ class ChangePasswordForm(FlaskForm): """ Form to reset one's password in the local database. """ old_password = wtforms.PasswordField( - 'Old Password *', + 'Old Password', [wtforms.validators.DataRequired()], ) password = wtforms.PasswordField( - 'Password *', + 'Password', [wtforms.validators.DataRequired()], ) confirm_password = wtforms.PasswordField( - 'Confirm password *', + 'Confirm password', [wtforms.validators.DataRequired(), same_password], ) diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index 714211d..67edd26 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -31,7 +31,7 @@ {% endif %} {% else %}
- {{ field.label }} + {{ field.label }} {% if field.errors %} * {% endif %} {% if rightlink %}
{{rightlink['text']}} {% endif %} From beb15747a5e5bb73a4fb9956358ed7b45ebdc86d Mon Sep 17 00:00:00 2001 From: Koichi MATSUMOTO Date: Oct 09 2020 14:32:46 +0000 Subject: [PATCH 3/4] fix AssertionError --- diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index cc2f8a4..b0fb0d6 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -2645,7 +2645,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): output_text = output.get_data(as_text=True) self.assertIn( '", + " ", output_text, ) @@ -2683,7 +2683,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): output_text = output.get_data(as_text=True) self.assertNotIn( '", + " ", output_text, ) diff --git a/tests/test_pagure_flask_ui_groups.py b/tests/test_pagure_flask_ui_groups.py index f73845f..d1b18a1 100644 --- a/tests/test_pagure_flask_ui_groups.py +++ b/tests/test_pagure_flask_ui_groups.py @@ -197,7 +197,7 @@ class PagureFlaskGroupstests(tests.Modeltests): ) self.assertIn( '", + " ", output.get_data(as_text=True), ) @@ -228,7 +228,7 @@ class PagureFlaskGroupstests(tests.Modeltests): ) self.assertIn( '", + " ", output.get_data(as_text=True), ) From 8d92660978258bef882bb3d605abf5d61cfd761a Mon Sep 17 00:00:00 2001 From: Koichi MATSUMOTO Date: Oct 09 2020 14:33:53 +0000 Subject: [PATCH 4/4] Merge branch 'master' of ssh://pagure.io/forks/mzch/pagure into master --- diff --git a/pagure/api/issue.py b/pagure/api/issue.py index 898c12e..6025117 100644 --- a/pagure/api/issue.py +++ b/pagure/api/issue.py @@ -1593,7 +1593,7 @@ def api_view_issues_history_detailed_stats( weeks_range = flask.request.args.get("weeks_range") or 53 try: weeks_range = int(weeks_range) - except: + except Exception: weeks_range = 53 repo = _get_repo(repo, username, namespace) diff --git a/pagure/hooks/mail.py b/pagure/hooks/mail.py index 989990b..bbb899e 100644 --- a/pagure/hooks/mail.py +++ b/pagure/hooks/mail.py @@ -128,7 +128,7 @@ class MailRunner(BaseRunner): proc = subprocess.Popen( [hook_file], cwd=repodir, stdin=subprocess.PIPE ) - proc.communicate(stdin) + proc.communicate(stdin.encode()) ecode = proc.wait() if ecode != 0: print("git_multimail failed")