diff --git a/budget/forms.py b/budget/forms.py index 60d1440e..d363ad58 100644 --- a/budget/forms.py +++ b/budget/forms.py @@ -1,4 +1,5 @@ from flaskext.wtf import * +from models import Project # define forms class CreationForm(Form): @@ -8,6 +9,16 @@ class CreationForm(Form): contact_email = TextField("Email", validators=[Required(), Email()]) submit = SubmitField("Get in") + def save(self): + """Create a new project with the information given by this form. + + Returns the created instance + """ + project = Project(name=self.name.data, id=self.id.data, + password=self.password.data, + contact_email=self.contact_email.data) + return project + class AuthenticationForm(Form): password = TextField("Password", validators=[Required()]) diff --git a/budget/templates/create_project.html b/budget/templates/create_project.html index 524a592c..b26da2de 100644 --- a/budget/templates/create_project.html +++ b/budget/templates/create_project.html @@ -8,7 +8,7 @@