Added container scoping to the admin content item list

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-07-16 16:37:12 -07:00
parent 416ca95395
commit 95f2eee912
5 changed files with 49 additions and 1 deletions

View File

@@ -7,6 +7,8 @@ using System.Web.Routing;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Models;
using Orchard.Core.Contents.ViewModels;
using Orchard.Data;
using Orchard.Localization;
@@ -43,6 +45,9 @@ namespace Orchard.Core.Contents.Controllers {
public ILogger Logger { get; set; }
public ActionResult List(ListContentsViewModel model) {
if (model.ContainerId != null && _contentManager.GetLatest((int)model.ContainerId) == null)
return new NotFoundResult();
const int pageSize = 20;
var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize;
@@ -59,6 +64,9 @@ namespace Orchard.Core.Contents.Controllers {
query = query.ForType(model.TypeName);
}
if (model.ContainerId != null)
query = query.Join<CommonRecord>().Where(cr => cr.Container.Id == model.ContainerId);
var contentItems = query.Slice(skip, pageSize);
model.Entries = contentItems.Select(BuildEntry).ToList();