|
Pierre-Yves Chibon |
33b534 |
# -*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
ab2f8f |
|
|
Pierre-Yves Chibon |
ab2f8f |
"""
|
|
Pierre-Yves Chibon |
362b15 |
(c) 2014-2016 - Copyright Red Hat Inc
|
|
Pierre-Yves Chibon |
ab2f8f |
|
|
Pierre-Yves Chibon |
ab2f8f |
Authors:
|
|
Pierre-Yves Chibon |
ab2f8f |
Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
|
|
Pierre-Yves Chibon |
ab2f8f |
|
|
Pierre-Yves Chibon |
ab2f8f |
"""
|
|
Pierre-Yves Chibon |
ab2f8f |
|
|
Pierre-Yves Chibon |
22a554 |
# pylint: disable=too-few-public-methods
|
|
Pierre-Yves Chibon |
22a554 |
# pylint: disable=no-init
|
|
Pierre-Yves Chibon |
22a554 |
# pylint: disable=super-on-old-class
|
|
Pierre-Yves Chibon |
22a554 |
|
|
Pierre-Yves Chibon |
67d1cc |
from __future__ import unicode_literals, absolute_import
|
|
Aurélien Bompard |
dcf6f6 |
|
|
Pierre-Yves Chibon |
4d16c5 |
import datetime
|
|
Pierre-Yves Chibon |
845e29 |
import re
|
|
Pierre-Yves Chibon |
362b15 |
|
|
Patrick Uiterwijk |
78afb3 |
import flask
|
|
Pierre-Yves Chibon |
362b15 |
import flask_wtf as wtf
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
5a5352 |
try:
|
|
Pierre-Yves Chibon |
2011e2 |
from flask_wtf import FlaskForm
|
|
Pierre-Yves Chibon |
2011e2 |
except ImportError:
|
|
Pierre-Yves Chibon |
5a5352 |
from flask_wtf import Form as FlaskForm
|
|
Pierre-Yves Chibon |
5a5352 |
|
|
Pierre-Yves Chibon |
7aa025 |
import six
|
|
Pierre-Yves Chibon |
ab2f8f |
import wtforms
|
|
Pierre-Yves Chibon |
ab2f8f |
|
|
Pierre-Yves Chibon |
930073 |
import pagure.lib.query
|
|
Lenka Segura |
64cf5d |
import pagure.validators
|
|
Pierre-Yves Chibon |
b130e5 |
from pagure.config import config as pagure_config
|
|
Patrick Uiterwijk |
3f97f6 |
from pagure.utils import urlpattern, is_admin
|
|
Patrick Uiterwijk |
78afb3 |
|
|
Pierre-Yves Chibon |
9c2953 |
STRICT_REGEX = "^[a-zA-Z0-9-_]+$"
|
|
Pierre-Yves Chibon |
dc20f1 |
# This regex is used when creating tags, there we do not want to allow ','
|
|
Pierre-Yves Chibon |
dc20f1 |
# as otherwise it breaks the UI.
|
|
Pierre-Yves Chibon |
4d961f |
TAGS_REGEX = "^[a-zA-Z0-9-_ .:]+$"
|
|
Pierre-Yves Chibon |
dc20f1 |
# In the issue page tags are sent as a comma-separated list, so in order to
|
|
Pierre-Yves Chibon |
dc20f1 |
# allow having multiple tags in an issue, we need to allow ',' in them.
|
|
Pierre-Yves Chibon |
dc20f1 |
TAGS_REGEX_MULTI = "^[a-zA-Z0-9-_, .:]+$"
|
|
Pierre-Yves Chibon |
9c2953 |
FALSE_VALUES = ("false", "", False, "False", 0, "0")
|
|
Pierre-Yves Chibon |
d2002e |
|
|
Pierre-Yves Chibon |
9740ae |
WTF_VERSION = tuple()
|
|
Pierre-Yves Chibon |
9c2953 |
if hasattr(wtf, "__version__"):
|
|
Pierre-Yves Chibon |
9c2953 |
WTF_VERSION = tuple(int(v) for v in wtf.__version__.split("."))
|
|
Pierre-Yves Chibon |
9740ae |
|
|
Pierre-Yves Chibon |
d2002e |
|
|
Pierre-Yves Chibon |
4d16c5 |
class PagureForm(FlaskForm):
|
|
Pierre-Yves Chibon |
4d16c5 |
""" Local form allowing us to form set the time limit. """
|
|
Pierre-Yves Chibon |
4d16c5 |
|
|
Pierre-Yves Chibon |
4d16c5 |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
9c2953 |
delta = pagure_config.get("WTF_CSRF_TIME_LIMIT", 3600)
|
|
Pierre-Yves Chibon |
9740ae |
if delta and WTF_VERSION < (0, 10, 0):
|
|
Pierre-Yves Chibon |
4d16c5 |
self.TIME_LIMIT = datetime.timedelta(seconds=delta)
|
|
Pierre-Yves Chibon |
4d16c5 |
else:
|
|
Pierre-Yves Chibon |
4d16c5 |
self.TIME_LIMIT = delta
|
|
Pierre-Yves Chibon |
9c2953 |
if "csrf_enabled" in kwargs and kwargs["csrf_enabled"] is False:
|
|
Pierre-Yves Chibon |
9c2953 |
kwargs["meta"] = {"csrf": False}
|
|
Pierre-Yves Chibon |
9740ae |
if WTF_VERSION >= (0, 14, 0):
|
|
Pierre-Yves Chibon |
9c2953 |
kwargs.pop("csrf_enabled")
|
|
Pierre-Yves Chibon |
4d16c5 |
super(PagureForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
4d16c5 |
|
|
Pierre-Yves Chibon |
4d16c5 |
|
|
Pierre-Yves Chibon |
7aa025 |
def convert_value(val):
|
|
Pierre-Yves Chibon |
7aa025 |
""" Convert the provided values to strings when possible. """
|
|
Pierre-Yves Chibon |
7aa025 |
if val:
|
|
Aurélien Bompard |
619e2a |
if not isinstance(val, (list, tuple, six.text_type)):
|
|
Pierre-Yves Chibon |
9c2953 |
return val.decode("utf-8")
|
|
Pierre-Yves Chibon |
7aa025 |
elif isinstance(val, six.string_types):
|
|
Pierre-Yves Chibon |
7aa025 |
return val
|
|
Pierre-Yves Chibon |
7aa025 |
|
|
Pierre-Yves Chibon |
7aa025 |
|
|
Pierre-Yves Chibon |
b51901 |
class MultipleEmail(wtforms.validators.Email):
|
|
Pierre-Yves Chibon |
b51901 |
""" Split the value by comma and run them through the email validator
|
|
Pierre-Yves Chibon |
b51901 |
of wtforms.
|
|
Pierre-Yves Chibon |
b51901 |
"""
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
b51901 |
def __call__(self, form, field):
|
|
Pierre-Yves Chibon |
9c2953 |
message = field.gettext("One or more invalid email address.")
|
|
Pierre-Yves Chibon |
9c2953 |
for data in field.data.split(","):
|
|
Pierre-Yves Chibon |
b51901 |
data = data.strip()
|
|
Pierre-Yves Chibon |
9c2953 |
if not self.regex.match(data or ""):
|
|
Pierre-Yves Chibon |
b51901 |
raise wtforms.validators.ValidationError(message)
|
|
Pierre-Yves Chibon |
b51901 |
|
|
Pierre-Yves Chibon |
b51901 |
|
|
Pierre-Yves Chibon |
aeff2b |
def user_namespace_if_private(form, field):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Check if the data in the field is the same as in the password field.
|
|
Pierre-Yves Chibon |
9c2953 |
"""
|
|
Pierre-Yves Chibon |
aeff2b |
if form.private.data:
|
|
Pierre-Yves Chibon |
aeff2b |
field.data = flask.g.fas_user.username
|
|
Pierre-Yves Chibon |
aeff2b |
|
|
Pierre-Yves Chibon |
aeff2b |
|
|
Patrick Uiterwijk |
78afb3 |
def file_virus_validator(form, field):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Checks for virus in the file from flask request object,
|
|
Pierre-Yves Chibon |
9c2953 |
raises wtf.ValidationError if virus is found else None. """
|
|
Arti Laddha |
38f8ff |
|
|
Pierre-Yves Chibon |
9c2953 |
if not pagure_config["VIRUS_SCAN_ATTACHMENTS"]:
|
|
Patrick Uiterwijk |
78afb3 |
return
|
|
Patrick Uiterwijk |
78afb3 |
from pyclamd import ClamdUnixSocket
|
|
Patrick Uiterwijk |
78afb3 |
|
|
Pierre-Yves Chibon |
9c2953 |
if (
|
|
Pierre-Yves Chibon |
9c2953 |
field.name not in flask.request.files
|
|
Pierre-Yves Chibon |
9c2953 |
or flask.request.files[field.name].filename == ""
|
|
Pierre-Yves Chibon |
9c2953 |
):
|
|
Patrick Uiterwijk |
78afb3 |
# If no file was uploaded, this field is correct
|
|
Patrick Uiterwijk |
78afb3 |
return
|
|
Patrick Uiterwijk |
78afb3 |
uploaded = flask.request.files[field.name]
|
|
Patrick Uiterwijk |
78afb3 |
clam = ClamdUnixSocket()
|
|
Patrick Uiterwijk |
78afb3 |
if not clam.ping():
|
|
Pierre-Yves Chibon |
fa85ee |
raise wtforms.ValidationError(
|
|
Pierre-Yves Chibon |
9c2953 |
"Unable to communicate with virus scanner"
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Patrick Uiterwijk |
78afb3 |
results = clam.scan_stream(uploaded.stream.read())
|
|
Patrick Uiterwijk |
78afb3 |
if results is None:
|
|
Patrick Uiterwijk |
78afb3 |
uploaded.stream.seek(0)
|
|
Patrick Uiterwijk |
78afb3 |
return
|
|
Patrick Uiterwijk |
78afb3 |
else:
|
|
Patrick Uiterwijk |
78afb3 |
result = results.values()
|
|
Patrick Uiterwijk |
78afb3 |
res_type, res_msg = result
|
|
Pierre-Yves Chibon |
9c2953 |
if res_type == "FOUND":
|
|
Pierre-Yves Chibon |
9c2953 |
raise wtforms.ValidationError("Virus found: %s" % res_msg)
|
|
Patrick Uiterwijk |
78afb3 |
else:
|
|
Pierre-Yves Chibon |
9c2953 |
raise wtforms.ValidationError("Error scanning uploaded file")
|
|
Patrick Uiterwijk |
78afb3 |
|
|
Patrick Uiterwijk |
78afb3 |
|
|
Patrick Uiterwijk |
f8d590 |
def ssh_key_validator(form, field):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form for ssh key validation """
|
|
Pierre-Yves Chibon |
930073 |
if not pagure.lib.query.are_valid_ssh_keys(field.data):
|
|
Pierre-Yves Chibon |
9c2953 |
raise wtforms.ValidationError("Invalid SSH keys")
|
|
Patrick Uiterwijk |
f8d590 |
|
|
Patrick Uiterwijk |
f8d590 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class ProjectFormSimplified(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to edit the description of a project. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
description = wtforms.StringField(
|
|
Sayan Chowdhury |
35175a |
'Description *',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
6a3964 |
)
|
|
Lenka Segura |
643d50 |
url = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"URL",
|
|
Pierre-Yves Chibon |
e64870 |
[
|
|
Pierre-Yves Chibon |
e64870 |
wtforms.validators.optional(),
|
|
Pierre-Yves Chibon |
e64870 |
wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE),
|
|
Pierre-Yves Chibon |
9c2953 |
],
|
|
Pierre-Yves Chibon |
6a3964 |
)
|
|
Lenka Segura |
643d50 |
avatar_email = wtforms.StringField(
|
|
Lenka Segura |
64cf5d |
"Avatar email",
|
|
Lenka Segura |
64cf5d |
[
|
|
Lenka Segura |
64cf5d |
pagure.validators.EmailValidator("avatar_email must be an email"),
|
|
Lenka Segura |
64cf5d |
wtforms.validators.optional(),
|
|
Lenka Segura |
64cf5d |
],
|
|
Pierre-Yves Chibon |
6a3964 |
)
|
|
Lenka Segura |
643d50 |
tags = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Project tags",
|
|
Pierre-Yves Chibon |
9c2953 |
[wtforms.validators.optional(), wtforms.validators.Length(max=255)],
|
|
Pierre-Yves Chibon |
5d4ee3 |
)
|
|
farhaanbukhsh |
b44e73 |
private = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Private", [wtforms.validators.Optional()], false_values=FALSE_VALUES
|
|
farhaanbukhsh |
b44e73 |
)
|
|
farhaanbukhsh |
b44e73 |
|
|
farhaanbukhsh |
b44e73 |
|
|
Pierre-Yves Chibon |
6a3964 |
class ProjectForm(ProjectFormSimplified):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to create or edit project. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
name = wtforms.StringField('Project name *')
|
|
Pierre-Yves Chibon |
227f4c |
mirrored_from = wtforms.StringField(
|
|
Pierre-Yves Chibon |
227f4c |
"Mirror from URL",
|
|
Pierre-Yves Chibon |
227f4c |
[
|
|
Pierre-Yves Chibon |
227f4c |
wtforms.validators.optional(),
|
|
Pierre-Yves Chibon |
227f4c |
wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE),
|
|
Pierre-Yves Chibon |
227f4c |
],
|
|
Pierre-Yves Chibon |
227f4c |
)
|
|
Ryan Lerch |
743aca |
create_readme = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Create README",
|
|
Ryan Lerch |
743aca |
[wtforms.validators.optional()],
|
|
Pierre-Yves Chibon |
a4a7ab |
false_values=FALSE_VALUES,
|
|
Ryan Lerch |
743aca |
)
|
|
Pierre-Yves Chibon |
a80fe3 |
namespace = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Project Namespace",
|
|
Pierre-Yves Chibon |
aeff2b |
[user_namespace_if_private, wtforms.validators.optional()],
|
|
Pierre-Yves Chibon |
a80fe3 |
choices=[],
|
|
Pierre-Yves Chibon |
9c2953 |
coerce=convert_value,
|
|
Pierre-Yves Chibon |
a80fe3 |
)
|
|
Patrick Uiterwijk |
ac10ea |
ignore_existing_repos = wtforms.BooleanField(
|
|
Patrick Uiterwijk |
ac10ea |
"Ignore existing repositories",
|
|
Patrick Uiterwijk |
ac10ea |
[wtforms.validators.optional()],
|
|
Patrick Uiterwijk |
ac10ea |
false_values=FALSE_VALUES,
|
|
Patrick Uiterwijk |
ac10ea |
)
|
|
Patrick Uiterwijk |
3f97f6 |
repospanner_region = wtforms.SelectField(
|
|
Patrick Uiterwijk |
3f97f6 |
"repoSpanner Region",
|
|
Patrick Uiterwijk |
3f97f6 |
[wtforms.validators.optional()],
|
|
Patrick Uiterwijk |
3f97f6 |
choices=(
|
|
Patrick Uiterwijk |
3f97f6 |
[("none", "Disabled")]
|
|
Patrick Uiterwijk |
3f97f6 |
+ [
|
|
Patrick Uiterwijk |
3f97f6 |
(region, region)
|
|
Patrick Uiterwijk |
3f97f6 |
for region in pagure_config["REPOSPANNER_REGIONS"].keys()
|
|
Patrick Uiterwijk |
3f97f6 |
]
|
|
Patrick Uiterwijk |
3f97f6 |
),
|
|
Patrick Uiterwijk |
3f97f6 |
coerce=convert_value,
|
|
Patrick Uiterwijk |
3f97f6 |
default=pagure_config["REPOSPANNER_NEW_REPO"],
|
|
Patrick Uiterwijk |
3f97f6 |
)
|
|
Pierre-Yves Chibon |
a80fe3 |
|
|
Pierre-Yves Chibon |
a80fe3 |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
a80fe3 |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
a80fe3 |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
a80fe3 |
drop-down list.
|
|
Pierre-Yves Chibon |
a80fe3 |
"""
|
|
Pierre-Yves Chibon |
a80fe3 |
super(ProjectForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
dc53a9 |
# set the name validator
|
|
Pierre-Yves Chibon |
b130e5 |
regex = pagure_config.get(
|
|
Pierre-Yves Chibon |
5e14ea |
"PROJECT_NAME_REGEX", "^[a-zA-z0-9_][a-zA-Z0-9-_.+]*$"
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Pierre-Yves Chibon |
dc53a9 |
self.name.validators = [
|
|
Lenka Segura |
e2e146 |
wtforms.validators.DataRequired(),
|
|
Pierre-Yves Chibon |
9c2953 |
wtforms.validators.Regexp(regex, flags=re.IGNORECASE),
|
|
Pierre-Yves Chibon |
dc53a9 |
]
|
|
Pierre-Yves Chibon |
dc53a9 |
# Set the list of namespace
|
|
Pierre-Yves Chibon |
9c2953 |
if "namespaces" in kwargs:
|
|
Pierre-Yves Chibon |
a80fe3 |
self.namespace.choices = [
|
|
Pierre-Yves Chibon |
9c2953 |
(namespace, namespace) for namespace in kwargs["namespaces"]
|
|
Pierre-Yves Chibon |
a80fe3 |
]
|
|
Pierre-Yves Chibon |
9c2953 |
if not pagure_config.get("USER_NAMESPACE", False):
|
|
Pierre-Yves Chibon |
9c2953 |
self.namespace.choices.insert(0, ("", ""))
|
|
Patrick Uiterwijk |
ac10ea |
|
|
Patrick Uiterwijk |
ac10ea |
if not (
|
|
Patrick Uiterwijk |
ac10ea |
is_admin()
|
|
Patrick Uiterwijk |
ac10ea |
and pagure_config.get("ALLOW_ADMIN_IGNORE_EXISTING_REPOS")
|
|
Patrick Uiterwijk |
9638fb |
) and (
|
|
Patrick Uiterwijk |
9638fb |
flask.g.fas_user.username
|
|
Patrick Uiterwijk |
9638fb |
not in pagure_config["USERS_IGNORE_EXISTING_REPOS"]
|
|
Patrick Uiterwijk |
ac10ea |
):
|
|
Patrick Uiterwijk |
ac10ea |
self.ignore_existing_repos = None
|
|
Patrick Uiterwijk |
ac10ea |
|
|
Patrick Uiterwijk |
3f97f6 |
if not (
|
|
Patrick Uiterwijk |
3f97f6 |
is_admin()
|
|
Patrick Uiterwijk |
3f97f6 |
and pagure_config.get("REPOSPANNER_NEW_REPO_ADMIN_OVERRIDE")
|
|
Patrick Uiterwijk |
3f97f6 |
):
|
|
Patrick Uiterwijk |
3f97f6 |
self.repospanner_region = None
|
|
Pierre-Yves Chibon |
a9bfbe |
|
|
Pierre-Yves Chibon |
a9bfbe |
|
|
Pierre-Yves Chibon |
4d16c5 |
class IssueFormSimplied(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to create or edit an issue. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
title = wtforms.StringField(
|
|
Lenka Segura |
e2e146 |
'Title*',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
b04f7c |
)
|
|
Pierre-Yves Chibon |
b04f7c |
issue_content = wtforms.TextAreaField(
|
|
Lenka Segura |
e2e146 |
'Content*',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
b04f7c |
)
|
|
Pierre-Yves Chibon |
b04f7c |
private = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Private", [wtforms.validators.optional()], false_values=FALSE_VALUES
|
|
Pierre-Yves Chibon |
b04f7c |
)
|
|
Pierre-Yves Chibon |
9ee3a0 |
milestone = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Milestone",
|
|
Mark Reynolds |
fc57b6 |
[wtforms.validators.Optional()],
|
|
Pierre-Yves Chibon |
9ee3a0 |
choices=[],
|
|
Pierre-Yves Chibon |
9c2953 |
coerce=convert_value,
|
|
Pierre-Yves Chibon |
9ee3a0 |
)
|
|
Pierre-Yves Chibon |
9ee3a0 |
priority = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Priority",
|
|
Pierre-Yves Chibon |
9ee3a0 |
[wtforms.validators.Optional()],
|
|
Pierre-Yves Chibon |
9ee3a0 |
choices=[],
|
|
Pierre-Yves Chibon |
9c2953 |
coerce=convert_value,
|
|
Mark Reynolds |
fc57b6 |
)
|
|
Pierre-Yves Chibon |
b04f7c |
|
|
Pierre-Yves Chibon |
9ee3a0 |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
9ee3a0 |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
9ee3a0 |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
9ee3a0 |
drop-down list.
|
|
Pierre-Yves Chibon |
9ee3a0 |
"""
|
|
Pierre-Yves Chibon |
9ee3a0 |
super(IssueFormSimplied, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9ee3a0 |
|
|
Pierre-Yves Chibon |
9ee3a0 |
self.priority.choices = []
|
|
Pierre-Yves Chibon |
9c2953 |
if "priorities" in kwargs:
|
|
Pierre-Yves Chibon |
9c2953 |
for key in sorted(kwargs["priorities"]):
|
|
Pierre-Yves Chibon |
9c2953 |
self.priority.choices.append((key, kwargs["priorities"][key]))
|
|
Pierre-Yves Chibon |
9ee3a0 |
|
|
Pierre-Yves Chibon |
9ee3a0 |
self.milestone.choices = []
|
|
Pierre-Yves Chibon |
9c2953 |
if "milestones" in kwargs and kwargs["milestones"]:
|
|
Pierre-Yves Chibon |
9c2953 |
for key in kwargs["milestones"]:
|
|
Pierre-Yves Chibon |
9ee3a0 |
self.milestone.choices.append((key, key))
|
|
Pierre-Yves Chibon |
9c2953 |
self.milestone.choices.insert(0, ("", ""))
|
|
Pierre-Yves Chibon |
9ee3a0 |
|
|
Pierre-Yves Chibon |
b04f7c |
|
|
Pierre-Yves Chibon |
b04f7c |
class IssueForm(IssueFormSimplied):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to create or edit an issue. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
01dc5b |
status = wtforms.SelectField(
|
|
Lenka Segura |
e2e146 |
"Status", [wtforms.validators.DataRequired()], choices=[]
|
|
Pierre-Yves Chibon |
01dc5b |
)
|
|
Pierre-Yves Chibon |
01dc5b |
|
|
Pierre-Yves Chibon |
01dc5b |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
01dc5b |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
01dc5b |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
01dc5b |
drop-down list.
|
|
Pierre-Yves Chibon |
01dc5b |
"""
|
|
Pierre-Yves Chibon |
01dc5b |
super(IssueForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
if "status" in kwargs:
|
|
Pierre-Yves Chibon |
01dc5b |
self.status.choices = [
|
|
Pierre-Yves Chibon |
9c2953 |
(status, status) for status in kwargs["status"]
|
|
Pierre-Yves Chibon |
01dc5b |
]
|
|
Pierre-Yves Chibon |
e926d1 |
|
|
Pierre-Yves Chibon |
e926d1 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class RequestPullForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to create a pull request. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
title = wtforms.StringField(
|
|
Lenka Segura |
e2e146 |
'Title*',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
e926d1 |
)
|
|
Clement Verna |
9b3fc8 |
initial_comment = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Initial Comment", [wtforms.validators.Optional()]
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Pierre-Yves Chibon |
e180e7 |
allow_rebase = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
e180e7 |
"Allow rebasing",
|
|
Pierre-Yves Chibon |
e180e7 |
[wtforms.validators.Optional()],
|
|
Pierre-Yves Chibon |
e180e7 |
false_values=FALSE_VALUES,
|
|
Pierre-Yves Chibon |
e180e7 |
)
|
|
Pierre-Yves Chibon |
9c3c1a |
|
|
Pierre-Yves Chibon |
9c3c1a |
|
|
Pierre-Yves Chibon |
f70220 |
class RemoteRequestPullForm(RequestPullForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to create a remote pull request. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
git_repo = wtforms.StringField(
|
|
Pierre-Yves Chibon |
608cdb |
'Git repo address*',
|
|
Pierre-Yves Chibon |
9d1740 |
[
|
|
Lenka Segura |
e2e146 |
wtforms.validators.DataRequired(),
|
|
Pierre-Yves Chibon |
9d1740 |
wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE),
|
|
Pierre-Yves Chibon |
9d1740 |
],
|
|
Pierre-Yves Chibon |
608cdb |
)
|
|
Lenka Segura |
643d50 |
branch_from = wtforms.StringField(
|
|
Pierre-Yves Chibon |
608cdb |
'Git branch*',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
608cdb |
)
|
|
Lenka Segura |
643d50 |
branch_to = wtforms.StringField(
|
|
Pierre-Yves Chibon |
608cdb |
'Git branch to merge in*',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
608cdb |
)
|
|
Pierre-Yves Chibon |
608cdb |
|
|
Pierre-Yves Chibon |
608cdb |
|
|
Pierre-Yves Chibon |
2bc953 |
class DeleteIssueTagForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to remove a tag to from a project. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
tag = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Tag",
|
|
Pierre-Yves Chibon |
845e29 |
[
|
|
Pierre-Yves Chibon |
845e29 |
wtforms.validators.Optional(),
|
|
Pierre-Yves Chibon |
8bed68 |
wtforms.validators.Regexp(TAGS_REGEX, flags=re.IGNORECASE),
|
|
Pierre-Yves Chibon |
8bed68 |
wtforms.validators.Length(max=255),
|
|
Pierre-Yves Chibon |
9c2953 |
],
|
|
Pierre-Yves Chibon |
b01b43 |
)
|
|
Pierre-Yves Chibon |
2bc953 |
|
|
Pierre-Yves Chibon |
2bc953 |
|
|
Pierre-Yves Chibon |
2bc953 |
class AddIssueTagForm(DeleteIssueTagForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to add a tag to a project. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
tag_description = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Tag Description", [wtforms.validators.Optional()]
|
|
Mark Reynolds |
403d8f |
)
|
|
Lenka Segura |
643d50 |
tag_color = wtforms.StringField(
|
|
Lenka Segura |
e2e146 |
"Tag Color", [wtforms.validators.DataRequired()]
|
|
Lenka Segura |
643d50 |
)
|
|
Mark Reynolds |
403d8f |
|
|
Pierre-Yves Chibon |
b01b43 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class StatusForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to add/change the status of an issue. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
e9dd60 |
status = wtforms.SelectField(
|
|
Lenka Segura |
e2e146 |
"Status", [wtforms.validators.DataRequired()], choices=[]
|
|
Pierre-Yves Chibon |
e9dd60 |
)
|
|
Pierre-Yves Chibon |
fc0a94 |
close_status = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Closed as", [wtforms.validators.Optional()], choices=[]
|
|
Pierre-Yves Chibon |
fc0a94 |
)
|
|
Pierre-Yves Chibon |
e9dd60 |
|
|
Pierre-Yves Chibon |
e9dd60 |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
e9dd60 |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
e9dd60 |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
e9dd60 |
drop-down list.
|
|
Pierre-Yves Chibon |
e9dd60 |
"""
|
|
Pierre-Yves Chibon |
e9dd60 |
super(StatusForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
if "status" in kwargs:
|
|
Pierre-Yves Chibon |
e9dd60 |
self.status.choices = [
|
|
Pierre-Yves Chibon |
9c2953 |
(status, status) for status in kwargs["status"]
|
|
Pierre-Yves Chibon |
e9dd60 |
]
|
|
Pierre-Yves Chibon |
fc0a94 |
self.close_status.choices = []
|
|
Pierre-Yves Chibon |
9c2953 |
if "close_status" in kwargs:
|
|
Pierre-Yves Chibon |
9c2953 |
for key in sorted(kwargs["close_status"]):
|
|
Pierre-Yves Chibon |
fc0a94 |
self.close_status.choices.append((key, key))
|
|
Pierre-Yves Chibon |
9c2953 |
self.close_status.choices.insert(0, ("", ""))
|
|
Pierre-Yves Chibon |
e9dd60 |
|
|
Pierre-Yves Chibon |
e9dd60 |
|
|
Martin Basti |
14aa9a |
class MilestoneForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to change the milestone of an issue. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Martin Basti |
14aa9a |
milestone = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Milestone",
|
|
Martin Basti |
14aa9a |
[wtforms.validators.Optional()],
|
|
Martin Basti |
14aa9a |
choices=[],
|
|
Pierre-Yves Chibon |
9c2953 |
coerce=convert_value,
|
|
Martin Basti |
14aa9a |
)
|
|
Martin Basti |
14aa9a |
|
|
Martin Basti |
14aa9a |
def __init__(self, *args, **kwargs):
|
|
Martin Basti |
14aa9a |
""" Calls the default constructor with the normal argument but
|
|
Martin Basti |
14aa9a |
uses the list of collection provided to fill the choices of the
|
|
Martin Basti |
14aa9a |
drop-down list.
|
|
Martin Basti |
14aa9a |
"""
|
|
Martin Basti |
14aa9a |
super(MilestoneForm, self).__init__(*args, **kwargs)
|
|
Martin Basti |
14aa9a |
self.milestone.choices = []
|
|
Pierre-Yves Chibon |
9c2953 |
if "milestones" in kwargs and kwargs["milestones"]:
|
|
Pierre-Yves Chibon |
9c2953 |
for key in kwargs["milestones"]:
|
|
Martin Basti |
14aa9a |
self.milestone.choices.append((key, key))
|
|
Pierre-Yves Chibon |
9c2953 |
self.milestone.choices.insert(0, ("", ""))
|
|
Martin Basti |
14aa9a |
|
|
Martin Basti |
14aa9a |
|
|
Pierre-Yves Chibon |
4d16c5 |
class NewTokenForm(PagureForm):
|
|
Fabien Boucher |
53b792 |
""" Form to add a new token. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
description = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"description", [wtforms.validators.Optional()]
|
|
Pierre-Yves Chibon |
60a786 |
)
|
|
Pierre-Yves Chibon |
bd5f16 |
acls = wtforms.SelectMultipleField(
|
|
Lenka Segura |
e2e146 |
"ACLs", [wtforms.validators.DataRequired()], choices=[]
|
|
Pierre-Yves Chibon |
bd5f16 |
)
|
|
Pierre-Yves Chibon |
bd5f16 |
|
|
Pierre-Yves Chibon |
bd5f16 |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
bd5f16 |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
bd5f16 |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
bd5f16 |
drop-down list.
|
|
Pierre-Yves Chibon |
bd5f16 |
"""
|
|
Pierre-Yves Chibon |
bd5f16 |
super(NewTokenForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
if "acls" in kwargs:
|
|
Pierre-Yves Chibon |
bd5f16 |
self.acls.choices = [
|
|
Pierre-Yves Chibon |
9c2953 |
(acl.name, acl.name) for acl in kwargs["acls"]
|
|
Pierre-Yves Chibon |
bd5f16 |
]
|
|
Fabien Boucher |
53b792 |
if "sacls" in kwargs:
|
|
Pierre-Yves Chibon |
3b2728 |
self.acls.choices = [(acl, acl) for acl in kwargs["sacls"]]
|
|
Pierre-Yves Chibon |
bd5f16 |
|
|
Pierre-Yves Chibon |
bd5f16 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class UpdateIssueForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to add a comment to an issue. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
tag = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"tag",
|
|
Pierre-Yves Chibon |
845e29 |
[
|
|
Pierre-Yves Chibon |
845e29 |
wtforms.validators.Optional(),
|
|
Pierre-Yves Chibon |
dc20f1 |
wtforms.validators.Regexp(TAGS_REGEX_MULTI, flags=re.IGNORECASE),
|
|
Pierre-Yves Chibon |
8bed68 |
wtforms.validators.Length(max=255),
|
|
Pierre-Yves Chibon |
9c2953 |
],
|
|
Pierre-Yves Chibon |
c5541c |
)
|
|
Lenka Segura |
643d50 |
depending = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"depending issue", [wtforms.validators.Optional()]
|
|
Pierre-Yves Chibon |
8890e1 |
)
|
|
Lenka Segura |
643d50 |
blocking = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"blocking issue", [wtforms.validators.Optional()]
|
|
Pierre-Yves Chibon |
2ac6a9 |
)
|
|
Pierre-Yves Chibon |
9c2953 |
comment = wtforms.TextAreaField("Comment", [wtforms.validators.Optional()])
|
|
Pierre-Yves Chibon |
2ac6a9 |
assignee = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Assigned to", [wtforms.validators.Optional()]
|
|
Pierre-Yves Chibon |
247d01 |
)
|
|
Pierre-Yves Chibon |
9c3c1a |
status = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Status", [wtforms.validators.Optional()], choices=[]
|
|
Pierre-Yves Chibon |
9c3c1a |
)
|
|
Pierre-Yves Chibon |
d0bcc7 |
priority = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Priority", [wtforms.validators.Optional()], choices=[]
|
|
Pierre-Yves Chibon |
d0bcc7 |
)
|
|
Pierre-Yves Chibon |
a0e287 |
milestone = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Milestone",
|
|
Pierre-Yves Chibon |
a0e287 |
[wtforms.validators.Optional()],
|
|
Pierre-Yves Chibon |
a84bb7 |
choices=[],
|
|
Pierre-Yves Chibon |
9c2953 |
coerce=convert_value,
|
|
Pierre-Yves Chibon |
a0e287 |
)
|
|
Pierre-Yves Chibon |
d9f811 |
private = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Private", [wtforms.validators.optional()], false_values=FALSE_VALUES
|
|
Pierre-Yves Chibon |
d9f811 |
)
|
|
Pierre-Yves Chibon |
05fc3c |
close_status = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Closed as",
|
|
Pierre-Yves Chibon |
05fc3c |
[wtforms.validators.Optional()],
|
|
Pierre-Yves Chibon |
6ea90a |
choices=[],
|
|
Pierre-Yves Chibon |
9c2953 |
coerce=convert_value,
|
|
Pierre-Yves Chibon |
05fc3c |
)
|
|
Pierre-Yves Chibon |
9c3c1a |
|
|
Pierre-Yves Chibon |
9c3c1a |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
9c3c1a |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
9c3c1a |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
9c3c1a |
drop-down list.
|
|
Pierre-Yves Chibon |
9c3c1a |
"""
|
|
Pierre-Yves Chibon |
2ac6a9 |
super(UpdateIssueForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
if "status" in kwargs:
|
|
Pierre-Yves Chibon |
9c3c1a |
self.status.choices = [
|
|
Pierre-Yves Chibon |
9c2953 |
(status, status) for status in kwargs["status"]
|
|
Pierre-Yves Chibon |
9c3c1a |
]
|
|
Pierre-Yves Chibon |
ec0500 |
|
|
Pierre-Yves Chibon |
38d72a |
self.priority.choices = []
|
|
Pierre-Yves Chibon |
9c2953 |
if "priorities" in kwargs:
|
|
Pierre-Yves Chibon |
9c2953 |
for key in sorted(kwargs["priorities"]):
|
|
Pierre-Yves Chibon |
9c2953 |
self.priority.choices.append((key, kwargs["priorities"][key]))
|
|
Pierre-Yves Chibon |
d0bcc7 |
|
|
Pierre-Yves Chibon |
a0e287 |
self.milestone.choices = []
|
|
Pierre-Yves Chibon |
9c2953 |
if "milestones" in kwargs and kwargs["milestones"]:
|
|
Pierre-Yves Chibon |
9c2953 |
for key in kwargs["milestones"]:
|
|
Pierre-Yves Chibon |
a0e287 |
self.milestone.choices.append((key, key))
|
|
Pierre-Yves Chibon |
9c2953 |
self.milestone.choices.insert(0, ("", ""))
|
|
Pierre-Yves Chibon |
a0e287 |
|
|
Pierre-Yves Chibon |
05fc3c |
self.close_status.choices = []
|
|
Pierre-Yves Chibon |
9c2953 |
if "close_status" in kwargs:
|
|
Pierre-Yves Chibon |
9c2953 |
for key in sorted(kwargs["close_status"]):
|
|
Pierre-Yves Chibon |
05fc3c |
self.close_status.choices.append((key, key))
|
|
Pierre-Yves Chibon |
9c2953 |
self.close_status.choices.insert(0, ("", ""))
|
|
Pierre-Yves Chibon |
05fc3c |
|
|
Pierre-Yves Chibon |
ec0500 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class AddPullRequestCommentForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to add a comment to a pull-request. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
9c2953 |
commit = wtforms.HiddenField("commit identifier")
|
|
Pierre-Yves Chibon |
9c2953 |
filename = wtforms.HiddenField("file changed")
|
|
Pierre-Yves Chibon |
9c2953 |
row = wtforms.HiddenField("row")
|
|
Pierre-Yves Chibon |
9c2953 |
requestid = wtforms.HiddenField("requestid")
|
|
Pierre-Yves Chibon |
9c2953 |
tree_id = wtforms.HiddenField("treeid")
|
|
Pierre-Yves Chibon |
2ac6a9 |
comment = wtforms.TextAreaField(
|
|
Lenka Segura |
e2e146 |
'Comment*',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
2ac6a9 |
)
|
|
Pierre-Yves Chibon |
2ac6a9 |
|
|
Pierre-Yves Chibon |
2bbe07 |
|
|
Pierre-Yves Chibon |
abcbf7 |
class AddPullRequestFlagFormV1(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to add a flag to a pull-request or commit. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
e2e146 |
username = wtforms.StringField(
|
|
Lenka Segura |
e2e146 |
"Username", [wtforms.validators.DataRequired()]
|
|
Lenka Segura |
e2e146 |
)
|
|
Lenka Segura |
643d50 |
percent = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Percentage of completion", [wtforms.validators.optional()]
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Lenka Segura |
e2e146 |
comment = wtforms.TextAreaField(
|
|
Lenka Segura |
e2e146 |
"Comment", [wtforms.validators.DataRequired()]
|
|
Lenka Segura |
e2e146 |
)
|
|
Lenka Segura |
643d50 |
url = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"URL",
|
|
Pierre-Yves Chibon |
9c2953 |
[
|
|
Lenka Segura |
e2e146 |
wtforms.validators.DataRequired(),
|
|
Pierre-Yves Chibon |
e64870 |
wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE),
|
|
Pierre-Yves Chibon |
9c2953 |
],
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Lenka Segura |
643d50 |
uid = wtforms.StringField("UID", [wtforms.validators.optional()])
|
|
Pierre-Yves Chibon |
727947 |
|
|
Pierre-Yves Chibon |
2ac6a9 |
|
|
Pierre-Yves Chibon |
abcbf7 |
class AddPullRequestFlagForm(AddPullRequestFlagFormV1):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to add a flag to a pull-request or commit. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Slavek Kabrda |
45252f |
def __init__(self, *args, **kwargs):
|
|
Slavek Kabrda |
45252f |
# we need to instantiate dynamically because the configuration
|
|
Slavek Kabrda |
45252f |
# values may change during tests and we want to always respect
|
|
Slavek Kabrda |
45252f |
# the currently set value
|
|
Slavek Kabrda |
45252f |
super(AddPullRequestFlagForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
self.status.choices = list(
|
|
Pierre-Yves Chibon |
9c2953 |
zip(
|
|
Pierre-Yves Chibon |
9c2953 |
pagure_config["FLAG_STATUSES_LABELS"].keys(),
|
|
Pierre-Yves Chibon |
9c2953 |
pagure_config["FLAG_STATUSES_LABELS"].keys(),
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Slavek Kabrda |
45252f |
|
|
Pierre-Yves Chibon |
abcbf7 |
status = wtforms.SelectField(
|
|
Lenka Segura |
e2e146 |
"status", [wtforms.validators.DataRequired()], choices=[]
|
|
Pierre-Yves Chibon |
abcbf7 |
)
|
|
Pierre-Yves Chibon |
abcbf7 |
|
|
Pierre-Yves Chibon |
abcbf7 |
|
|
Patrick Uiterwijk |
9b237b |
class AddSSHKeyForm(PagureForm):
|
|
Patrick Uiterwijk |
9b237b |
""" Form to add a SSH key to a user. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
ssh_key = wtforms.StringField(
|
|
Patrick Uiterwijk |
9a7915 |
'SSH Key *',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()]
|
|
Patrick Uiterwijk |
9a7915 |
# TODO: Add an ssh key validator?
|
|
Patrick Uiterwijk |
9a7915 |
)
|
|
Patrick Uiterwijk |
9b237b |
|
|
Patrick Uiterwijk |
9b237b |
|
|
Patrick Uiterwijk |
9b237b |
class AddDeployKeyForm(AddSSHKeyForm):
|
|
Patrick Uiterwijk |
9b237b |
""" Form to add a deploy key to a project. """
|
|
Patrick Uiterwijk |
9b237b |
|
|
Patrick Uiterwijk |
9a7915 |
pushaccess = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Push access",
|
|
Patrick Uiterwijk |
9a7915 |
[wtforms.validators.optional()],
|
|
Pierre-Yves Chibon |
a4a7ab |
false_values=FALSE_VALUES,
|
|
Patrick Uiterwijk |
9a7915 |
)
|
|
Patrick Uiterwijk |
9a7915 |
|
|
Patrick Uiterwijk |
9a7915 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class AddUserForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to add a user to a project. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
user = wtforms.StringField(
|
|
Pierre-Yves Chibon |
6350bb |
'Username *',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
6350bb |
)
|
|
Lenka Segura |
643d50 |
access = wtforms.StringField(
|
|
Vivek Anand |
967335 |
'Access Level *',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Vivek Anand |
967335 |
)
|
|
Vivek Anand |
967335 |
|
|
Vivek Anand |
967335 |
|
|
Vivek Anand |
967335 |
class AddUserToGroupForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to add a user to a pagure group. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
user = wtforms.StringField(
|
|
Vivek Anand |
967335 |
'Username *',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Vivek Anand |
967335 |
)
|
|
Pierre-Yves Chibon |
443aa9 |
|
|
Pierre-Yves Chibon |
443aa9 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class AssignIssueForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to assign an user to an issue. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
assignee = wtforms.StringField(
|
|
Pierre-Yves Chibon |
0aaa5e |
'Assignee *',
|
|
Pierre-Yves Chibon |
9c2953 |
[wtforms.validators.Optional()],
|
|
Pierre-Yves Chibon |
0aaa5e |
)
|
|
Pierre-Yves Chibon |
0aaa5e |
|
|
Pierre-Yves Chibon |
b8fd2c |
|
|
Pierre-Yves Chibon |
4d16c5 |
class AddGroupForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to add a group to a project. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
group = wtforms.StringField(
|
|
Pierre-Yves Chibon |
c40b8a |
'Group *',
|
|
Pierre-Yves Chibon |
845e29 |
[
|
|
Lenka Segura |
e2e146 |
wtforms.validators.DataRequired(),
|
|
Pierre-Yves Chibon |
9c2953 |
wtforms.validators.Regexp(STRICT_REGEX, flags=re.IGNORECASE),
|
|
Pierre-Yves Chibon |
9c2953 |
],
|
|
Pierre-Yves Chibon |
c40b8a |
)
|
|
Lenka Segura |
643d50 |
access = wtforms.StringField(
|
|
Vivek Anand |
967335 |
'Access Level *',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Vivek Anand |
967335 |
)
|
|
Pierre-Yves Chibon |
c40b8a |
|
|
Pierre-Yves Chibon |
c40b8a |
|
|
Pierre-Yves Chibon |
4d16c5 |
class ConfirmationForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Simple form used just for CSRF protection. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
5a9800 |
pass
|
|
Pierre-Yves Chibon |
5b8ced |
|
|
Pierre-Yves Chibon |
5b8ced |
|
|
Karsten Hopp |
be01e8 |
class ModifyACLForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to change ACL of a user or a group to a project. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Karsten Hopp |
be01e8 |
user_type = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"User type",
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
9c2953 |
choices=[("user", "User"), ("group", "Group")],
|
|
Karsten Hopp |
be01e8 |
)
|
|
Lenka Segura |
643d50 |
name = wtforms.StringField(
|
|
Karsten Hopp |
be01e8 |
'User- or Groupname *',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Karsten Hopp |
be01e8 |
)
|
|
Karsten Hopp |
be01e8 |
acl = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"ACL type",
|
|
Pierre-Yves Chibon |
6ffde7 |
[wtforms.validators.Optional()],
|
|
Pierre-Yves Chibon |
9c2953 |
choices=[
|
|
Pierre-Yves Chibon |
9c2953 |
("admin", "Admin"),
|
|
Pierre-Yves Chibon |
9c2953 |
("ticket", "Ticket"),
|
|
Pierre-Yves Chibon |
9c2953 |
("commit", "Commit"),
|
|
Pierre-Yves Chibon |
9c2953 |
(None, None),
|
|
Pierre-Yves Chibon |
9c2953 |
],
|
|
Pierre-Yves Chibon |
9c2953 |
coerce=convert_value,
|
|
Karsten Hopp |
be01e8 |
)
|
|
Karsten Hopp |
be01e8 |
|
|
Karsten Hopp |
be01e8 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class UploadFileForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to upload a file. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
5b8ced |
filestream = wtforms.FileField(
|
|
Lenka Segura |
e2e146 |
"File", [wtforms.validators.DataRequired(), file_virus_validator]
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Pierre-Yves Chibon |
f929cb |
|
|
Pierre-Yves Chibon |
f929cb |
|
|
Pierre-Yves Chibon |
4d16c5 |
class UserEmailForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to edit the description of a project. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
e2e146 |
email = wtforms.StringField("email", [wtforms.validators.DataRequired()])
|
|
Pierre-Yves Chibon |
a1f31c |
|
|
Pierre-Yves Chibon |
0aec6f |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
0aec6f |
super(UserEmailForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
if "emails" in kwargs:
|
|
Pierre-Yves Chibon |
9c2953 |
if kwargs["emails"]:
|
|
Pierre-Yves Chibon |
0aec6f |
self.email.validators.append(
|
|
Pierre-Yves Chibon |
9c2953 |
wtforms.validators.NoneOf(kwargs["emails"])
|
|
Pierre-Yves Chibon |
0aec6f |
)
|
|
Pierre-Yves Chibon |
0aec6f |
else:
|
|
Lenka Segura |
e2e146 |
self.email.validators = [wtforms.validators.DataRequired()]
|
|
Ryan Lerch |
7eb66d |
|
|
Pierre-Yves Chibon |
a1f31c |
|
|
Pierre-Yves Chibon |
4d16c5 |
class ProjectCommentForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to represent project. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
objid = wtforms.StringField(
|
|
Lenka Segura |
e2e146 |
"Ticket/Request id", [wtforms.validators.DataRequired()]
|
|
Lenka Segura |
e2e146 |
)
|
|
Lenka Segura |
e2e146 |
useremail = wtforms.StringField(
|
|
Lenka Segura |
e2e146 |
"Email", [wtforms.validators.DataRequired()]
|
|
Pierre-Yves Chibon |
a1f31c |
)
|
|
Pierre-Yves Chibon |
88ad60 |
|
|
Pierre-Yves Chibon |
88ad60 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class CommentForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to upload a file. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
88ad60 |
comment = wtforms.FileField(
|
|
Lenka Segura |
e2e146 |
"Comment", [wtforms.validators.DataRequired(), file_virus_validator]
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Pierre-Yves Chibon |
6daee5 |
|
|
Pierre-Yves Chibon |
6daee5 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class EditGroupForm(PagureForm):
|
|
Pierre-Yves Chibon |
42452c |
""" Form to ask for a password change. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
display_name = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Group name to display",
|
|
Lenka Segura |
e2e146 |
[
|
|
Lenka Segura |
e2e146 |
wtforms.validators.DataRequired(),
|
|
Lenka Segura |
e2e146 |
wtforms.validators.Length(max=255),
|
|
Lenka Segura |
e2e146 |
],
|
|
Pierre-Yves Chibon |
42452c |
)
|
|
Lenka Segura |
643d50 |
description = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Description",
|
|
Lenka Segura |
e2e146 |
[
|
|
Lenka Segura |
e2e146 |
wtforms.validators.DataRequired(),
|
|
Lenka Segura |
e2e146 |
wtforms.validators.Length(max=255),
|
|
Lenka Segura |
e2e146 |
],
|
|
Pierre-Yves Chibon |
42452c |
)
|
|
Pierre-Yves Chibon |
42452c |
|
|
Pierre-Yves Chibon |
42452c |
|
|
Pierre-Yves Chibon |
42452c |
class NewGroupForm(EditGroupForm):
|
|
Pierre-Yves Chibon |
6daee5 |
""" Form to ask for a password change. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
group_name = wtforms.StringField(
|
|
Pierre-Yves Chibon |
6daee5 |
'Group name *',
|
|
Pierre-Yves Chibon |
845e29 |
[
|
|
Lenka Segura |
e2e146 |
wtforms.validators.DataRequired(),
|
|
Pierre-Yves Chibon |
c2701e |
wtforms.validators.Length(max=255),
|
|
Pierre-Yves Chibon |
9c2953 |
wtforms.validators.Regexp(STRICT_REGEX, flags=re.IGNORECASE),
|
|
Pierre-Yves Chibon |
9c2953 |
],
|
|
Pierre-Yves Chibon |
6daee5 |
)
|
|
Pierre-Yves Chibon |
c2a75b |
group_type = wtforms.SelectField(
|
|
Lenka Segura |
e2e146 |
"Group type", [wtforms.validators.DataRequired()], choices=[]
|
|
Pierre-Yves Chibon |
6daee5 |
)
|
|
Pierre-Yves Chibon |
6daee5 |
|
|
Pierre-Yves Chibon |
6daee5 |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
6daee5 |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
6daee5 |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
6daee5 |
drop-down list.
|
|
Pierre-Yves Chibon |
6daee5 |
"""
|
|
Pierre-Yves Chibon |
6daee5 |
super(NewGroupForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
if "group_types" in kwargs:
|
|
Pierre-Yves Chibon |
c2a75b |
self.group_type.choices = [
|
|
Pierre-Yves Chibon |
9c2953 |
(grptype, grptype) for grptype in kwargs["group_types"]
|
|
Pierre-Yves Chibon |
6daee5 |
]
|
|
Pierre-Yves Chibon |
e7472f |
|
|
Pierre-Yves Chibon |
e7472f |
|
|
Pierre-Yves Chibon |
4d16c5 |
class EditFileForm(PagureForm):
|
|
Pierre-Yves Chibon |
e7472f |
""" Form used to edit a file. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
9c2953 |
content = wtforms.TextAreaField("content", [wtforms.validators.Optional()])
|
|
Lenka Segura |
643d50 |
commit_title = wtforms.StringField(
|
|
Lenka Segura |
e2e146 |
"Title", [wtforms.validators.DataRequired()]
|
|
Lenka Segura |
643d50 |
)
|
|
Pierre-Yves Chibon |
e7472f |
commit_message = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Commit message", [wtforms.validators.optional()]
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Pierre-Yves Chibon |
c5cf80 |
email = wtforms.SelectField(
|
|
Lenka Segura |
e2e146 |
"Email", [wtforms.validators.DataRequired()], choices=[]
|
|
Pierre-Yves Chibon |
c5cf80 |
)
|
|
Lenka Segura |
e2e146 |
branch = wtforms.StringField("Branch", [wtforms.validators.DataRequired()])
|
|
Pierre-Yves Chibon |
c5cf80 |
|
|
Pierre-Yves Chibon |
c5cf80 |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
c5cf80 |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
c5cf80 |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
c5cf80 |
drop-down list.
|
|
Pierre-Yves Chibon |
c5cf80 |
"""
|
|
Pierre-Yves Chibon |
c5cf80 |
super(EditFileForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
if "emails" in kwargs:
|
|
Pierre-Yves Chibon |
c5cf80 |
self.email.choices = [
|
|
Pierre-Yves Chibon |
9c2953 |
(email.email, email.email) for email in kwargs["emails"]
|
|
Pierre-Yves Chibon |
c5cf80 |
]
|
|
Ghost-script |
966a39 |
|
|
farhaanbukhsh |
4e1b74 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class DefaultBranchForm(PagureForm):
|
|
Ghost-script |
966a39 |
"""Form to change the default branh for a repository"""
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Ghost-script |
966a39 |
branches = wtforms.SelectField(
|
|
Lenka Segura |
e2e146 |
"default_branch", [wtforms.validators.DataRequired()], choices=[]
|
|
Ghost-script |
966a39 |
)
|
|
Ghost-script |
966a39 |
|
|
Ghost-script |
966a39 |
def __init__(self, *args, **kwargs):
|
|
Ghost-script |
966a39 |
""" Calls the default constructor with the normal argument but
|
|
Ghost-script |
966a39 |
uses the list of collection provided to fill the choices of the
|
|
Ghost-script |
966a39 |
drop-down list.
|
|
Ghost-script |
966a39 |
"""
|
|
Ghost-script |
966a39 |
super(DefaultBranchForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
if "branches" in kwargs:
|
|
Ghost-script |
966a39 |
self.branches.choices = [
|
|
Pierre-Yves Chibon |
9c2953 |
(branch, branch) for branch in kwargs["branches"]
|
|
Ghost-script |
966a39 |
]
|
|
farhaanbukhsh |
a04e02 |
|
|
Pierre-Yves Chibon |
fa85ee |
|
|
Pierre-Yves Chibon |
dff667 |
class DefaultPriorityForm(PagureForm):
|
|
Pierre-Yves Chibon |
dff667 |
"""Form to change the default priority for a repository"""
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
dff667 |
priority = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c2953 |
"default_priority", [wtforms.validators.optional()], choices=[]
|
|
Pierre-Yves Chibon |
dff667 |
)
|
|
Pierre-Yves Chibon |
dff667 |
|
|
Pierre-Yves Chibon |
dff667 |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
dff667 |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
dff667 |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
dff667 |
drop-down list.
|
|
Pierre-Yves Chibon |
dff667 |
"""
|
|
Pierre-Yves Chibon |
dff667 |
super(DefaultPriorityForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c2953 |
if "priorities" in kwargs:
|
|
Pierre-Yves Chibon |
dff667 |
self.priority.choices = [
|
|
Pierre-Yves Chibon |
9c2953 |
(priority, priority) for priority in kwargs["priorities"]
|
|
Pierre-Yves Chibon |
dff667 |
]
|
|
Pierre-Yves Chibon |
dff667 |
|
|
Pierre-Yves Chibon |
dff667 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class EditCommentForm(PagureForm):
|
|
farhaanbukhsh |
a04e02 |
""" Form to verify that comment is not empty
|
|
farhaanbukhsh |
a04e02 |
"""
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
farhaanbukhsh |
a04e02 |
update_comment = wtforms.TextAreaField(
|
|
Lenka Segura |
e2e146 |
'Comment*',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
farhaanbukhsh |
a04e02 |
)
|
|
Pierre-Yves Chibon |
dc21df |
|
|
Pierre-Yves Chibon |
dc21df |
|
|
Pierre-Yves Chibon |
4d16c5 |
class ForkRepoForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to fork a project in the API. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Lenka Segura |
643d50 |
repo = wtforms.StringField(
|
|
Lenka Segura |
e2e146 |
"The project name", [wtforms.validators.DataRequired()]
|
|
Pierre-Yves Chibon |
dc21df |
)
|
|
Lenka Segura |
643d50 |
username = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"User who forked the project", [wtforms.validators.optional()]
|
|
Pierre-Yves Chibon |
9c2953 |
)
|
|
Lenka Segura |
643d50 |
namespace = wtforms.StringField(
|
|
Pierre-Yves Chibon |
9c2953 |
"The project namespace", [wtforms.validators.optional()]
|
|
Pierre-Yves Chibon |
34ece4 |
)
|
|
Pierre-Yves Chibon |
cab0ee |
|
|
Pierre-Yves Chibon |
cab0ee |
|
|
Pierre-Yves Chibon |
4d16c5 |
class AddReportForm(PagureForm):
|
|
Pierre-Yves Chibon |
cab0ee |
""" Form to verify that comment is not empty
|
|
Pierre-Yves Chibon |
cab0ee |
"""
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
cab0ee |
report_name = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
cab0ee |
'Report name*',
|
|
Lenka Segura |
e2e146 |
[wtforms.validators.DataRequired()],
|
|
Pierre-Yves Chibon |
cab0ee |
)
|
|
Pierre-Yves Chibon |
080c15 |
|
|
Pierre-Yves Chibon |
080c15 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class PublicNotificationForm(PagureForm):
|
|
Pierre-Yves Chibon |
080c15 |
""" Form to verify that comment is not empty
|
|
Pierre-Yves Chibon |
080c15 |
"""
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
080c15 |
issue_notifs = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
080c15 |
'Public issue notification*',
|
|
Pierre-Yves Chibon |
9c2953 |
[wtforms.validators.optional(), MultipleEmail()],
|
|
Pierre-Yves Chibon |
080c15 |
)
|
|
Pierre-Yves Chibon |
080c15 |
|
|
Pierre-Yves Chibon |
080c15 |
pr_notifs = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
080c15 |
'Public PR notification*',
|
|
Pierre-Yves Chibon |
9c2953 |
[wtforms.validators.optional(), MultipleEmail()],
|
|
Pierre-Yves Chibon |
080c15 |
)
|
|
Pierre-Yves Chibon |
f0a4f5 |
|
|
Pierre-Yves Chibon |
f0a4f5 |
|
|
Pierre-Yves Chibon |
4d16c5 |
class SubscribtionForm(PagureForm):
|
|
Pierre-Yves Chibon |
9c2953 |
""" Form to subscribe to or unsubscribe from an issue or a PR. """
|
|
Pierre-Yves Chibon |
9c2953 |
|
|
Pierre-Yves Chibon |
f0a4f5 |
status = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Subscription status",
|
|
Pierre-Yves Chibon |
f0a4f5 |
[wtforms.validators.optional()],
|
|
Pierre-Yves Chibon |
a4a7ab |
false_values=FALSE_VALUES,
|
|
Pierre-Yves Chibon |
f0a4f5 |
)
|
|
Lubomír Sedlář |
7c6b11 |
|
|
Lubomír Sedlář |
7c6b11 |
|
|
Lubomír Sedlář |
7c6b11 |
class MergePRForm(PagureForm):
|
|
Lubomír Sedlář |
7c6b11 |
delete_branch = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
9c2953 |
"Delete branch after merging",
|
|
Lubomír Sedlář |
7c6b11 |
[wtforms.validators.optional()],
|
|
Lubomír Sedlář |
7c6b11 |
false_values=FALSE_VALUES,
|
|
Lubomír Sedlář |
7c6b11 |
)
|
|
Slavek Kabrda |
a80d7c |
|
|
Slavek Kabrda |
a80d7c |
|
|
Slavek Kabrda |
a80d7c |
class TriggerCIPRForm(PagureForm):
|
|
Slavek Kabrda |
a80d7c |
def __init__(self, *args, **kwargs):
|
|
Slavek Kabrda |
a80d7c |
# we need to instantiate dynamically because the configuration
|
|
Slavek Kabrda |
a80d7c |
# values may change during tests and we want to always respect
|
|
Slavek Kabrda |
a80d7c |
# the currently set value
|
|
Slavek Kabrda |
a80d7c |
super(TriggerCIPRForm, self).__init__(*args, **kwargs)
|
|
Slavek Kabrda |
a80d7c |
choices = []
|
|
Slavek Kabrda |
a80d7c |
trigger_ci = pagure_config["TRIGGER_CI"]
|
|
Slavek Kabrda |
a80d7c |
if isinstance(trigger_ci, dict):
|
|
Slavek Kabrda |
a80d7c |
# make sure to preserver compatibility with older configs
|
|
Slavek Kabrda |
a80d7c |
# which had TRIGGER_CI as a list
|
|
Slavek Kabrda |
a80d7c |
for comment, meta in trigger_ci.items():
|
|
Slavek Kabrda |
a80d7c |
if meta is not None:
|
|
Slavek Kabrda |
a80d7c |
choices.append((comment, comment))
|
|
Slavek Kabrda |
a80d7c |
self.comment.choices = choices
|
|
Slavek Kabrda |
a80d7c |
|
|
Slavek Kabrda |
a80d7c |
comment = wtforms.SelectField(
|
|
Slavek Kabrda |
a80d7c |
"comment", [wtforms.validators.Required()], choices=[]
|
|
Slavek Kabrda |
a80d7c |
)
|