RootFolder removed from Series, going back to Path

pull/6/head
Mark McDowall 12 years ago
parent 75def198e4
commit 95a9a297bc

@ -29,7 +29,6 @@ namespace NzbDrone.Api.Series
Get["/{slug}"] = o => GetSeries((string)o.slug.ToString());
SharedValidator.RuleFor(s => s.RootFolderId).ValidId();
SharedValidator.RuleFor(s => s.QualityProfileId).ValidId();
PostValidator.RuleFor(s => s.Title).NotEmpty();

@ -26,11 +26,8 @@ namespace NzbDrone.Api.Series
public Int32 UtcOffset { get; set; }
public List<Core.MediaCover.MediaCover> Images { get; set; }
public String Path { get; set; }
//View & Edit
public int RootFolderId { get; set; }
public string FolderName { get; set; }
public String Path { get; set; }
public Int32 QualityProfileId { get; set; }
//Editing Only
@ -50,8 +47,6 @@ namespace NzbDrone.Api.Series
public String CleanTitle { get; set; }
public String ImdbId { get; set; }
public String TitleSlug { get; set; }
public String RootFolderPath { get; set; }
}
}

@ -144,25 +144,6 @@ namespace NzbDrone.Core.Test.Datastore
Db.All<ScheduledTask>().Single().TypeName.Should().Be("A");
Db.All<ScheduledTask>().Single().Interval.Should().Be(12);
}
[Test]
public void should_load_lazy_objects()
{
var rootFolder = Db.Insert(new RootFolders.RootFolder() { Path = "C:\test" });
var series = Builder<Series>.CreateNew()
.With(c => c.RootFolderId = rootFolder.Id)
.BuildNew();
Db.Insert(series);
Db.Single<Series>().RootFolder.Should().NotBeNull();
Db.Single<Series>().RootFolder.Value.Should().NotBeNull();
Db.Single<Series>().RootFolder.Value.Path.Should().Be(rootFolder.Path);
}
}
}

@ -33,8 +33,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
{
var fakeSeries = Builder<Series>.CreateNew()
.With(s => s.Title = "30 Rock")
.With(s => s.RootFolder = new LazyLoaded<RootFolder>(new RootFolder { Path = @"C:\Test" }))
.With(s => s.FolderName = "30 Rock")
.With(s => s.Path = @"C:\Test\30 Rock")
.With(s => s.SeasonFolder = useSeasonFolder)
.Build();

@ -4,8 +4,8 @@ using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Tags("")]
[Migration(20130324)]
public class Migration20130324 : NzbDroneMigrationBase
[Migration(1)]
public class InitialSetup : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
@ -27,8 +27,7 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Overview").AsString().Nullable()
.WithColumn("AirTime").AsString().Nullable()
.WithColumn("Images").AsString()
.WithColumn("RootFolderId").AsInt32()
.WithColumn("FolderName").AsString()
.WithColumn("Path").AsString()
.WithColumn("Monitored").AsBoolean()
.WithColumn("QualityProfileId").AsInt32()
.WithColumn("SeasonFolder").AsBoolean()
@ -83,7 +82,7 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("NzbInfoUrl").AsString().Nullable()
.WithColumn("ReleaseGroup").AsString().Nullable();
Create.TableForModel("NotificationDefinitions")
Create.TableForModel("Notifications")
.WithColumn("Name").AsString()
.WithColumn("OnGrab").AsBoolean()
.WithColumn("OnDownload").AsBoolean()
@ -95,7 +94,7 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Interval").AsInt32()
.WithColumn("LastExecution").AsDateTime();
Create.TableForModel("IndexerDefinitions")
Create.TableForModel("Indexers")
.WithColumn("Enable").AsBoolean()
.WithColumn("Name").AsString().Unique()
.WithColumn("Implementation").AsString()

@ -1,29 +0,0 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Tags("")]
[Migration(20130522)]
public class Migration20130522 : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Execute.Sql("DROP TABLE IF EXISTS NotificationDefinitions");
Rename.Table("IndexerDefinitions")
.To("Indexers");
Create.TableForModel("Notifications")
.WithColumn("Name").AsString()
.WithColumn("OnGrab").AsBoolean()
.WithColumn("OnDownload").AsBoolean()
.WithColumn("Settings").AsString()
.WithColumn("Implementation").AsString();
}
protected override void LogDbUpgrade()
{
}
}
}

