Merge branch 'master' into backbone

Conflicts:
	NzbDrone.Web/Global.asax.cs
pull/3113/head
Mark McDowall 12 years ago
commit 65f2dbce77

3
.gitignore vendored

@ -17,8 +17,9 @@ Thumbs.db
*.cache
*.ilk
*.log
[Bb]in*/
[Bb]in
[Dd]ebug*/
[Rrelease]*/
*.lib
*.sbr
*.nzb

@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests
public class QualityTypeProviderTest : CoreTest
{
[Test]
public void SetupDefault_should_add_six_profiles()
public void SetupDefault_should_add_all_profiles()
{
var db = TestDbHelper.GetEmptyDatabase();
@ -33,8 +33,8 @@ namespace NzbDrone.Core.Test.ProviderTests
types.Should().Contain(e => e.Name == "SDTV" && e.QualityTypeId == 1);
types.Should().Contain(e => e.Name == "DVD" && e.QualityTypeId == 2);
types.Should().Contain(e => e.Name == "HDTV" && e.QualityTypeId == 4);
types.Should().Contain(e => e.Name == "WEBDL720p" && e.QualityTypeId == 5);
types.Should().Contain(e => e.Name == "WEBDL1080p" && e.QualityTypeId == 3);
types.Should().Contain(e => e.Name == "WEBDL-720p" && e.QualityTypeId == 5);
types.Should().Contain(e => e.Name == "WEBDL-1080p" && e.QualityTypeId == 3);
types.Should().Contain(e => e.Name == "Bluray720p" && e.QualityTypeId == 6);
types.Should().Contain(e => e.Name == "Bluray1080p" && e.QualityTypeId == 7);
}

@ -58,21 +58,15 @@ namespace NzbDrone.Core.Providers
Logger.Debug("Setting up default quality types");
var qualityTypes = new List<QualityType>();
qualityTypes.Add(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 2, Name = "DVD", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 4, Name = "HDTV", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 5, Name = "WEBDL720p", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 3, Name = "WEBDL1080p", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 6, Name = "Bluray720p", MinSize = 0, MaxSize = 100 });
qualityTypes.Add(new QualityType { QualityTypeId = 7, Name = "Bluray1080p", MinSize = 0, MaxSize = 100 });
foreach(var qualityType in qualityTypes)
foreach(var qualityType in QualityTypes.All())
{
var db = inDb.SingleOrDefault(s => s.QualityTypeId == qualityType.QualityTypeId);
//Skip UNKNOWN
if (qualityType.Id == 0) continue;
var db = inDb.SingleOrDefault(s => s.QualityTypeId == qualityType.Id);
if (db == null)
_database.Insert(qualityType);
_database.Insert(new QualityType { QualityTypeId = qualityType.Id, Name = qualityType.Name, MinSize = 0, MaxSize = 100 });
}
}
}

@ -16,6 +16,8 @@ using NzbDrone.Common;
using NzbDrone.Core;
using ServiceStack.CacheAccess;
using ServiceStack.CacheAccess.Providers;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Helpers.Binders;
using ServiceStack.ServiceInterface;
namespace NzbDrone.Web
@ -54,6 +56,8 @@ namespace NzbDrone.Web
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(razor);
ModelBinders.Binders.Add(typeof(QualityTypes), new QualityTypesBinder());
RegisterGlobalFilters(GlobalFilters.Filters);
Logger.Info("Fully initialized and ready.");

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Helpers.Binders
{
public class QualityTypesBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var value = bindingContext.ValueProvider.GetValue("quality");
var quality = QualityTypes.FindById(Convert.ToInt32(value.AttemptedValue));
return quality;
}
}
}

@ -199,6 +199,7 @@
<Compile Include="App_Start\DataTablesMvc.cs" />
<Compile Include="App_Start\MiniProfiler.cs" />
<Compile Include="Controllers\SearchHistoryController.cs" />
<Compile Include="Helpers\Binders\QualityTypesBinder.cs" />
<Compile Include="Helpers\RenderActionHelper.cs" />
<Compile Include="Helpers\Validation\RequiredIfAnyAttribute.cs" />
<Compile Include="Helpers\Validation\RequiredIfAttribute.cs" />

Loading…
Cancel
Save