Adding a CMS to Your Flask Web App Transcripts
Chapter: Advanced markdown
Lecture: Restricting shared content

Login or purchase this course to watch this video and the rest of the course contents.
0:00 it might look like we're done and yeah, maybe we are right. We can go over here and use this correctly. Our admin section is very helpful,
0:08 but there's still one weird thing. Remember, I go over this, I can actually just go to the site and requested directly.
0:17 That's weird, Isn't it? Also weird that except Spaces. But that's OK. This is probably not what we want, right? We want to be able to request donate,
0:26 but not little sub elements, right? They're not put together in a way that will look like they're supposed to be part
0:31 of our site. They might freak out search engines, all sorts of stuff. So the last thing to do is go over to our
0:36 template engine. And remember, we had this section that didn't make a ton of
0:40 sense at the very beginning, like wiser get marked down and then get marked down for shared content. So you would go over here and say,
0:48 Get Paige and say is shared equals false. And this one we can say is shared is true. They also just passed true or false.
1:00 But I would like to be explosive there. So what? We need to Dio is we need to tell the system that in
1:07 this case I only want you to be ableto show top level pages and down here in this case, I only want you to get shared content that was explicitly set
1:16 for sharing because you don't want to jam one giant page inside of another again. That's weird. Well, it's good in here,
1:22 and add is shared like so and that's a Boolean not say it's false. So let's go to do with this.
1:37 Let's actually hold on to this page object and will stay return page down here so
1:41 we don't forget. But let's go and compare before we allowed to go back, make sure that it's not shared. So we'll say if Page Don is shared.
1:53 Is not equal Teoh whether or not we wanted to be shared. So if it's public, but we wanted to be, I was only for shared or if it's shared,
2:03 what were asking for public will return. None. Eso in the case that the shared state doesn't match, wouldn't say no. No, we don't want this one right.
2:13 That's actually not allowed in this use case, even though it might exist in the database. Otherwise, we're going to give it back if it exists,
2:22 right? This still could return nothing. But, you know, assuming I guess we'd probably be better. Be careful. Make sure that there's a page.
2:30 Ah, if there is a page, we can then do this test. Right? Okay, so this is looking pretty good. I think this might do what we want.
2:40 So let's go and have a look here. So, first of all, can we still get to our pages?
2:47 Like getting help? No. Let's just set a break point here and see what we got wrong. We got a page? Yes. Yes, that's what I was afraid of.
3:05 We have this issue where we already created a bunch of pages over here. And the way seek welcoming works is it doesn't go back and set all the ones
3:15 where we didn't have a value before the migration was added. Do the default value just leaves it as none. So these minuses here mean it's none.
3:24 This unchecked means it's false. And this checked means it's true. We got a couple options. We could just go update the database.
3:31 Or we could just put a test in here. I'll do the test. I suppose I'll say if page and page dot is shared is none hes dot is shared.
3:43 Equals false. Some like that. A little annoying, but it's probably makes more sense to update the database. But that's what I'm gonna dio in this case.
3:56 Now come back, Try HelpAge. Yes. Help works. Donate works over here and be the pages. The our team should work. But we tried to view it.
4:07 I guess I should probably take that button away. We tried to view it Perfect for a four Cannot pay. Find that page. However we go here,
4:15 it can be used in a shared context. So let's go quickly Remove that one little piece of you I Where the admin at a page. Ah, sorry.
4:28 Page list down here. Look at it is gone. Look of the pages. Yes, you can only edit the shared ones because now you cannot be them like you should
4:45 not be able to write. You can't view them in line. I mean, obviously you can still view them like this, right? But you can't view him in line.
4:53 Perfect. I think our richer, nicer, faster, more reusable TMS story for pages using markdown sub templates is done


Talk Python's Mastodon Michael Kennedy's Mastodon