Hooked up remove BlogPost in the admin.

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045314
This commit is contained in:
ErikPorter
2010-01-12 23:48:09 +00:00
parent adde3ef6ea
commit 706bd7f2e4
4 changed files with 26 additions and 17 deletions

View File

@@ -181,7 +181,7 @@ namespace Orchard.Blogs.Controllers {
if (blog == null)
return new NotFoundResult();
BlogPost post = _blogPostService.Get(blog, postSlug);
BlogPost post = _blogPostService.Get(blog, postSlug, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();

View File

@@ -16,6 +16,7 @@ namespace Orchard.Blogs.Models {
Filters.Add(new StorageFilter<CommonVersionRecord>(commonRepository));
OnCreated<BlogPost>((context, bp) => bp.Blog.PostCount++);
OnRemoved<BlogPost>((context, bp) => bp.Blog.PostCount--);
}
}
}

View File

@@ -1,4 +1,6 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPost>>" %>
<%@ Import Namespace="Orchard.Themes"%>
<%@ Import Namespace="Orchard.Extensions"%>
<%@ Import Namespace="Orchard.ContentManagement"%>
<%@ Import Namespace="Orchard.Core.Common.Models"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
@@ -7,14 +9,19 @@
<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="content"><%=Model.Item.As<BodyAspect>().Text ?? string.Format("<p><em>{0}</em></p>", _Encoded("there's no content for this blog post"))%></div>
<p class="actions">
<%-- todo: (heskew) make into a ul --%>
<span class="construct">
<ul class="actions">
<li class="construct">
<a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton edit"><%=_Encoded("Edit Post")%></a>
<a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton view"><%=_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"><%=_Encoded("Publish Post Now")%></a>
<% } %>
</span>
<span class="destruct"><a href="#" class="ibutton remove"><%=_Encoded("Remove Post")%></a></span>
</p>
</li>
<li class="destruct">
<% using (Html.BeginFormAntiForgeryPost(Url.BlogPostDelete(Model.Item.Blog.Slug, Model.Item.Slug))) { %>
<fieldset>
<input type="image" src="<%=ResolveUrl(Html.Resolve<IExtensionManager>().GetThemeLocation(Html.Resolve<IThemeService>().GetRequestTheme(ViewContext.RequestContext)) + "/styles/images/remove.png") %>" alt="<%=_Encoded("Remove Post") %>" title="<%=_Encoded("Remove Post") %>" class="ibutton image remove" />
</fieldset><%
} %>
</li>
</ul>

View File

@@ -211,16 +211,17 @@ namespace Orchard.Mvc.Html {
return htmlHelper.BeginFormAntiForgeryPost(htmlHelper.ViewContext.HttpContext.Request.RawUrl, FormMethod.Post, new RouteValueDictionary());
}
//TODO: (erikpo) Uncomment when needed (not currently needed)
//public static MvcForm BeginFormAntiForgeryPost(this HtmlHelper htmlHelper, string formAction) {
// return htmlHelper.BeginFormAntiForgeryPost(formAction, FormMethod.Post, new RouteValueDictionary());
//}
//public static MvcForm BeginFormAntiForgeryPost(this HtmlHelper htmlHelper, string formAction, FormMethod formMethod) {
// return htmlHelper.BeginFormAntiForgeryPost(formAction, formMethod, new RouteValueDictionary());
//}
//public static MvcForm BeginFormAntiForgeryPost(this HtmlHelper htmlHelper, string formAction, FormMethod formMethod, object htmlAttributes) {
// return htmlHelper.BeginFormAntiForgeryPost(formAction, formMethod, new RouteValueDictionary(htmlAttributes));
//}
public static MvcForm BeginFormAntiForgeryPost(this HtmlHelper htmlHelper, string formAction) {
return htmlHelper.BeginFormAntiForgeryPost(formAction, FormMethod.Post, new RouteValueDictionary());
}
public static MvcForm BeginFormAntiForgeryPost(this HtmlHelper htmlHelper, string formAction, FormMethod formMethod) {
return htmlHelper.BeginFormAntiForgeryPost(formAction, formMethod, new RouteValueDictionary());
}
public static MvcForm BeginFormAntiForgeryPost(this HtmlHelper htmlHelper, string formAction, FormMethod formMethod, object htmlAttributes) {
return htmlHelper.BeginFormAntiForgeryPost(formAction, formMethod, new RouteValueDictionary(htmlAttributes));
}
public static MvcForm BeginFormAntiForgeryPost(this HtmlHelper htmlHelper, string formAction, FormMethod formMethod, IDictionary<string, object> htmlAttributes) {
TagBuilder tagBuilder = new TagBuilder("form");