Adding a CMS to Your Flask Web App Transcripts
Chapter: Advanced markdown
Lecture: Add is_shared to the editor

Login or purchase this course to watch this video and the rest of the course contents.
0:00 in the database. We could now market page as shared. But over here, when we go to edit it, where do we indicate that we can't?
0:08 So the next thing to do will be add like a little check box right there So let's start on the H two mouth side and we want that after the
0:15 title in Europe but before the main content. So let's go in at an input. Say the type is check box.
0:23 The i D. It's gonna be is shared and the name will also be is shared. That's cool. And then we also want tohave a label,
0:34 and the label is gonna be four is shared, and we'll just say something like shared. Okay, let's see how that makes it better.
0:45 Well, it sort of worked like that's a check box, and I guess we can check it.
0:49 And the label seems to indicate clicking here on the text also changes that. But why is it so weird like this? Why is it taking up all the space?
0:56 And if I, like, inspect element on it, you'll see. But it's actually taken up the whole with here. That's kind of weird is because over here.
1:05 We've got to see the non gray ones. One applies. We've got inside our admin the form. If it directly contains an element of type input or text area,
1:14 it's going to set the pattern and the with think if we undid that, it would go back to the way we wanted,
1:20 so we could make a really quick and simple change Over here, we can say this section is not immediately contained within the form.
1:28 Remember, this arrow means not just somewhere in the form, but is the next thing in the hierarchy. So we just take this away for a second,
1:39 make a div and the devil be full with with some padding a match. But the stuff in it will just have it sort of natural layout.
1:46 So we just make that quick change. All right, there we go. Now it looks more like we would expect we go back here and then we're to
1:55 load it up with a new one, right? We've got to get it initialized and either show actually,
2:00 whether the pages shared because we're not passing that information along, I'll say, if is shared Well, output checked else? None. Okay,
2:15 sort of annoying that that wraps round. But let's just put it like this. Oh, ah, yeah, And got a close Those off, like so. And if there we go.
2:33 All right, well, let's see how far that got us come back over here Admin page. And yeah,
2:41 that didn't check. If we would just write in reverse will be able to see if it would work. Well, say, if not shared. So what's hold on?
2:51 We don't want to put that they're still left over the other style. I tried. Awesome. So now you can see that if we sort of Hackett
3:02 to be the opposite. So if it's not shared, that with checked. But now the way we really wanted to work is if it's not shared, doesn't check. Beautiful.
3:09 So this works well, however, were not communicating this back to our website. What? I mean, if we go over to our view model here,
3:23 all right, we're not actually passing down whether or not that is shared. So that's gonna be a problems. Will say Self thought is shared equals false.
3:33 So we'll start out by saying No, it's not shared or new pages. If there is a page. Then we want to just go here and say self
3:40 dot page that is shared to copy that over. And then similarly, when we submit the form, we got to do it in reverse.
3:46 So we'll come here. Say is shared but is shared here. Now this is shared. Gets weird, huh? Because of the check boxes.
3:56 Check boxes are weird in HTML for some reason. Does this come back is true or false, like you would totally think it should.
4:03 Is it checked or not? True or false? No, no, no. It doesn't do that, does it? When we write the word checked, does it come back is checked or empty,
4:12 right? Does it come back with that? Nope. What it comes back with is either when its checked it comes back is
4:20 the string on. And if it's not checked of that check pot of that check attribute is not there it comes back is off.
4:28 So what we're gonna do is just going to say if the value is on that me that shared Hey, let's just make sure everything works here.
4:38 You're back in here currently shared. Now, if we I guess we could put a break point here. Probably the only way we're going to see it for this.
4:47 The moment and we go and say this one is shared and we hit it. What? It is shared come back as one quick little step. Our view model is shared is true.
5:05 Perfect. So it looks like it works. Because if we come over here to this request, Dichter we've got is shared is on just like I was telling you.
5:13 Okay, so that works. But we're not telling the database anything about whether or not it shared. So we're gonna have to make sure we get that as well
5:22 in place before this actually works. But at least from the HTML side of things interacting with our site we've got is


Talk Python's Mastodon Michael Kennedy's Mastodon