diff --git a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs index 777f425b0..54633acc4 100644 --- a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs @@ -299,5 +299,43 @@ namespace NzbDrone.Core.Test.ProviderTests //Assert result.Should().BeTrue(); } + + [Test] + public void SetBlacklist_should_set_to_true_when_true_is_passed_in() + { + WithRealDb(); + + var history = Builder.CreateNew() + .With(h => h.Blacklisted = false) + .Build(); + + Db.Insert(history); + + //Act + Mocker.Resolve().SetBlacklist(history.HistoryId, true); + + //Assert + var result = Db.Single(history.HistoryId); + result.Blacklisted.Should().BeTrue(); + } + + [Test] + public void SetBlacklist_should_set_to_false_when_false_is_passed_in() + { + WithRealDb(); + + var history = Builder.CreateNew() + .With(h => h.Blacklisted = true) + .Build(); + + Db.Insert(history); + + //Act + Mocker.Resolve().SetBlacklist(history.HistoryId, false); + + //Assert + var result = Db.Single(history.HistoryId); + result.Blacklisted.Should().BeFalse(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/HistoryProvider.cs b/NzbDrone.Core/Providers/HistoryProvider.cs index 667ad35ac..b8663b70e 100644 --- a/NzbDrone.Core/Providers/HistoryProvider.cs +++ b/NzbDrone.Core/Providers/HistoryProvider.cs @@ -78,5 +78,10 @@ namespace NzbDrone.Core.Providers { return _database.Exists("WHERE Blacklisted = 1 AND NewzbinId = @0", newzbinId); } + + public virtual void SetBlacklist(int historyId, bool toggle) + { + _database.Execute("UPDATE History SET Blacklisted = @0 WHERE HistoryId = @1", toggle, historyId); + } } } \ No newline at end of file diff --git a/NzbDrone.Web/Content/Images/blacklist_false.png b/NzbDrone.Web/Content/Images/blacklist_false.png new file mode 100644 index 000000000..39a1bfece Binary files /dev/null and b/NzbDrone.Web/Content/Images/blacklist_false.png differ diff --git a/NzbDrone.Web/Content/Images/blacklist_true.png b/NzbDrone.Web/Content/Images/blacklist_true.png new file mode 100644 index 000000000..5ef7a3307 Binary files /dev/null and b/NzbDrone.Web/Content/Images/blacklist_true.png differ diff --git a/NzbDrone.Web/Controllers/HistoryController.cs b/NzbDrone.Web/Controllers/HistoryController.cs index f742f4804..ee0ea089a 100644 --- a/NzbDrone.Web/Controllers/HistoryController.cs +++ b/NzbDrone.Web/Controllers/HistoryController.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Web.Mvc; using NzbDrone.Core.Jobs; using NzbDrone.Core.Providers; @@ -73,10 +74,18 @@ namespace NzbDrone.Web.Controllers IsProper = h.IsProper, Date = h.Date, Indexer = h.Indexer, - EpisodeId = h.EpisodeId + EpisodeId = h.EpisodeId, + Blacklisted = h.Blacklisted }); return View(new GridModel(history)); } + + [HttpPost] + public JsonResult ToggleBlacklist(int historyId, bool toggle) + { + _historyProvider.SetBlacklist(historyId, toggle); + return new JsonResult { Data = "Success" }; + } } } \ No newline at end of file diff --git a/NzbDrone.Web/Models/HistoryModel.cs b/NzbDrone.Web/Models/HistoryModel.cs index 1bb6cbd25..e95452388 100644 --- a/NzbDrone.Web/Models/HistoryModel.cs +++ b/NzbDrone.Web/Models/HistoryModel.cs @@ -18,5 +18,6 @@ namespace NzbDrone.Web.Models public bool IsProper { get; set; } public string Indexer { get; set; } public int EpisodeId { get; set; } + public bool Blacklisted { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index cecff258d..f13ce7724 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -141,6 +141,8 @@ + + diff --git a/NzbDrone.Web/Views/History/Index.cshtml b/NzbDrone.Web/Views/History/Index.cshtml index 497acf2de..fb5162c4f 100644 --- a/NzbDrone.Web/Views/History/Index.cshtml +++ b/NzbDrone.Web/Views/History/Index.cshtml @@ -11,6 +11,20 @@ @section HeaderContent { @Html.IncludeCss("Grid.css") + + }
@{Html.Telerik().Grid().Name("history") @@ -33,7 +47,8 @@ columns.Bound(c => c.Date).Title("Grabbed on"); columns.Bound(c => c.HistoryId) .Title("Actions") - .ClientTemplate(Ajax.ImageActionLink("../../Content/Images/X.png", new { Alt = "Delete", Title = "Delete from history", @class = "searchImage" }, "Delete", "History", new { HistoryId = "<#= HistoryId #>" }, new AjaxOptions { OnSuccess = "reloadHistoryGrid" }, null).ToString() + + .ClientTemplate("" + + Ajax.ImageActionLink("../../Content/Images/X.png", new { Alt = "Delete", Title = "Delete from history", @class = "searchImage" }, "Delete", "History", new { HistoryId = "<#= HistoryId #>" }, new AjaxOptions { OnSuccess = "reloadHistoryGrid" }, null).ToString() + Ajax.ImageActionLink("../../Content/Images/Downloading.png", new { Alt = "Redownload", Title = "Redownlod Episode", @class = "searchImage" }, "Redownload", "History", new { HistoryId = "<#= HistoryId #>", EpisodeId = "<#= EpisodeId #>" }, new AjaxOptions { OnSuccess = "reloadHistoryGrid" }, null).ToString()) .Width("40"); }) @@ -54,9 +69,41 @@