@ -47,9 +47,8 @@ namespace NzbDrone.Core.Datastore
// .HasOne(h => h.Series, h => h.SeriesId);
Mapper.Entity<Series>().RegisterModel("Series")
.Ignore(s => s.Path)
.Ignore(s => s.RootFolderPath)
.Relationship()
.HasOne(s => s.RootFolder, s => s.RootFolderId)
.HasOne(s => s.QualityProfile, s => s.QualityProfileId);
Mapper.Entity<Season>().RegisterModel("Seasons");

@ -202,12 +202,11 @@
<Compile Include="Datastore\IWriteModels.cs" />
<Compile Include="Datastore\LazyList.cs" />
<Compile Include="Datastore\MappingExtensions.cs" />
<Compile Include="Datastore\Migration\Migration20130522.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationOptions.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationLogger.cs" />
<Compile Include="Datastore\Migration\Migration20130324.cs" />
<Compile Include="Datastore\Migration\001_InitialSetup.cs" />
<Compile Include="Datastore\Migration\Framework\NzbDroneMigrationBase.cs" />
<Compile Include="Datastore\MigrationType.cs" />
<Compile Include="Datastore\ModelBase.cs" />

@ -36,24 +36,9 @@ namespace NzbDrone.Core.Tv
public DateTime? CustomStartDate { get; set; }
public bool UseSceneNumbering { get; set; }
public string TitleSlug { get; set; }
public string Path { get; set; }
public int RootFolderId { get; set; }
public string FolderName { get; set; }
public LazyLoaded<RootFolder> RootFolder { get; set; }
//Todo: Use this to auto link RootFolder and Folder (using the proper path separator)
public string Path
{
get
{
if (RootFolder == null || RootFolder.Value == null || String.IsNullOrWhiteSpace(RootFolder.Value.Path))
{
return null;
}
return System.IO.Path.Combine(RootFolder.Value.Path, FolderName);
}
}
public string RootFolderPath { get; set; }
public DateTime? FirstAired { get; set; }
public LazyLoaded<QualityProfile> QualityProfile { get; set; }

@ -101,10 +101,11 @@ namespace NzbDrone.Core.Tv
{
Ensure.That(() => newSeries).IsNotNull();
if (String.IsNullOrWhiteSpace(newSeries.FolderName))
if (String.IsNullOrWhiteSpace(newSeries.Path))
{
newSeries.FolderName = FileNameBuilder.CleanFilename(newSeries.Title);
newSeries.RootFolder = _rootFolderService.Get(newSeries.RootFolderId);
var folderName = FileNameBuilder.CleanFilename(newSeries.Title);
newSeries.Path = Path.Combine(newSeries.RootFolderPath, folderName);
_diskProvider.CreateFolder(newSeries.Path);
}

@ -38,16 +38,13 @@ namespace NzbDrone.Integration.Test
{
var series = Series.Lookup("archer").First();
var rootFolder = RootFolders.Post(new RootFolderResource { Path = Directory.GetCurrentDirectory() });
series.RootFolderId = rootFolder.Id;
series.QualityProfileId = 1;
series.Path = @"C:\Test\Archer";
series = Series.Post(series);
Series.All().Should().HaveCount(1);
Series.Get(series.Id).Should().NotBeNull();
Series.Get(series.TitleSlug).Should().NotBeNull();

@ -29,12 +29,10 @@ define([
var self = this;
var quality = this.ui.qualityProfile.val();
var rootFolderId = this.options.rootFolder.id;
var folderName = this.options.folder.name;
var path = this.options.folder.path;
this.model.set('qualityProfileId', quality);
this.model.set('rootFolderId', rootFolderId);
this.model.set('folderName', folderName);
this.model.set('path', path);
this.model.save(undefined, {
success: function () {

@ -24,10 +24,10 @@ define(['app', 'Series/SeriesCollection'], function (app) {
icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled');
var quality = this.ui.qualityProfile.val();
var rootFolderId = this.ui.rootFolder.val();
var rootFolderPath = this.ui.rootFolder.children(':selected').text();
this.model.set('qualityProfileId', quality);
this.model.set('rootFolderId', rootFolderId);
this.model.set('rootFolderPath', rootFolderPath);
var self = this;

Loading…
Cancel
Save