Merge 2da79128cf
into 0b88976ce0
This commit is contained in:
commit
31216e2a13
|
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<SabProvider>()
|
||||
.Setup(s => s.AddByUrl(parseResult.NzbUrl, sabTitle))
|
||||
.Setup(s => s.AddByUrl(parseResult, sabTitle))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<SabProvider>()
|
||||
|
|
|
@ -191,5 +191,185 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
history.Quality.Should().Be(storedHistory.First().Quality);
|
||||
history.IsProper.Should().Be(storedHistory.First().IsProper);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_false_if_nzbTitle_doesnt_exist()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted("Not a Real NZB Title");
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_false_if_nzbTitle_is_not_blacklisted()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(history.NzbTitle);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_true_if_nzbTitle_is_blacklisted()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = true)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(history.NzbTitle);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_true_if_nzbTitle_is_blacklisted_ignoring_case()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = true)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(history.NzbTitle.ToLower());
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_false_if_newzbinId_doesnt_exist()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(555);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_false_if_newzbinId_is_not_blacklisted()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(history.NewzbinId);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_return_true_if_newzbinId_is_blacklisted()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Blacklisted = true)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<HistoryProvider>().IsBlacklisted(history.NewzbinId);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsBlacklisted_should_throw_if_newzbinId_is_less_than_1()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
Mocker.Resolve<HistoryProvider>().IsBlacklisted(0)
|
||||
);
|
||||
}
|
||||
|
||||
[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();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetBlacklist_should_throw_if_newzbinId_is_less_than_1()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
Mocker.Resolve<HistoryProvider>().SetBlacklist(0, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,6 +29,13 @@ namespace NzbDrone.Core.Test.ProviderTests.InventoryProviderTests
|
|||
private QualityProfile sdProfile;
|
||||
private Series series;
|
||||
|
||||
private void WithNoBlacklist()
|
||||
{
|
||||
Mocker.GetMock<HistoryProvider>()
|
||||
.Setup(s => s.IsBlacklisted(It.IsAny<string>()))
|
||||
.Returns(false);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
@ -186,6 +193,7 @@ namespace NzbDrone.Core.Test.ProviderTests.InventoryProviderTests
|
|||
public void IsQualityNeeded_lesser_file_in_history_should_be_downloaded()
|
||||
{
|
||||
WithStrictMocker();
|
||||
WithNoBlacklist();
|
||||
|
||||
parseResultSingle.Series.QualityProfile = sdProfile;
|
||||
parseResultSingle.Quality.QualityType = QualityTypes.DVD;
|
||||
|
@ -240,6 +248,8 @@ namespace NzbDrone.Core.Test.ProviderTests.InventoryProviderTests
|
|||
.Setup(s => s.Get(It.IsAny<int>()))
|
||||
.Returns(new QualityType { MaxSize = 100, MinSize = 0 });
|
||||
|
||||
WithNoBlacklist();
|
||||
|
||||
episode.EpisodeFile.Quality = QualityTypes.SDTV;
|
||||
//Act
|
||||
bool result = Mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle);
|
||||
|
@ -299,6 +309,8 @@ namespace NzbDrone.Core.Test.ProviderTests.InventoryProviderTests
|
|||
.Setup(s => s.Get(It.IsAny<int>()))
|
||||
.Returns(new QualityType { MaxSize = 100, MinSize = 0 });
|
||||
|
||||
WithNoBlacklist();
|
||||
|
||||
episode.EpisodeFile.Quality = QualityTypes.SDTV;
|
||||
//Act
|
||||
bool result = Mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle, true);
|
||||
|
|
|
@ -21,6 +21,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SabProviderTests
|
|||
// ReSharper disable InconsistentNaming
|
||||
public class SabProviderTest : CoreTest
|
||||
{
|
||||
private EpisodeParseResult newzbinResult;
|
||||
private EpisodeParseResult nonNewzbinResult;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
@ -39,8 +42,17 @@ namespace NzbDrone.Core.Test.ProviderTests.SabProviderTests
|
|||
fakeConfig.SetupGet(c => c.SabUsername).Returns(username);
|
||||
fakeConfig.SetupGet(c => c.SabPassword).Returns(password);
|
||||
fakeConfig.SetupGet(c => c.SabTvCategory).Returns(cat);
|
||||
}
|
||||
|
||||
newzbinResult = Builder<EpisodeParseResult>.CreateNew()
|
||||
.With(r => r.NewzbinId = 6107863)
|
||||
.With(r => r.Indexer = "Newzbin")
|
||||
.Build();
|
||||
|
||||
nonNewzbinResult = Builder<EpisodeParseResult>.CreateNew()
|
||||
.With(r => r.NzbUrl = "http://www.nzbclub.com/nzb_download.aspx?mid=1950232")
|
||||
.With(r => r.Indexer = "Not Newzbin")
|
||||
.Build();
|
||||
}
|
||||
|
||||
private void WithFailResponse()
|
||||
{
|
||||
|
@ -59,9 +71,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SabProviderTests
|
|||
.Returns("ok");
|
||||
|
||||
//Act
|
||||
bool result = Mocker.Resolve<SabProvider>().AddByUrl(
|
||||
"http://www.nzbclub.com/nzb_download.aspx?mid=1950232",
|
||||
"This is an Nzb");
|
||||
bool result = Mocker.Resolve<SabProvider>().AddByUrl(nonNewzbinResult, "This is an Nzb");
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
|
@ -79,9 +89,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SabProviderTests
|
|||
.Returns("ok");
|
||||
|
||||
//Act
|
||||
bool result = Mocker.Resolve<SabProvider>().AddByUrl(
|
||||
"http://www.newzbin.com/browse/post/6107863/nzb",
|
||||
"This is an Nzb");
|
||||
bool result = Mocker.Resolve<SabProvider>().AddByUrl(newzbinResult, "This is an Nzb");
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
|
@ -94,7 +102,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SabProviderTests
|
|||
|
||||
//Act
|
||||
var sabProvider = Mocker.Resolve<SabProvider>();
|
||||
var result = sabProvider.AddByUrl("http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an nzb");
|
||||
var result = sabProvider.AddByUrl(nonNewzbinResult, "This is an nzb");
|
||||
|
||||
//Assert
|
||||
Assert.IsFalse(result);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20120127)]
|
||||
public class Migration20120127 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("History", "NewzbinId", DbType.Int32, ColumnProperty.Null);
|
||||
Database.AddColumn("History", "Blacklisted", DbType.Boolean, ColumnProperty.Null);
|
||||
Database.ExecuteNonQuery("UPDATE History SET Blacklisted = 0");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,6 +39,8 @@ namespace NzbDrone.Core.Model
|
|||
|
||||
public long Size { get; set; }
|
||||
|
||||
public int NewzbinId { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (AirDate != null && EpisodeNumbers == null)
|
||||
|
|
|
@ -212,6 +212,7 @@
|
|||
<Compile Include="Datastore\MigrationLogger.cs" />
|
||||
<Compile Include="Datastore\MigrationsHelper.cs" />
|
||||
<Compile Include="Datastore\CustomeMapper.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120127.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120123.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120118.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20111125.cs" />
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Providers
|
|||
}
|
||||
|
||||
var sabTitle = _sabProvider.GetSabTitle(parseResult);
|
||||
var addSuccess = _sabProvider.AddByUrl(parseResult.NzbUrl, sabTitle);
|
||||
var addSuccess = _sabProvider.AddByUrl(parseResult, sabTitle);
|
||||
|
||||
if (addSuccess)
|
||||
{
|
||||
|
@ -54,6 +54,7 @@ namespace NzbDrone.Core.Providers
|
|||
history.NzbTitle = parseResult.OriginalString;
|
||||
history.EpisodeId = episode.EpisodeId;
|
||||
history.SeriesId = episode.SeriesId;
|
||||
history.NewzbinId = parseResult.NewzbinId;
|
||||
|
||||
_historyProvider.Add(history);
|
||||
_episodeProvider.MarkEpisodeAsFetched(episode.EpisodeId);
|
||||
|
|
|
@ -68,5 +68,26 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
_database.Delete<History>(historyId);
|
||||
}
|
||||
|
||||
public virtual bool IsBlacklisted(string nzbTitle)
|
||||
{
|
||||
return _database.Exists<History>("WHERE Blacklisted = 1 AND NzbTitle = @0", nzbTitle);
|
||||
}
|
||||
|
||||
public virtual bool IsBlacklisted(int newzbinId)
|
||||
{
|
||||
if (newzbinId <= 0)
|
||||
throw new ArgumentException("Newzbin ID must be greater than 0");
|
||||
|
||||
return _database.Exists<History>("WHERE Blacklisted = 1 AND NewzbinId = @0", newzbinId);
|
||||
}
|
||||
|
||||
public virtual void SetBlacklist(int historyId, bool toggle)
|
||||
{
|
||||
if (historyId <= 0)
|
||||
throw new ArgumentException("HistoryId must be greater than 0");
|
||||
|
||||
_database.Execute("UPDATE History SET Blacklisted = @0 WHERE HistoryId = @1", toggle, historyId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -85,7 +85,7 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
//Don't change the name or things that rely on it being "Newzbin" will fail... ugly...
|
||||
public override string Name
|
||||
{
|
||||
get { return "Newzbin"; }
|
||||
|
@ -101,19 +101,18 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||
if (currentResult != null)
|
||||
{
|
||||
var quality = Parser.ParseQuality(item.Summary.Text);
|
||||
|
||||
currentResult.Quality = quality;
|
||||
|
||||
var languageString = Regex.Match(item.Summary.Text, @"Language - \w*", RegexOptions.IgnoreCase).Value;
|
||||
|
||||
currentResult.Language = Parser.ParseLanguage(languageString);
|
||||
|
||||
var sizeString = Regex.Match(item.Summary.Text, @"\(Size: \d*\,?\d+\.\d{1,2}\w{2}\)", RegexOptions.IgnoreCase).Value;
|
||||
|
||||
currentResult.Size = Parser.GetReportSize(sizeString);
|
||||
|
||||
var id = Regex.Match(NzbDownloadUrl(item), @"\d{5,10}").Value;
|
||||
currentResult.NewzbinId = Int32.Parse(id);
|
||||
}
|
||||
return currentResult;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -116,6 +116,26 @@ namespace NzbDrone.Core.Providers
|
|||
}
|
||||
}
|
||||
|
||||
if (parsedReport.Indexer == "Newzbin")
|
||||
{
|
||||
//Check for Blacklisting by NewzbinId
|
||||
Logger.Trace("Checking if Newzbin ID has been black listed: ", parsedReport.NewzbinId);
|
||||
if (_historyProvider.IsBlacklisted(parsedReport.NewzbinId))
|
||||
{
|
||||
Logger.Info("Newzbin ID has been blacklisted: [{0}] Skipping", parsedReport.NewzbinId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Trace("Checking if Nzb has been black listed: ", parsedReport.OriginalString);
|
||||
if(_historyProvider.IsBlacklisted(parsedReport.OriginalString))
|
||||
{
|
||||
Logger.Info("Nzb has been blacklisted: [{0}] Skipping", parsedReport.OriginalString);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Debug("Episode {0} is needed", parsedReport);
|
||||
|
|
|
@ -31,21 +31,23 @@ namespace NzbDrone.Core.Providers
|
|||
_httpProvider = httpProvider;
|
||||
}
|
||||
|
||||
public virtual bool AddByUrl(string url, string title)
|
||||
public virtual bool AddByUrl(EpisodeParseResult parseResult, string title)
|
||||
{
|
||||
string cat = _configProvider.SabTvCategory;
|
||||
int priority = (int)_configProvider.SabTvPriority;
|
||||
string name = GetNzbName(url);
|
||||
string name = GetNzbName(parseResult.NzbUrl);
|
||||
string nzbName = HttpUtility.UrlEncode(title);
|
||||
string mode = "addurl";
|
||||
|
||||
string action = string.Format("mode=addurl&name={0}&priority={1}&pp=3&cat={2}&nzbname={3}",
|
||||
name, priority, cat, nzbName);
|
||||
|
||||
if (url.ToLower().Contains("newzbin"))
|
||||
if (parseResult.Indexer == "Newzbin")
|
||||
{
|
||||
action = action.Replace("mode=addurl", "mode=addid");
|
||||
mode = "addid";
|
||||
name = parseResult.NewzbinId.ToString();
|
||||
}
|
||||
|
||||
string action = string.Format("mode={0}&name={1}&priority={2}&pp=3&cat={3}&nzbname={4}", mode,
|
||||
name, priority, cat, nzbName);
|
||||
|
||||
string request = GetSabRequest(action);
|
||||
|
||||
Logger.Info("Adding report [{0}] to the queue.", title);
|
||||
|
@ -63,13 +65,6 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
private static string GetNzbName(string urlString)
|
||||
{
|
||||
var url = new Uri(urlString);
|
||||
if (url.Host.ToLower().Contains("newzbin"))
|
||||
{
|
||||
var postId = Regex.Match(urlString, @"\d{5,10}").Value;
|
||||
return postId;
|
||||
}
|
||||
|
||||
return urlString.Replace("&", "%26");
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace NzbDrone.Core.Repository
|
|||
public DateTime Date { get; set; }
|
||||
public bool IsProper { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public int NewzbinId { get; set; }
|
||||
public bool Blacklisted { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public Episode Episode { get; set; }
|
||||
|
|
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 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" };
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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; }
|
||||
}
|
||||
}
|
|
@ -141,6 +141,8 @@
|
|||
<Content Include="Content\2011.3.1115\telerik.metro.min.css" />
|
||||
<Content Include="Content\2011.3.1115\telerik.sitefinity.min.css" />
|
||||
<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\Gear.png" />
|
||||
<Content Include="Content\Images\green.png" />
|
||||
|
|
|
@ -12,6 +12,20 @@
|
|||
@section HeaderContent
|
||||
{
|
||||
@Html.IncludeCss("Grid.css")
|
||||
|
||||
<style>
|
||||
.blacklist
|
||||
{
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.blacklist:hover
|
||||
{
|
||||
}
|
||||
</style>
|
||||
}
|
||||
<div class="grid-container">
|
||||
@{Html.Telerik().Grid<HistoryModel>().Name("history")
|
||||
|
@ -34,7 +48,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("<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())
|
||||
.Width("40");
|
||||
})
|
||||
|
@ -60,9 +75,41 @@
|
|||
<script type="text/javascript">
|
||||
deleteHistoryRowUrl = '../History/Delete';
|
||||
redownloadUrl = '../History/Redownload';
|
||||
var toggleBlacklistUrl = '../History/ToggleBlacklist';
|
||||
var blacklistedTrueImage = '../../Content/Images/blacklist_true.png';
|
||||
var blacklistedFalseImage = '../../Content/Images/blacklist_false.png';
|
||||
|
||||
function reloadHistoryGrid() {
|
||||
var grid = $('#history').data('tGrid');
|
||||
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>
|
||||
|
|
Loading…
Reference in New Issue