- Fixing more tags related regressions.

- Fixing a bug where tags weren't being applied to new posts.

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4046035
This commit is contained in:
suhacan
2010-01-28 00:58:20 +00:00
parent 08fa1c0c6b
commit 69bda8f0da
3 changed files with 20 additions and 11 deletions

View File

@@ -62,6 +62,7 @@ namespace Orchard.Blogs.Controllers {
}
Services.ContentManager.Create(model.BlogPost.Item.ContentItem, VersionOptions.Draft);
Services.ContentManager.UpdateEditorModel(blogPost, this);
// Execute publish command
switch (Request.Form["Command"]) {

View File

@@ -45,7 +45,9 @@ namespace Orchard.Tags.Controllers {
updater.TryUpdateModel(model, Prefix, null, null);
var tagNames = TagHelpers.ParseCommaSeparatedTagNames(model.Tags);
_tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames);
if (part.ContentItem.Id != 0) {
_tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames);
}
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location("primary", "9");
}

View File

@@ -3,8 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Security;
using Orchard.Settings;
using Orchard.Tags.Helpers;
using Orchard.Tags.Services;
@@ -15,16 +17,20 @@ namespace Orchard.Tags.Controllers {
[ValidateInput(false)]
public class HomeController : Controller {
private readonly ITagService _tagService;
private readonly IContentManager _contentManager;
private readonly INotifier _notifier;
private readonly IAuthorizer _authorizer;
public HomeController(ITagService tagService) {
public HomeController(ITagService tagService, IAuthorizer authorizer, INotifier notifier, IContentManager contentManager) {
_tagService = tagService;
_authorizer = authorizer;
_notifier = notifier;
_contentManager = contentManager;
T = NullLocalizer.Instance;
}
public IOrchardServices Services { get; set; }
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
public ILogger Logger { get; set; }
public Localizer T { get; set; }
@@ -35,7 +41,7 @@ namespace Orchard.Tags.Controllers {
return View(model);
}
catch (Exception exception) {
Services.Notifier.Error(T("Listing tags failed: " + exception.Message));
_notifier.Error(T("Listing tags failed: " + exception.Message));
return Index();
}
}
@@ -43,7 +49,7 @@ namespace Orchard.Tags.Controllers {
[HttpPost]
public ActionResult Edit(FormCollection input, int taggedContentId, string returnUrl, string newTagName) {
try {
if (!Services.Authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
if (!_authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
return new HttpUnauthorizedResult();
if (!String.IsNullOrEmpty(newTagName)) {
foreach (var tagName in TagHelpers.ParseCommaSeparatedTagNames(newTagName)) {
@@ -59,7 +65,7 @@ namespace Orchard.Tags.Controllers {
return RedirectToAction("Index");
}
catch (Exception exception) {
Services.Notifier.Error(T("Editing tags failed: " + exception.Message));
_notifier.Error(T("Editing tags failed: " + exception.Message));
if (!String.IsNullOrEmpty(returnUrl)) {
return Redirect(returnUrl);
}
@@ -70,7 +76,7 @@ namespace Orchard.Tags.Controllers {
[HttpPost]
public ActionResult Update(string tags, int taggedContentId, string returnUrl) {
try {
if (!Services.Authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
if (!_authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
return new HttpUnauthorizedResult();
List<string> tagNames = TagHelpers.ParseCommaSeparatedTagNames(tags);
_tagService.UpdateTagsForContentItem(taggedContentId, tagNames);
@@ -80,7 +86,7 @@ namespace Orchard.Tags.Controllers {
return RedirectToAction("Index");
}
catch (Exception exception) {
Services.Notifier.Error(T("Updating tags failed: " + exception.Message));
_notifier.Error(T("Updating tags failed: " + exception.Message));
if (!String.IsNullOrEmpty(returnUrl)) {
return Redirect(returnUrl);
}
@@ -93,7 +99,7 @@ namespace Orchard.Tags.Controllers {
var tag = _tagService.GetTagByName(tagName);
var items =
_tagService.GetTaggedContentItems(tag.Id).Select(
ic => Services.ContentManager.BuildDisplayModel(ic, "SummaryForSearch"));
ic => _contentManager.BuildDisplayModel(ic, "SummaryForSearch"));
var viewModel = new TagsSearchViewModel {
TagName = tag.TagName,
@@ -103,7 +109,7 @@ namespace Orchard.Tags.Controllers {
}
catch (Exception exception) {
Services.Notifier.Error(T("Retrieving tagged items failed: " + exception.Message));
_notifier.Error(T("Retrieving tagged items failed: " + exception.Message));
return RedirectToAction("Index");
}
}