mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-22 21:02:08 +08:00
Make page and blog post editing experience consistent
When editing/creating a blog post or a page, the "save" button always redirects to the "edit" page, with a notification message at the top stating the new state of the page (draft, published, scheduled for publishing). This makes the experience consistent with Wordpress blog editing, and also fixes a Pri1 bug about a 404 when creating a draft post. This also fixes a bug where "publish later" wasn't working (strings are evil) for either blog of page. --HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045802
This commit is contained in:
@@ -18,13 +18,11 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
private readonly IOrchardServices _services;
|
private readonly IOrchardServices _services;
|
||||||
private readonly IBlogService _blogService;
|
private readonly IBlogService _blogService;
|
||||||
private readonly IBlogPostService _blogPostService;
|
private readonly IBlogPostService _blogPostService;
|
||||||
private readonly ISessionLocator _sessionLocator;
|
|
||||||
|
|
||||||
public BlogPostAdminController(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService, ISessionLocator sessionLocator) {
|
public BlogPostAdminController(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService) {
|
||||||
_services = services;
|
_services = services;
|
||||||
_blogService = blogService;
|
_blogService = blogService;
|
||||||
_blogPostService = blogPostService;
|
_blogPostService = blogPostService;
|
||||||
_sessionLocator = sessionLocator;
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,9 +65,10 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
bool publishNow = false;
|
bool publishNow = false;
|
||||||
if (string.Equals(Request.Form["Command"], "PublishNow")) {
|
if (string.Equals(Request.Form["Command"], "PublishNow")) {
|
||||||
publishNow = true;
|
publishNow = true;
|
||||||
} else if (string.Equals(Request.Form["Publish"], "Publish")) {
|
}
|
||||||
|
else if (string.Equals(Request.Form["Command"], "PublishLater")) {
|
||||||
DateTime publishDateValue;
|
DateTime publishDateValue;
|
||||||
if (DateTime.TryParse(Request.Form["Publish"], out publishDateValue)) {
|
if (DateTime.TryParse(Request.Form["Published"], out publishDateValue)) {
|
||||||
publishDate = publishDateValue;
|
publishDate = publishDateValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,11 +89,14 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
if (publishNow)
|
if (publishNow)
|
||||||
_services.ContentManager.Publish(model.BlogPost.Item.ContentItem);
|
_services.ContentManager.Publish(model.BlogPost.Item.ContentItem);
|
||||||
|
|
||||||
//TEMP: (erikpo) ensure information has committed for this record
|
if (publishNow)
|
||||||
var session = _sessionLocator.For(typeof(ContentItemRecord));
|
_services.Notifier.Information(T("Blog post has been published"));
|
||||||
session.Flush();
|
else if (publishDate != null)
|
||||||
|
_services.Notifier.Information(T("Blog post has been scheduled for publishing"));
|
||||||
|
else
|
||||||
|
_services.Notifier.Information(T("Blog post draft has been saved"));
|
||||||
|
|
||||||
return Redirect(Url.BlogPost(blogSlug, model.BlogPost.Item.As<RoutableAspect>().Slug));
|
return Redirect(Url.BlogPostEdit(blogSlug, model.BlogPost.Item.Id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Edit(string blogSlug, int postId) {
|
public ActionResult Edit(string blogSlug, int postId) {
|
||||||
@@ -124,8 +126,6 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
if (!_services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post")))
|
if (!_services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
bool isDraft = false;
|
|
||||||
|
|
||||||
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
|
||||||
Blog blog = _blogService.Get(blogSlug);
|
Blog blog = _blogService.Get(blogSlug);
|
||||||
|
|
||||||
@@ -142,9 +142,10 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
bool publishNow = false;
|
bool publishNow = false;
|
||||||
if (string.Equals(Request.Form["Command"], "PublishNow")) {
|
if (string.Equals(Request.Form["Command"], "PublishNow")) {
|
||||||
publishNow = true;
|
publishNow = true;
|
||||||
} else if (string.Equals(Request.Form["Publish"], "Publish")) {
|
}
|
||||||
|
else if (string.Equals(Request.Form["Command"], "PublishLater")) {
|
||||||
DateTime publishDateValue;
|
DateTime publishDateValue;
|
||||||
if (DateTime.TryParse(Request.Form["Publish"], out publishDateValue)) {
|
if (DateTime.TryParse(Request.Form["Published"], out publishDateValue)) {
|
||||||
publishDate = publishDateValue;
|
publishDate = publishDateValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +156,6 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
else if (publishDate != null)
|
else if (publishDate != null)
|
||||||
_blogPostService.Publish(post, publishDate.Value);
|
_blogPostService.Publish(post, publishDate.Value);
|
||||||
else {
|
else {
|
||||||
isDraft = true;
|
|
||||||
_blogPostService.Unpublish(post);
|
_blogPostService.Unpublish(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,12 +171,14 @@ namespace Orchard.Blogs.Controllers {
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
_services.Notifier.Information(T("Blog post information updated."));
|
if (publishNow)
|
||||||
|
_services.Notifier.Information(T("Blog post has been published"));
|
||||||
|
else if (publishDate != null)
|
||||||
|
_services.Notifier.Information(T("Blog post has been scheduled for publishing"));
|
||||||
|
else
|
||||||
|
_services.Notifier.Information(T("Blog post draft has been saved"));
|
||||||
|
|
||||||
if (isDraft) {
|
return Redirect(Url.BlogPostEdit(blogSlug, model.BlogPost.Item.Id));
|
||||||
return Redirect(Url.BlogPostEdit(blog.Slug, post.Id));
|
|
||||||
}
|
|
||||||
return Redirect(Url.BlogForAdmin(blog.Slug));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
@@ -121,9 +121,10 @@ namespace Orchard.Pages.Controllers {
|
|||||||
bool publishNow = false;
|
bool publishNow = false;
|
||||||
if (string.Equals(Request.Form["Command"], "PublishNow")) {
|
if (string.Equals(Request.Form["Command"], "PublishNow")) {
|
||||||
publishNow = true;
|
publishNow = true;
|
||||||
} else if (string.Equals(Request.Form["Publish"], "Publish")) {
|
}
|
||||||
|
else if (string.Equals(Request.Form["Command"], "PublishLater")) {
|
||||||
DateTime publishDateValue;
|
DateTime publishDateValue;
|
||||||
if (DateTime.TryParse(Request.Form["Publish"], out publishDateValue)) {
|
if (DateTime.TryParse(Request.Form["Published"], out publishDateValue)) {
|
||||||
publishDate = publishDateValue;
|
publishDate = publishDateValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,7 +140,14 @@ namespace Orchard.Pages.Controllers {
|
|||||||
|
|
||||||
_services.ContentManager.Create(model.Page.Item.ContentItem, publishNow ? VersionOptions.Published : VersionOptions.Draft);
|
_services.ContentManager.Create(model.Page.Item.ContentItem, publishNow ? VersionOptions.Published : VersionOptions.Draft);
|
||||||
|
|
||||||
return RedirectToAction("List");
|
if (publishNow)
|
||||||
|
_services.Notifier.Information(T("Page has been published"));
|
||||||
|
else if (publishDate != null)
|
||||||
|
_services.Notifier.Information(T("Page has been scheduled for publishing"));
|
||||||
|
else
|
||||||
|
_services.Notifier.Information(T("Page draft has been saved"));
|
||||||
|
|
||||||
|
return RedirectToAction("Edit", "Admin", new { id = model.Page.Item.ContentItem.Id });
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Edit(int id) {
|
public ActionResult Edit(int id) {
|
||||||
@@ -173,9 +181,10 @@ namespace Orchard.Pages.Controllers {
|
|||||||
bool publishNow = false;
|
bool publishNow = false;
|
||||||
if (string.Equals(Request.Form["Command"], "PublishNow")) {
|
if (string.Equals(Request.Form["Command"], "PublishNow")) {
|
||||||
publishNow = true;
|
publishNow = true;
|
||||||
} else if (string.Equals(Request.Form["Publish"], "Publish")) {
|
}
|
||||||
|
else if (string.Equals(Request.Form["Command"], "PublishLater")) {
|
||||||
DateTime publishDateValue;
|
DateTime publishDateValue;
|
||||||
if (DateTime.TryParse(Request.Form["Publish"], out publishDateValue)) {
|
if (DateTime.TryParse(Request.Form["Published"], out publishDateValue)) {
|
||||||
publishDate = publishDateValue;
|
publishDate = publishDateValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,9 +209,14 @@ namespace Orchard.Pages.Controllers {
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
_services.Notifier.Information(T("Page information updated."));
|
if (publishNow)
|
||||||
|
_services.Notifier.Information(T("Page has been published"));
|
||||||
|
else if (publishDate != null)
|
||||||
|
_services.Notifier.Information(T("Page has been scheduled for publishing"));
|
||||||
|
else
|
||||||
|
_services.Notifier.Information(T("Page draft has been saved"));
|
||||||
|
|
||||||
return RedirectToAction("List");
|
return RedirectToAction("Edit", "Admin", new { id = model.Page.Item.ContentItem.Id });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
Reference in New Issue
Block a user