From cb05727ec3d10de25d23a7bcf8c108bb6640327a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Sureau?= <fred@milka.(none)>
Date: Tue, 9 Aug 2011 18:28:48 +0200
Subject: [PATCH] We now are able to set the date when adding a bill.

---
 budget/forms.py             | 4 +++-
 budget/templates/forms.html | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/budget/forms.py b/budget/forms.py
index 3327f21..afa86cc 100644
--- a/budget/forms.py
+++ b/budget/forms.py
@@ -1,5 +1,6 @@
 from flaskext.wtf import *
 from models import Project, Person, Bill
+from datetime import datetime
 
 class ProjectForm(Form):
     name = TextField("Project name", validators=[Required()])
@@ -26,6 +27,7 @@ class AuthenticationForm(Form):
 
 
 class BillForm(Form):
+    date = DateField("Date", validators=[Required()], default=datetime.now)
     what = TextField("What?", validators=[Required()])
     payer = SelectField("Payer", validators=[Required()])
     amount = DecimalField("Amount payed", validators=[Required()])
@@ -35,7 +37,7 @@ class BillForm(Form):
 
     def save(self):
         bill = Bill(payer_id=self.payer.data, amount=self.amount.data,
-                what=self.what.data)
+                what=self.what.data, date=self.date.data)
         # set the owers
         for ower in self.payed_for.data:
             bill.owers.append(Person.query.get(ower))
diff --git a/budget/templates/forms.html b/budget/templates/forms.html
index 0fa642d..d462a82 100644
--- a/budget/templates/forms.html
+++ b/budget/templates/forms.html
@@ -40,6 +40,7 @@
 
     {% include "display_errors.html" %}
     {{ form.hidden_tag() }} 
+    {{ input(form.date) }} 
     {{ input(form.what) }} 
     {{ input(form.payer) }} 
     {{ input(form.amount) }}