Getting content publishing/unpublishing hooked up (from the content item list)

- moved publishing control to the Contents module
- included some prep for adding bulk actions and filtering to the content item list
- publish, unpublish and remove actions need downlevel interstitial pages (functionality only workes w/ JS at the moment)

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-07-16 00:49:24 -07:00
parent fd3d722860
commit 7d6b76d7f5
15 changed files with 150 additions and 49 deletions

View File

@@ -5,9 +5,7 @@ using System.Web.Routing;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Common.Models;
using Orchard.Core.Contents.ViewModels;
using Orchard.Core.PublishLater.Models;
using Orchard.Data;
using Orchard.Localization;
using Orchard.Logging;
@@ -179,6 +177,38 @@ namespace Orchard.Core.Contents.Controllers {
return RedirectToAction("List");
}
[HttpPost]
public ActionResult Publish(int id) {
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't publish content")))
return new HttpUnauthorizedResult();
var contentItem = _contentManager.GetLatest(id);
if (contentItem == null)
return new NotFoundResult();
_contentManager.Publish(contentItem);
Services.ContentManager.Flush();
Services.Notifier.Information(T("{0} successfully published.", contentItem.TypeDefinition.DisplayName));
return RedirectToAction("List");
}
[HttpPost]
public ActionResult Unpublish(int id) {
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't unpublish content")))
return new HttpUnauthorizedResult();
var contentItem = _contentManager.GetLatest(id);
if (contentItem == null)
return new NotFoundResult();
_contentManager.Unpublish(contentItem);
Services.ContentManager.Flush();
Services.Notifier.Information(T("{0} successfully unpublished.", contentItem.TypeDefinition.DisplayName));
return RedirectToAction("List");
}
private static void PrepareEditorViewModel(ContentItemViewModel itemViewModel) {
if (string.IsNullOrEmpty(itemViewModel.TemplateName)) {
itemViewModel.TemplateName = "Items/Contents.Item";