|
1 | 1 | import os |
| 2 | +from datetime import datetime |
2 | 3 | from config import db |
3 | 4 | from models import Person, Note |
4 | 5 |
|
|
8 | 9 | "fname": "Doug", |
9 | 10 | "lname": "Farrell", |
10 | 11 | "notes": [ |
11 | | - "Cool, a mini-blogging application!", |
12 | | - "This could be useful", |
13 | | - "Well, sort of useful" |
| 12 | + ("Cool, a mini-blogging application!", "2019-01-06 22:17:54"), |
| 13 | + ("This could be useful", "2019-01-08 22:17:54"), |
| 14 | + ("Well, sort of useful", "2019-03-06 22:17:54"), |
14 | 15 | ] |
15 | 16 | }, |
16 | 17 | { |
17 | 18 | "fname": "Kent", |
18 | 19 | "lname": "Brockman", |
19 | 20 | "notes": [ |
20 | | - "I'm going to make really profound observations", |
21 | | - "Maybe they'll be more obvious than I thought" |
| 21 | + ("I'm going to make really profound observations", "2019-01-07 22:17:54"), |
| 22 | + ("Maybe they'll be more obvious than I thought", "2019-02-06 22:17:54"), |
22 | 23 | ] |
23 | 24 | }, |
24 | 25 | { |
25 | 26 | "fname": "Bunny", |
26 | 27 | "lname": "Easter", |
27 | 28 | "notes": [ |
28 | | - "Has anyone seen my Easter eggs?", |
29 | | - "I'm really late delivering these!" |
| 29 | + ("Has anyone seen my Easter eggs?", "2019-01-07 22:47:54"), |
| 30 | + ("I'm really late delivering these!", "2019-04-06 22:17:54"), |
30 | 31 | ] |
31 | 32 | }, |
32 | 33 | ] |
|
44 | 45 |
|
45 | 46 | # Add the notes for the person |
46 | 47 | for note in person.get("notes"): |
47 | | - p.notes.append(Note(content=note)) |
| 48 | + content, timestamp = note |
| 49 | + p.notes.append(Note(content=content, timestamp=datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S"))) |
48 | 50 | db.session.add(p) |
49 | 51 |
|
50 | 52 | db.session.commit() |
0 commit comments