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


Talk Python's Mastodon Michael Kennedy's Mastodon