- Blogs: Fixing publish now button on Blog Details page throws 404 issue, and other inconsistencies related to publish now button visibility and the Draft/publish date information in that view.

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045740
This commit is contained in:
suhacan 2010-01-20 19:50:42 +00:00
parent 90cd0451c8
commit 135ce3d661
3 changed files with 29 additions and 3 deletions

View File

@ -200,6 +200,28 @@ namespace Orchard.Blogs.Controllers {
return Redirect(Url.BlogForAdmin(blogSlug));
}
public ActionResult Publish(string blogSlug, string postSlug) {
if (!_services.Authorizer.Authorize(Permissions.PublishPost, T("Couldn't publish blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
BlogPost post = _blogPostService.Get(blog, postSlug, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();
_blogPostService.Publish(post);
_services.Notifier.Information(T("Blog post information updated."));
return Redirect(Url.BlogForAdmin(blog.Slug));
}
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
}

View File

@ -57,5 +57,9 @@ namespace Orchard.Blogs.Extensions {
public static string BlogPostDelete(this UrlHelper urlHelper, string blogSlug, string postSlug) {
return urlHelper.Action("Delete", "BlogPostAdmin", new {blogSlug, postSlug, area = "Orchard.Blogs"});
}
public static string BlogPostPublish(this UrlHelper urlHelper, string blogSlug, string postSlug) {
return urlHelper.Action("Publish", "BlogPostAdmin", new { blogSlug, postSlug, area = "Orchard.Blogs" });
}
}
}

View File

@ -7,14 +7,14 @@
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<h2><%=Html.Link(Html.Encode(Model.Item.Title), Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Slug)) %></h2>
<div class="meta"><%=Html.PublishedState(Model.Item) %> | <%=Html.Link(_Encoded("?? comments").ToString(), "") %></div>
<div class="meta"><%=Model.Item.ContentItem.VersionRecord.Published == false ? "Draft" : Html.PublishedState(Model.Item) %> | <%=Html.Link(_Encoded("?? comments").ToString(), "") %></div>
<div class="content"><%=Model.Item.As<BodyAspect>().Text ?? string.Format("<p><em>{0}</em></p>", _Encoded("there's no content for this blog post"))%></div>
<ul class="actions">
<li class="construct">
<a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton edit" title="<%=_Encoded("Edit Post")%>"><%=_Encoded("Edit Post")%></a>
<a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton view" title="<%=_Encoded("View Post")%>"><%=_Encoded("View Post")%></a><%
if (Model.Item.Published == null) { // todo: (heskew) be smart about this and maybe have other contextual actions - including view/preview for view up there ^^ %>
<a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton publish" title="<%=_Encoded("Publish Post Now")%>"><%=_Encoded("Publish Post Now")%></a>
if (Model.Item.ContentItem.VersionRecord.Published == false) { // todo: (heskew) be smart about this and maybe have other contextual actions - including view/preview for view up there ^^ %>
<a href="<%=Url.BlogPostPublish(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton publish" title="<%=_Encoded("Publish Post Now")%>"><%=_Encoded("Publish Post Now")%></a>
<% } %>
</li>
<li class="destruct">