#100DaysOfCode in Python Transcripts
Chapter: Days 85-87: Fullstack web apps made easy
Lecture: All docs

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's go mess with the old documents,
0:02 recall what we had before we had a little filter thing,
0:04 and I'll go ahead and put the text of it up here.
0:09 This isn't going to do anything yet, but we'll have our little
0:11 filter there, and let's put a spacer.
0:13 And then what we need is,
0:14 we want a list of all of the documents.
0:17 How do you do that?
0:18 So far we've set like the text value and so on,
0:20 so what we need for the next thing is actually
0:23 called a linear panel or a repeating panel,
0:26 we'll go for repeating panel.
0:29 Now, there's an item template
0:31 that we've got created right here,
0:32 and I don't like that name, so let me rename this
0:34 to doc_list_item_template.
0:40 If you go down here, we'll see that we have
0:42 the doc_list_item_template, right there, sorry.
0:44 And let's set the name to docs, like that.
0:50 Now, if we actually want to edit that item template,
0:52 we can double click here or just go there,
0:54 we'll double click there and it says
0:56 what items would you like to display?
0:57 Right on the table, how about documents.
1:01 And that means there'll be a little item property
1:03 for each one that comes through here.
1:05 Alright, so within this, how do you want to show it?
1:09 Well, let's go do some more stuff,
1:10 let's set into this thing, we're going to put the title,
1:18 make that bold and go left.
1:22 Put another one right there,
1:31 that's when it's created, and then let's put a link in here,
1:33 so you can click the link to say navigate over and edit it,
1:36 and this is going to be details.
1:47 Alright, make that smaller at that side,
1:49 that created we can make it a little smaller,
1:51 leave some room for the title,
1:53 which is going to be the main thing.
1:55 This is pretty interesting,
1:56 but how do I get the data wired into this?
1:59 Now, we get a little data binding here,
2:01 check that bad boy out right there.
2:03 Self.item of what?
2:04 Well, that is the scheme of our database.
2:08 How cool is that?
2:10 Okay, this should be name,
2:13 and that's looking good. Oops, I don't want this one.
2:15 Self.name and the created,
2:17 we're going to set that up a little bit different,
2:18 but let's just see what we can do to make this work.
2:23 Come into code here,
2:26 go to our utilities, remember it's already loaded the data
2:29 so we shouldn't have to download anything, this is all
2:32 a single paid app, it's amazing.
2:35 So all we have to do is say
2:36 self.repeating_panel.items = utility.docs.
2:42 Let's see if this works.
2:45 Alright, moment of truth, wow,
2:49 it doesn't look like much,
2:50 but that is out of our database right there.
2:52 Super, super cool.
2:54 Let's work on our created date right here.
2:58 Now, if you look over here at the bindings,
2:59 I could try to add a binding,
3:01 and I could have created,
3:03 but I really wanted something like,
3:04 kind of complicated for how I do this,
3:06 like stuff that's happening here.
3:09 So, instead of doing it this way, let's remove that,
3:12 and let's actually go and write
3:13 some code for our doc template.
3:16 Right, so we come over here, and this little item
3:18 thing has been set, actually, I believe it's not set yet.
3:21 We got to be a little careful when the thing is shown,
3:24 or the doc list is shown, then the item has been set,
3:27 so we come down here and say self dot label,
3:31 created dot text, and then we want to use this nice little
3:36 expression here, where we say item.created,
3:39 this is the document, that's it's created field,
3:41 actually, sorry, we got to do it like this.
3:44 Created, and then store format for the friendly
3:48 month, then the day, then the year, let's try that.
3:52 Try all the docs, there you go, March fourth,
3:56 that's today, that's when I created these things.
3:58 Super, super cool, I mean we could make those fonts
4:00 a little bit bigger.
4:01 Last thing is what happens when we click this?
4:03 Right now, nothing.
4:06 So, inside our template,
4:08 when we double click on these details,
4:11 something is going to happen.
4:13 What we want to do is, again tell the home form to navigate
4:17 somewhere, so what we're going to do is we're going to
4:19 write one more function here, kind of like the go_home.
4:35 And we'll tell the home_form to do this thing
4:38 we're calling go_details,
4:39 and what is that?
4:40 Well it's going to show this details form.
4:42 We haven't put that in place yet,
4:43 because it's not a top level navigation item you can do,
4:47 but we'll write it now.
4:53 It's almost the same,
4:58 going to add the doc_details_form.
5:02 Let's pass the doc along,
5:07 and to kind of keep with the pattern
5:08 when you do this binding
5:09 or something is associated with it,
5:11 it's typically item, so I'm going to say item equals this.
5:16 Alright, in our doc_details_form, let's just
5:19 do something like this,
5:20 print self.item name, just to make sure
5:24 that we got the name here, so,
5:29 like that, let's see if the details now work.
5:39 It doesn't, what are we missing?
5:40 Let me check.
5:45 Why didn't it work?
5:46 Well, it doesn't take a genius to figure that
5:49 out does it, look at this, forgot to call it, alright, so let's do our import again.
5:57 Go to details and pass the document that they clicked.
6:02 Remember, the one I clicked was self.item,
6:04 that's the thing that's bound to this particular row
6:07 of our repeating table, so self.item,
6:10 pass that along.
6:14 Click it, what happens?
6:15 Run demo ReadMe,
6:18 oh we didn't pass enough, what's happening here?
6:23 I forgot to put the self parameter.
6:25 Okay, one more time.
6:29 Ready, let's go see the demo ReadMe.
6:32 Boom, we loaded the document demo ReadMe,
6:34 want to try the other, live doc, loaded live doc.
6:37 Yes, it's working.
6:38 So we pretty much have our app all in place,
6:41 the last thing we need to do is sort of replicate this
6:44 view over here on the home,
6:45 as well as filter the documents.
6:47 So what I'm going to do is,
6:48 I'm going to go add a bunch of documents
6:50 so we have things to work with, and then,
6:52 we'll finish out these last two small pieces.