mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Adding a "Delete" button on the blog edit page. Keeping consistent with what we're doing with widgets.
work item: 17769 --HG-- branch : 1.x
This commit is contained in:
@@ -100,6 +100,24 @@ namespace Orchard.Blogs.Controllers {
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Edit")]
|
||||
[FormValueRequired("submit.Delete")]
|
||||
public ActionResult EditDeletePOST(int blogId) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blog = _blogService.Get(blogId, VersionOptions.DraftRequired);
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
_blogService.Delete(blog);
|
||||
|
||||
Services.Notifier.Information(T("Blog deleted"));
|
||||
|
||||
return Redirect(Url.BlogsForAdmin());
|
||||
}
|
||||
|
||||
|
||||
[HttpPost, ActionName("Edit")]
|
||||
[FormValueRequired("submit.Save")]
|
||||
public ActionResult EditPOST(int blogId) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement;
|
||||
@@ -10,19 +11,28 @@ namespace Orchard.Blogs.Drivers {
|
||||
protected override DriverResult Display(BlogPart part, string displayType, dynamic shapeHelper) {
|
||||
return Combined(
|
||||
ContentShape("Parts_Blogs_Blog_Manage",
|
||||
() => shapeHelper.Parts_Blogs_Blog_Manage(ContentPart: part)),
|
||||
() => shapeHelper.Parts_Blogs_Blog_Manage(ContentPart: part)),
|
||||
ContentShape("Parts_Blogs_Blog_Description",
|
||||
() => shapeHelper.Parts_Blogs_Blog_Description(ContentPart: part, Description: part.Description)),
|
||||
() => shapeHelper.Parts_Blogs_Blog_Description(ContentPart: part, Description: part.Description)),
|
||||
ContentShape("Parts_Blogs_Blog_SummaryAdmin",
|
||||
() => shapeHelper.Parts_Blogs_Blog_SummaryAdmin(ContentPart: part, ContentItem: part.ContentItem)),
|
||||
() => shapeHelper.Parts_Blogs_Blog_SummaryAdmin(ContentPart: part, ContentItem: part.ContentItem)),
|
||||
ContentShape("Parts_Blogs_Blog_BlogPostCount",
|
||||
() => shapeHelper.Parts_Blogs_Blog_BlogPostCount(ContentPart: part, PostCount: part.PostCount))
|
||||
() => shapeHelper.Parts_Blogs_Blog_BlogPostCount(ContentPart: part, PostCount: part.PostCount))
|
||||
);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogPart blogPart, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_Blogs_Blog_Fields",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Blogs.Blog.Fields", Model: blogPart, Prefix: Prefix));
|
||||
var results = new List<DriverResult> {
|
||||
ContentShape("Parts_Blogs_Blog_Fields",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Blogs.Blog.Fields", Model: blogPart, Prefix: Prefix))
|
||||
};
|
||||
|
||||
|
||||
if (blogPart.Id > 0)
|
||||
results.Add(ContentShape("Blog_DeleteButton",
|
||||
deleteButton => deleteButton));
|
||||
|
||||
return Combined(results.ToArray());
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogPart blogPart, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<TargetFrameworkProfile />
|
||||
<UseIISExpress>false</UseIISExpress>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -166,6 +167,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Parts.Blogs.Blog.SummaryAdmin.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Blog.DeleteButton.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<Place Parts_Blogs_Blog_Fields="Content:2"/>
|
||||
<Place Parts_Blogs_BlogArchives_Edit="Content:5"/>
|
||||
<Place Parts_Blogs_RecentBlogPosts_Edit="Content:5"/>
|
||||
<Place Blog_DeleteButton="Sidebar:25" />
|
||||
<!-- widgets -->
|
||||
<Place Parts_Blogs_BlogArchives="Content"/>
|
||||
<Place Parts_Blogs_RecentBlogPosts="Content"/>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<fieldset class="delete-button">
|
||||
<button type="submit" name="submit.Delete" value="@T("Delete")">@T("Delete")</button>
|
||||
</fieldset>
|
||||
Reference in New Issue
Block a user