Adding a CMS to Your Pyramid Web App Transcripts
Chapter: The Pages
Lecture: Admin: Listing pages

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Well to work with those pages, we definitely don't want Teoh change some weird fake data thing or even type directly on the database.
0:08 We want to have a rich admin section kind of like we had for redirects, but honestly, much better
0:13 with a proper editor where you can do cool formatting and hot keys.
0:17 And you've got, like, toolbar buttons to help you form at the code and all kinds of good stuff.
0:21 So we're going to create an admin section for pages just like we have for redirects.
0:26 But because we've already done it for redirects, we should be able to blaze through this pretty quick.
0:30 So let's go over here and we're gonna have... First we had redirects. Now we have pages.
0:36 Again make sure. Double Triple Quadruple make sure the admin permission requirement is on there. And this can be pages.
0:43 So we wont to go down here and this should be 'page.list_view_model'. We're gonna get that by making a copy of this one.
0:53 We're going to call it page page_list. And guess what? Instead of request.redirect(pages) and this will be 'all_pages'.
1:02 It should be super similar to the one we have all redirects. We're going to just come down here.
1:09 But our create a list of our not redirects but pages and values.
1:14 And that should pretty much do it for this one, I think, other than it needs the pages list view model. and Pages.
1:25 Here we go. You can import that correctly. Return it and as long as we have this template... We don't have it yet, but we will in a second.
1:36 Add page. Add new page. You don't need a test instead of a test we went to visit and let's look really quick over here at our fake data.
1:49 Have a URL to go visit. So that's what we're going to need here. So we can save visit instead of. This will be url. That looks good.
1:56 Edit. Edit Page doesn't exist yet, but it's going to be Page ID. We can just use the url, I believe, for this one. Eh, we'll keep it at ID.
2:05 It makes life better, and then you just do the title. That might do it. Really there's not a whole lot more going on.
2:18 We've got our admin section into the shared layout. Let's go find out.
2:23 Go to our admin, we have view redirects which, of course, still seems to be working And view page. Fingers crossed.
2:31 No name error redirects. Where is that? Somewhere over here. We have a redirect still. Oh, yeah, There it is. You'll probably noticed it. And I didn't
2:42 So we'll say p in pages. Save that and refresh. We have r, or should I call it p, I could call it r, but that would be wrong.
2:52 dict attribute has no object, no attribute 'id' That is fine. We need to go and put those in here. We did that for the redirects.
3:01 It's going to be easier to change of the url of a page instead of trying to use that. So let's go over here and just put a quick...
3:08 Every one of these has an id that's gonna be one. Be too. And three. Now, we should be in business. Let's give it a shot.
3:21 Tada! There we go and check it out! Here's our company history. Our team and our donate to the PSF and we could visit it.
3:30 That should actually work. Shouldn't it. We could visit our team and visit the donate which of course, is the same as clicking right there. Okay. Edit.
3:39 Probably not gonna be amazing yet, is it? Add new Page?
3:43 No, but we do have this ability to list and see them and even visit the pages, so that's a really good start.

Talk Python's Mastodon Michael Kennedy's Mastodon