From ec050059213a2f4ba516766cf68de2ba4cbc42bb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 30 2014 17:41:50 +0000 Subject: Create a form to edit a project's settings Signed-off-by: Pierre-Yves Chibon --- diff --git a/progit/forms.py b/progit/forms.py index 44b0924..80cc353 100644 --- a/progit/forms.py +++ b/progit/forms.py @@ -86,3 +86,25 @@ class UpdateIssueStatusForm(wtf.Form): self.status.choices = [ (status, status) for status in kwargs['status'] ] + + +class ProjectSettingsForm(wtf.Form): + ''' Form to update the settings of a project. ''' + issue_tracker = wtforms.BooleanField( + 'Activate issue tracker', + [wtforms.validators.optional()], + ) + project_docs = wtforms.BooleanField( + 'Activate project documentation', + [wtforms.validators.optional()], + ) + + def __init__(self, *args, **kwargs): + """ Calls the default constructor with the normal argument but + uses the list of collection provided to fill the choices of the + drop-down list. + """ + super(ProjectSettingsForm, self).__init__(*args, **kwargs) + if 'project' in kwargs: + self.issue_tracker.data = kwargs['project'].issue_tracker + self.project_docs.data = kwargs['project'].project_docs