New: Blacklisting can now be toggled in History, preventing that Nzb from being downloaded again.
This commit is contained in:
parent
51bec56741
commit
f63fadfe35
|
@ -299,5 +299,43 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().BeTrue();
|
result.Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SetBlacklist_should_set_to_true_when_true_is_passed_in()
|
||||||
|
{
|
||||||
|
WithRealDb();
|
||||||
|
|
||||||
|
var history = Builder<History>.CreateNew()
|
||||||
|
.With(h => h.Blacklisted = false)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Db.Insert(history);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
Mocker.Resolve<HistoryProvider>().SetBlacklist(history.HistoryId, true);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
var result = Db.Single<History>(history.HistoryId);
|
||||||
|
result.Blacklisted.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SetBlacklist_should_set_to_false_when_false_is_passed_in()
|
||||||
|
{
|
||||||
|
WithRealDb();
|
||||||
|
|
||||||
|
var history = Builder<History>.CreateNew()
|
||||||
|
.With(h => h.Blacklisted = true)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Db.Insert(history);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
Mocker.Resolve<HistoryProvider>().SetBlacklist(history.HistoryId, false);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
var result = Db.Single<History>(history.HistoryId);
|
||||||
|
result.Blacklisted.Should().BeFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -78,5 +78,10 @@ namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
return _database.Exists<History>("WHERE Blacklisted = 1 AND NewzbinId = @0", newzbinId);
|
return _database.Exists<History>("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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
After Width: | Height: | Size: 737 B |
Binary file not shown.
After Width: | Height: | Size: 977 B |
|
@ -1,4 +1,5 @@
|
||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using NzbDrone.Core.Jobs;
|
using NzbDrone.Core.Jobs;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
|
@ -73,10 +74,18 @@ namespace NzbDrone.Web.Controllers
|
||||||
IsProper = h.IsProper,
|
IsProper = h.IsProper,
|
||||||
Date = h.Date,
|
Date = h.Date,
|
||||||
Indexer = h.Indexer,
|
Indexer = h.Indexer,
|
||||||
EpisodeId = h.EpisodeId
|
EpisodeId = h.EpisodeId,
|
||||||
|
Blacklisted = h.Blacklisted
|
||||||
});
|
});
|
||||||
|
|
||||||
return View(new GridModel(history));
|
return View(new GridModel(history));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public JsonResult ToggleBlacklist(int historyId, bool toggle)
|
||||||
|
{
|
||||||
|
_historyProvider.SetBlacklist(historyId, toggle);
|
||||||
|
return new JsonResult { Data = "Success" };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,5 +18,6 @@ namespace NzbDrone.Web.Models
|
||||||
public bool IsProper { get; set; }
|
public bool IsProper { get; set; }
|
||||||
public string Indexer { get; set; }
|
public string Indexer { get; set; }
|
||||||
public int EpisodeId { get; set; }
|
public int EpisodeId { get; set; }
|
||||||
|
public bool Blacklisted { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -141,6 +141,8 @@
|
||||||
<Content Include="Content\2011.3.1115\telerik.metro.min.css" />
|
<Content Include="Content\2011.3.1115\telerik.metro.min.css" />
|
||||||
<Content Include="Content\2011.3.1115\telerik.sitefinity.min.css" />
|
<Content Include="Content\2011.3.1115\telerik.sitefinity.min.css" />
|
||||||
<Content Include="Content\Images\background.jpg" />
|
<Content Include="Content\Images\background.jpg" />
|
||||||
|
<Content Include="Content\Images\blacklist_false.png" />
|
||||||
|
<Content Include="Content\Images\blacklist_true.png" />
|
||||||
<Content Include="Content\Images\blue.png" />
|
<Content Include="Content\Images\blue.png" />
|
||||||
<Content Include="Content\Images\Gear.png" />
|
<Content Include="Content\Images\Gear.png" />
|
||||||
<Content Include="Content\Images\green.png" />
|
<Content Include="Content\Images\green.png" />
|
||||||
|
|
|
@ -11,6 +11,20 @@
|
||||||
@section HeaderContent
|
@section HeaderContent
|
||||||
{
|
{
|
||||||
@Html.IncludeCss("Grid.css")
|
@Html.IncludeCss("Grid.css")
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.blacklist
|
||||||
|
{
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
padding: 1px;
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blacklist:hover
|
||||||
|
{
|
||||||
|
}
|
||||||
|
</style>
|
||||||
}
|
}
|
||||||
<div class="grid-container">
|
<div class="grid-container">
|
||||||
@{Html.Telerik().Grid<HistoryModel>().Name("history")
|
@{Html.Telerik().Grid<HistoryModel>().Name("history")
|
||||||
|
@ -33,7 +47,8 @@
|
||||||
columns.Bound(c => c.Date).Title("Grabbed on");
|
columns.Bound(c => c.Date).Title("Grabbed on");
|
||||||
columns.Bound(c => c.HistoryId)
|
columns.Bound(c => c.HistoryId)
|
||||||
.Title("Actions")
|
.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("<img src='../../Content/Images/blacklist_<#= Blacklisted #>.png' class='blacklist blacklist_<#= Blacklisted #>' id='<#= HistoryId #>' title='Click to toggle blacklisting status' />" +
|
||||||
|
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())
|
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");
|
.Width("40");
|
||||||
})
|
})
|
||||||
|
@ -54,9 +69,41 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
deleteHistoryRowUrl = '../History/Delete';
|
deleteHistoryRowUrl = '../History/Delete';
|
||||||
redownloadUrl = '../History/Redownload';
|
redownloadUrl = '../History/Redownload';
|
||||||
|
var toggleBlacklistUrl = '../History/ToggleBlacklist';
|
||||||
|
var blacklistedTrueImage = '../../Content/Images/blacklist_true.png';
|
||||||
|
var blacklistedFalseImage = '../../Content/Images/blacklist_false.png';
|
||||||
|
|
||||||
function reloadHistoryGrid() {
|
function reloadHistoryGrid() {
|
||||||
var grid = $('#history').data('tGrid');
|
var grid = $('#history').data('tGrid');
|
||||||
grid.ajaxRequest();
|
grid.ajaxRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(".blacklist").live("click", function () {
|
||||||
|
var toggle = $(this);
|
||||||
|
var result = toggle.hasClass('blacklist_true');
|
||||||
|
var id = toggle.attr('id');
|
||||||
|
|
||||||
|
toggle.toggleClass('blacklist_true blacklist_false');
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
toggle.attr('src', blacklistedFalseImage);
|
||||||
|
toggleBlacklist(id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
toggle.attr('src', blacklistedTrueImage);
|
||||||
|
toggleBlacklist(id, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function toggleBlacklist(historyId, toggle) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: toggleBlacklistUrl,
|
||||||
|
data: jQuery.param({ historyId: historyId, toggle: toggle }),
|
||||||
|
error: function (req, status, error) {
|
||||||
|
alert("Sorry! We could not toggle blacklist for History: " + historyId + " " + error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue