home · contact · privacy
In ledger.py, default new Booking to today.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 16 Oct 2023 22:54:48 +0000 (00:54 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 16 Oct 2023 22:54:48 +0000 (00:54 +0200)
ledger.py

index 640c63afca0a601488ca55fce96a311cec60aa89..0dbc9fe4debe3c133a766d039394d1828a88a600 100755 (executable)
--- a/ledger.py
+++ b/ledger.py
@@ -426,6 +426,7 @@ edit:
         return f'{self.header_add_form("add_free")}<textarea name="booking" rows="8" cols="80">{content}</textarea>{self.footer_add_form(start, end)}'
 
     def add_structured(self, db, start=0, end=0, bonus_lines=10):
+        import datetime
         lines = db.get_lines(start, end) 
         bookings, comments = parse_lines(lines) 
         if len(bookings) > 1:
@@ -436,7 +437,8 @@ edit:
             safe_val = html.escape(str(val))
             return f'<input name="{name}" value="{safe_val}" />'
         if len(bookings) == 0:
-            input_lines += f'{inpu("date")} {inpu("description")} ; {inpu("comment")}<br />' 
+            today = str(datetime.datetime.now())[:10]
+            input_lines += f'{inpu("date", today)} {inpu("description")} ; {inpu("comment")}<br />' 
             last_line = 1 
         else:
             booking = bookings[0]