diff --git a/pagure/forms.py b/pagure/forms.py
index bc1e742..0474d84 100644
--- a/pagure/forms.py
+++ b/pagure/forms.py
@@ -131,7 +131,7 @@ class ProjectFormSimplified(PagureForm):
description = wtforms.StringField(
'Description *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
url = wtforms.StringField(
"URL",
@@ -197,7 +197,7 @@ class ProjectForm(ProjectFormSimplified):
"PROJECT_NAME_REGEX", "^[a-zA-z0-9_][a-zA-Z0-9-_]*$"
)
self.name.validators = [
- wtforms.validators.Required(),
+ wtforms.validators.DataRequired(),
wtforms.validators.Regexp(regex, flags=re.IGNORECASE),
]
# Set the list of namespace
@@ -228,10 +228,12 @@ class IssueFormSimplied(PagureForm):
""" Form to create or edit an issue. """
title = wtforms.StringField(
- 'Title*', [wtforms.validators.Required()]
+ 'Title*',
+ [wtforms.validators.DataRequired()],
)
issue_content = wtforms.TextAreaField(
- 'Content*', [wtforms.validators.Required()]
+ 'Content*',
+ [wtforms.validators.DataRequired()],
)
private = wtforms.BooleanField(
"Private", [wtforms.validators.optional()], false_values=FALSE_VALUES
@@ -272,7 +274,7 @@ class IssueForm(IssueFormSimplied):
""" Form to create or edit an issue. """
status = wtforms.SelectField(
- "Status", [wtforms.validators.Required()], choices=[]
+ "Status", [wtforms.validators.DataRequired()], choices=[]
)
def __init__(self, *args, **kwargs):
@@ -291,7 +293,8 @@ class RequestPullForm(PagureForm):
""" Form to create a pull request. """
title = wtforms.StringField(
- 'Title*', [wtforms.validators.Required()]
+ 'Title*',
+ [wtforms.validators.DataRequired()],
)
initial_comment = wtforms.TextAreaField(
"Initial Comment", [wtforms.validators.Optional()]
@@ -304,17 +307,17 @@ class RemoteRequestPullForm(RequestPullForm):
git_repo = wtforms.StringField(
'Git repo address*',
[
- wtforms.validators.Required(),
+ wtforms.validators.DataRequired(),
wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE),
],
)
branch_from = wtforms.StringField(
'Git branch*',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
branch_to = wtforms.StringField(
'Git branch to merge in*',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
@@ -338,7 +341,7 @@ class AddIssueTagForm(DeleteIssueTagForm):
"Tag Description", [wtforms.validators.Optional()]
)
tag_color = wtforms.StringField(
- "Tag Color", [wtforms.validators.Required()]
+ "Tag Color", [wtforms.validators.DataRequired()]
)
@@ -346,7 +349,7 @@ class StatusForm(PagureForm):
""" Form to add/change the status of an issue. """
status = wtforms.SelectField(
- "Status", [wtforms.validators.Required()], choices=[]
+ "Status", [wtforms.validators.DataRequired()], choices=[]
)
close_status = wtforms.SelectField(
"Closed as", [wtforms.validators.Optional()], choices=[]
@@ -399,7 +402,7 @@ class NewTokenForm(PagureForm):
"description", [wtforms.validators.Optional()]
)
acls = wtforms.SelectMultipleField(
- "ACLs", [wtforms.validators.Required()], choices=[]
+ "ACLs", [wtforms.validators.DataRequired()], choices=[]
)
def __init__(self, *args, **kwargs):
@@ -495,22 +498,27 @@ class AddPullRequestCommentForm(PagureForm):
requestid = wtforms.HiddenField("requestid")
tree_id = wtforms.HiddenField("treeid")
comment = wtforms.TextAreaField(
- 'Comment*', [wtforms.validators.Required()]
+ 'Comment*',
+ [wtforms.validators.DataRequired()],
)
class AddPullRequestFlagFormV1(PagureForm):
""" Form to add a flag to a pull-request or commit. """
- username = wtforms.StringField("Username", [wtforms.validators.Required()])
+ username = wtforms.StringField(
+ "Username", [wtforms.validators.DataRequired()]
+ )
percent = wtforms.StringField(
"Percentage of completion", [wtforms.validators.optional()]
)
- comment = wtforms.TextAreaField("Comment", [wtforms.validators.Required()])
+ comment = wtforms.TextAreaField(
+ "Comment", [wtforms.validators.DataRequired()]
+ )
url = wtforms.StringField(
"URL",
[
- wtforms.validators.Required(),
+ wtforms.validators.DataRequired(),
wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE),
],
)
@@ -533,7 +541,7 @@ class AddPullRequestFlagForm(AddPullRequestFlagFormV1):
)
status = wtforms.SelectField(
- "status", [wtforms.validators.Required()], choices=[]
+ "status", [wtforms.validators.DataRequired()], choices=[]
)
@@ -542,7 +550,7 @@ class AddSSHKeyForm(PagureForm):
ssh_key = wtforms.StringField(
'SSH Key *',
- [wtforms.validators.Required()]
+ [wtforms.validators.DataRequired()]
# TODO: Add an ssh key validator?
)
@@ -562,11 +570,11 @@ class AddUserForm(PagureForm):
user = wtforms.StringField(
'Username *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
access = wtforms.StringField(
'Access Level *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
@@ -575,7 +583,7 @@ class AddUserToGroupForm(PagureForm):
user = wtforms.StringField(
'Username *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
@@ -594,13 +602,13 @@ class AddGroupForm(PagureForm):
group = wtforms.StringField(
'Group *',
[
- wtforms.validators.Required(),
+ wtforms.validators.DataRequired(),
wtforms.validators.Regexp(STRICT_REGEX, flags=re.IGNORECASE),
],
)
access = wtforms.StringField(
'Access Level *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
@@ -615,12 +623,12 @@ class ModifyACLForm(PagureForm):
user_type = wtforms.SelectField(
"User type",
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
choices=[("user", "User"), ("group", "Group")],
)
name = wtforms.StringField(
'User- or Groupname *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
acl = wtforms.SelectField(
"ACL type",
@@ -639,14 +647,14 @@ class UploadFileForm(PagureForm):
""" Form to upload a file. """
filestream = wtforms.FileField(
- "File", [wtforms.validators.Required(), file_virus_validator]
+ "File", [wtforms.validators.DataRequired(), file_virus_validator]
)
class UserEmailForm(PagureForm):
""" Form to edit the description of a project. """
- email = wtforms.StringField("email", [wtforms.validators.Required()])
+ email = wtforms.StringField("email", [wtforms.validators.DataRequired()])
def __init__(self, *args, **kwargs):
super(UserEmailForm, self).__init__(*args, **kwargs)
@@ -656,23 +664,25 @@ class UserEmailForm(PagureForm):
wtforms.validators.NoneOf(kwargs["emails"])
)
else:
- self.email.validators = [wtforms.validators.Required()]
+ self.email.validators = [wtforms.validators.DataRequired()]
class ProjectCommentForm(PagureForm):
""" Form to represent project. """
objid = wtforms.StringField(
- "Ticket/Request id", [wtforms.validators.Required()]
+ "Ticket/Request id", [wtforms.validators.DataRequired()]
+ )
+ useremail = wtforms.StringField(
+ "Email", [wtforms.validators.DataRequired()]
)
- useremail = wtforms.StringField("Email", [wtforms.validators.Required()])
class CommentForm(PagureForm):
""" Form to upload a file. """
comment = wtforms.FileField(
- "Comment", [wtforms.validators.Required(), file_virus_validator]
+ "Comment", [wtforms.validators.DataRequired(), file_virus_validator]
)
@@ -681,11 +691,17 @@ class EditGroupForm(PagureForm):
display_name = wtforms.StringField(
"Group name to display",
- [wtforms.validators.Required(), wtforms.validators.Length(max=255)],
+ [
+ wtforms.validators.DataRequired(),
+ wtforms.validators.Length(max=255),
+ ],
)
description = wtforms.StringField(
"Description",
- [wtforms.validators.Required(), wtforms.validators.Length(max=255)],
+ [
+ wtforms.validators.DataRequired(),
+ wtforms.validators.Length(max=255),
+ ],
)
@@ -695,13 +711,13 @@ class NewGroupForm(EditGroupForm):
group_name = wtforms.StringField(
'Group name *',
[
- wtforms.validators.Required(),
+ wtforms.validators.DataRequired(),
wtforms.validators.Length(max=255),
wtforms.validators.Regexp(STRICT_REGEX, flags=re.IGNORECASE),
],
)
group_type = wtforms.SelectField(
- "Group type", [wtforms.validators.Required()], choices=[]
+ "Group type", [wtforms.validators.DataRequired()], choices=[]
)
def __init__(self, *args, **kwargs):
@@ -721,15 +737,15 @@ class EditFileForm(PagureForm):
content = wtforms.TextAreaField("content", [wtforms.validators.Optional()])
commit_title = wtforms.StringField(
- "Title", [wtforms.validators.Required()]
+ "Title", [wtforms.validators.DataRequired()]
)
commit_message = wtforms.TextAreaField(
"Commit message", [wtforms.validators.optional()]
)
email = wtforms.SelectField(
- "Email", [wtforms.validators.Required()], choices=[]
+ "Email", [wtforms.validators.DataRequired()], choices=[]
)
- branch = wtforms.StringField("Branch", [wtforms.validators.Required()])
+ branch = wtforms.StringField("Branch", [wtforms.validators.DataRequired()])
def __init__(self, *args, **kwargs):
""" Calls the default constructor with the normal argument but
@@ -747,7 +763,7 @@ class DefaultBranchForm(PagureForm):
"""Form to change the default branh for a repository"""
branches = wtforms.SelectField(
- "default_branch", [wtforms.validators.Required()], choices=[]
+ "default_branch", [wtforms.validators.DataRequired()], choices=[]
)
def __init__(self, *args, **kwargs):
@@ -786,7 +802,8 @@ class EditCommentForm(PagureForm):
"""
update_comment = wtforms.TextAreaField(
- 'Comment*', [wtforms.validators.Required()]
+ 'Comment*',
+ [wtforms.validators.DataRequired()],
)
@@ -794,7 +811,7 @@ class ForkRepoForm(PagureForm):
""" Form to fork a project in the API. """
repo = wtforms.StringField(
- "The project name", [wtforms.validators.Required()]
+ "The project name", [wtforms.validators.DataRequired()]
)
username = wtforms.StringField(
"User who forked the project", [wtforms.validators.optional()]
@@ -810,7 +827,7 @@ class AddReportForm(PagureForm):
report_name = wtforms.TextAreaField(
'Report name*',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
diff --git a/pagure/hooks/__init__.py b/pagure/hooks/__init__.py
index 027f582..bd417ff 100644
--- a/pagure/hooks/__init__.py
+++ b/pagure/hooks/__init__.py
@@ -26,7 +26,7 @@ from pagure.lib.git_auth import get_git_auth_helper
from pagure.lib.plugins import get_enabled_plugins
-class RequiredIf(wtforms.validators.Required):
+class RequiredIf(wtforms.validators.DataRequired):
""" Wtforms validator setting a field as required if another field
has a value.
"""
diff --git a/pagure/login_forms.py b/pagure/login_forms.py
index 4131ea6..63dab4c 100644
--- a/pagure/login_forms.py
+++ b/pagure/login_forms.py
@@ -44,7 +44,7 @@ class LostPasswordForm(FlaskForm):
username = wtforms.StringField(
'username *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
@@ -53,11 +53,11 @@ class ResetPasswordForm(FlaskForm):
password = wtforms.PasswordField(
'Password *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
confirm_password = wtforms.PasswordField(
'Confirm password *',
- [wtforms.validators.Required(), same_password],
+ [wtforms.validators.DataRequired(), same_password],
)
@@ -66,11 +66,11 @@ class LoginForm(FlaskForm):
username = wtforms.StringField(
'username *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
password = wtforms.PasswordField(
'Password *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
@@ -79,22 +79,22 @@ class NewUserForm(FlaskForm):
user = wtforms.StringField(
'username *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
fullname = wtforms.StringField(
"Full name", [wtforms.validators.Optional()]
)
email_address = wtforms.StringField(
'Email address *',
- [wtforms.validators.Required(), wtforms.validators.Email()],
+ [wtforms.validators.DataRequired(), wtforms.validators.Email()],
)
password = wtforms.PasswordField(
'Password *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
confirm_password = wtforms.PasswordField(
'Confirm password *',
- [wtforms.validators.Required(), same_password],
+ [wtforms.validators.DataRequired(), same_password],
)
@@ -103,13 +103,13 @@ class ChangePasswordForm(FlaskForm):
old_password = wtforms.PasswordField(
'Old Password *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
password = wtforms.PasswordField(
'Password *',
- [wtforms.validators.Required()],
+ [wtforms.validators.DataRequired()],
)
confirm_password = wtforms.PasswordField(
'Confirm password *',
- [wtforms.validators.Required(), same_password],
+ [wtforms.validators.DataRequired(), same_password],
)
diff --git a/tests/test_pagure_flask_ui_remote_pr.py b/tests/test_pagure_flask_ui_remote_pr.py
index 7aaeb22..1bca997 100644
--- a/tests/test_pagure_flask_ui_remote_pr.py
+++ b/tests/test_pagure_flask_ui_remote_pr.py
@@ -211,7 +211,8 @@ class PagureRemotePRtests(tests.Modeltests):
with patch(
'pagure.forms.RemoteRequestPullForm.git_repo.args',
MagicMock(return_value=(
- u'Git Repo address', [wtforms.validators.Required()]))):
+ u'Git Repo address',
+ [wtforms.validators.DataRequired()]))):
data = {
'csrf_token': csrf_token,
'title': 'Remote PR title',
@@ -335,7 +336,8 @@ class PagureRemotePRtests(tests.Modeltests):
with patch(
'pagure.forms.RemoteRequestPullForm.git_repo.args',
MagicMock(return_value=(
- u'Git Repo address', [wtforms.validators.Required()]))):
+ u'Git Repo address',
+ [wtforms.validators.DataRequired()]))):
data = {
'csrf_token': csrf_token,
'title': 'Remote PR title',
@@ -451,7 +453,8 @@ class PagureRemotePRtests(tests.Modeltests):
with patch(
'pagure.forms.RemoteRequestPullForm.git_repo.args',
MagicMock(return_value=(
- u'Git Repo address', [wtforms.validators.Required()]))):
+ u'Git Repo address',
+ [wtforms.validators.DataRequired()]))):
output = self.app.post(
'/test/diff/remote', data=data, follow_redirects=True)
@@ -523,7 +526,8 @@ class PagureRemotePRtests(tests.Modeltests):
with patch(
'pagure.forms.RemoteRequestPullForm.git_repo.args',
MagicMock(return_value=(
- u'Git Repo address', [wtforms.validators.Required()]))):
+ u'Git Repo address',
+ [wtforms.validators.DataRequired()]))):
# Do the preview, triggers the cache & all
output = self.app.post(