|
Pierre-Yves Chibon |
33b534 |
# -*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
ab2f8f |
|
|
Pierre-Yves Chibon |
ab2f8f |
"""
|
|
Pierre-Yves Chibon |
ab2f8f |
(c) 2014 - 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 |
ab2f8f |
from flask.ext import wtf
|
|
Pierre-Yves Chibon |
ab2f8f |
import wtforms
|
|
Pierre-Yves Chibon |
ab2f8f |
|
|
Pierre-Yves Chibon |
ab2f8f |
|
|
Pierre-Yves Chibon |
ab2f8f |
class ProjectForm(wtf.Form):
|
|
Pierre-Yves Chibon |
ab2f8f |
''' Form to create or edit project. '''
|
|
Pierre-Yves Chibon |
ab2f8f |
name = wtforms.TextField(
|
|
Pierre-Yves Chibon |
ab2f8f |
'Project name *',
|
|
Pierre-Yves Chibon |
ab2f8f |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
ab2f8f |
)
|
|
Pierre-Yves Chibon |
ab2f8f |
description = wtforms.TextField(
|
|
Pierre-Yves Chibon |
ab2f8f |
'description',
|
|
Pierre-Yves Chibon |
ab2f8f |
[wtforms.validators.optional()]
|
|
Pierre-Yves Chibon |
ab2f8f |
)
|
|
Pierre-Yves Chibon |
a9bfbe |
|
|
Pierre-Yves Chibon |
a9bfbe |
|
|
Pierre-Yves Chibon |
a9bfbe |
class IssueForm(wtf.Form):
|
|
Pierre-Yves Chibon |
a9bfbe |
''' Form to create or edit an issue. '''
|
|
Pierre-Yves Chibon |
a9bfbe |
title = wtforms.TextField(
|
|
Pierre-Yves Chibon |
a9bfbe |
'Title*',
|
|
Pierre-Yves Chibon |
a9bfbe |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
a9bfbe |
)
|
|
Pierre-Yves Chibon |
c5a9a2 |
issue_content = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
a9bfbe |
'Content*',
|
|
Pierre-Yves Chibon |
a9bfbe |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
a9bfbe |
)
|
|
Pierre-Yves Chibon |
01dc5b |
status = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
01dc5b |
'Status',
|
|
Pierre-Yves Chibon |
01dc5b |
[wtforms.validators.Required()],
|
|
Pierre-Yves Chibon |
01dc5b |
choices=[(item, item) for item in []]
|
|
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 |
01dc5b |
if 'status' in kwargs:
|
|
Pierre-Yves Chibon |
01dc5b |
self.status.choices = [
|
|
Pierre-Yves Chibon |
01dc5b |
(status, status) for status in kwargs['status']
|
|
Pierre-Yves Chibon |
01dc5b |
]
|
|
Pierre-Yves Chibon |
e926d1 |
|
|
Pierre-Yves Chibon |
e926d1 |
|
|
Pierre-Yves Chibon |
e926d1 |
class RequestPullForm(wtf.Form):
|
|
Pierre-Yves Chibon |
e926d1 |
''' Form to create a request pull. '''
|
|
Pierre-Yves Chibon |
e926d1 |
title = wtforms.TextField(
|
|
Pierre-Yves Chibon |
e926d1 |
'Title*',
|
|
Pierre-Yves Chibon |
e926d1 |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
e926d1 |
)
|
|
Pierre-Yves Chibon |
9c3c1a |
|
|
Pierre-Yves Chibon |
9c3c1a |
|
|
Pierre-Yves Chibon |
66950b |
class AddIssueCommentForm(wtf.Form):
|
|
Pierre-Yves Chibon |
66950b |
''' Form to add a comment to an issue. '''
|
|
Pierre-Yves Chibon |
462740 |
comment = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
66950b |
'Comment*',
|
|
Pierre-Yves Chibon |
66950b |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
66950b |
)
|
|
Pierre-Yves Chibon |
66950b |
|
|
Pierre-Yves Chibon |
66950b |
|
|
Pierre-Yves Chibon |
c5541c |
class AddIssueTagForm(wtf.Form):
|
|
Pierre-Yves Chibon |
c5541c |
''' Form to add a tag to an issue. '''
|
|
Pierre-Yves Chibon |
c5541c |
tag = wtforms.TextField(
|
|
Pierre-Yves Chibon |
c5541c |
'tag*',
|
|
Pierre-Yves Chibon |
c5541c |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
c5541c |
)
|
|
Pierre-Yves Chibon |
c5541c |
|
|
Pierre-Yves Chibon |
c5541c |
|
|
Pierre-Yves Chibon |
8890e1 |
class AddIssueDependencyForm(wtf.Form):
|
|
Pierre-Yves Chibon |
8890e1 |
''' Form to add a blocked issue to an issue. '''
|
|
Pierre-Yves Chibon |
8890e1 |
depends = wtforms.TextField(
|
|
Pierre-Yves Chibon |
8890e1 |
'dependency issue*',
|
|
Pierre-Yves Chibon |
8890e1 |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
8890e1 |
)
|
|
Pierre-Yves Chibon |
8890e1 |
|
|
Pierre-Yves Chibon |
8890e1 |
|
|
Pierre-Yves Chibon |
247d01 |
class AddPullRequestCommentForm(wtf.Form):
|
|
Pierre-Yves Chibon |
247d01 |
''' Form to add a comment to a pull-request. '''
|
|
Pierre-Yves Chibon |
247d01 |
commit = wtforms.HiddenField('commit identifier')
|
|
Pierre-Yves Chibon |
e55bf8 |
filename = wtforms.HiddenField('file changed')
|
|
Pierre-Yves Chibon |
247d01 |
row = wtforms.HiddenField('row')
|
|
Pierre-Yves Chibon |
247d01 |
requestid = wtforms.HiddenField('requestid')
|
|
Pierre-Yves Chibon |
247d01 |
comment = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
247d01 |
'Comment*',
|
|
Pierre-Yves Chibon |
247d01 |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
247d01 |
)
|
|
Pierre-Yves Chibon |
247d01 |
|
|
Pierre-Yves Chibon |
247d01 |
|
|
Pierre-Yves Chibon |
9c3c1a |
class UpdateIssueStatusForm(wtf.Form):
|
|
Pierre-Yves Chibon |
9c3c1a |
''' Form to update the status of an issue. '''
|
|
Pierre-Yves Chibon |
9c3c1a |
status = wtforms.SelectField(
|
|
Pierre-Yves Chibon |
9c3c1a |
'Status',
|
|
Pierre-Yves Chibon |
9c3c1a |
[wtforms.validators.Required()],
|
|
Pierre-Yves Chibon |
9c3c1a |
choices=[(item, item) for item in []]
|
|
Pierre-Yves Chibon |
9c3c1a |
)
|
|
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 |
9c3c1a |
super(UpdateIssueStatusForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
9c3c1a |
if 'status' in kwargs:
|
|
Pierre-Yves Chibon |
9c3c1a |
self.status.choices = [
|
|
Pierre-Yves Chibon |
9c3c1a |
(status, status) for status in kwargs['status']
|
|
Pierre-Yves Chibon |
9c3c1a |
]
|
|
Pierre-Yves Chibon |
ec0500 |
|
|
Pierre-Yves Chibon |
ec0500 |
|
|
Pierre-Yves Chibon |
ec0500 |
class ProjectSettingsForm(wtf.Form):
|
|
Pierre-Yves Chibon |
ec0500 |
''' Form to update the settings of a project. '''
|
|
Pierre-Yves Chibon |
ec0500 |
issue_tracker = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
ec0500 |
'Activate issue tracker',
|
|
Pierre-Yves Chibon |
ec0500 |
[wtforms.validators.optional()],
|
|
Pierre-Yves Chibon |
ec0500 |
)
|
|
Pierre-Yves Chibon |
ec0500 |
project_docs = wtforms.BooleanField(
|
|
Pierre-Yves Chibon |
ec0500 |
'Activate project documentation',
|
|
Pierre-Yves Chibon |
ec0500 |
[wtforms.validators.optional()],
|
|
Pierre-Yves Chibon |
ec0500 |
)
|
|
Pierre-Yves Chibon |
ec0500 |
|
|
Pierre-Yves Chibon |
ec0500 |
def __init__(self, *args, **kwargs):
|
|
Pierre-Yves Chibon |
ec0500 |
""" Calls the default constructor with the normal argument but
|
|
Pierre-Yves Chibon |
ec0500 |
uses the list of collection provided to fill the choices of the
|
|
Pierre-Yves Chibon |
ec0500 |
drop-down list.
|
|
Pierre-Yves Chibon |
ec0500 |
"""
|
|
Pierre-Yves Chibon |
ec0500 |
super(ProjectSettingsForm, self).__init__(*args, **kwargs)
|
|
Pierre-Yves Chibon |
ec0500 |
if 'project' in kwargs:
|
|
Pierre-Yves Chibon |
ec0500 |
self.issue_tracker.data = kwargs['project'].issue_tracker
|
|
Pierre-Yves Chibon |
ec0500 |
self.project_docs.data = kwargs['project'].project_docs
|
|
Pierre-Yves Chibon |
7d80f3 |
|
|
Pierre-Yves Chibon |
7d80f3 |
|
|
Pierre-Yves Chibon |
7d80f3 |
class UserSettingsForm(wtf.Form):
|
|
Pierre-Yves Chibon |
7d80f3 |
''' Form to create or edit project. '''
|
|
Pierre-Yves Chibon |
7d80f3 |
ssh_key = wtforms.TextAreaField(
|
|
Pierre-Yves Chibon |
7d80f3 |
'Public ssh key *',
|
|
Pierre-Yves Chibon |
7d80f3 |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
7d80f3 |
)
|
|
Pierre-Yves Chibon |
6350bb |
|
|
Pierre-Yves Chibon |
6350bb |
|
|
Pierre-Yves Chibon |
6350bb |
class AddUserForm(wtf.Form):
|
|
Pierre-Yves Chibon |
6350bb |
''' Form to add a user to a project. '''
|
|
Pierre-Yves Chibon |
6350bb |
user = wtforms.TextField(
|
|
Pierre-Yves Chibon |
6350bb |
'Username *',
|
|
Pierre-Yves Chibon |
6350bb |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
6350bb |
)
|
|
Pierre-Yves Chibon |
443aa9 |
|
|
Pierre-Yves Chibon |
443aa9 |
|
|
Pierre-Yves Chibon |
443aa9 |
class DescriptionForm(wtf.Form):
|
|
Pierre-Yves Chibon |
443aa9 |
''' Form to edit the description of a project. '''
|
|
Pierre-Yves Chibon |
443aa9 |
description = wtforms.TextField(
|
|
Pierre-Yves Chibon |
443aa9 |
'description *',
|
|
Pierre-Yves Chibon |
443aa9 |
[wtforms.validators.Required()]
|
|
Pierre-Yves Chibon |
443aa9 |
)
|
|
Pierre-Yves Chibon |
5a9800 |
|
|
Pierre-Yves Chibon |
5a9800 |
class ConfirmationForm(wtf.Form):
|
|
Pierre-Yves Chibon |
5a9800 |
pass
|