1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

RootFolder removed from Series, going back to Path

This commit is contained in:
Mark McDowall 2013-05-23 21:10:56 -07:00
parent 75def198e4
commit 95a9a297bc
14 changed files with 21 additions and 98 deletions

View File

@ -29,7 +29,6 @@ public SeriesModule(ISeriesService seriesService, ISeriesStatisticsService serie
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();

View File

@ -26,11 +26,8 @@ public class SeriesResource : RestResource
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 @@ public class SeriesResource : RestResource
public String CleanTitle { get; set; }
public String ImdbId { get; set; }
public String TitleSlug { get; set; }
public String RootFolderPath { get; set; }
}
}

View File

@ -144,25 +144,6 @@ public void set_fields_should_only_update_selected_filed()
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);
}
}
}

View File

@ -33,8 +33,7 @@ public void CalculateFilePath_SeasonFolder_SingleNumber(string filename, int sea
{
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();

View File

@ -4,8 +4,8 @@
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 @@ protected override void MainDbUpgrade()
.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 @@ protected override void MainDbUpgrade()
.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 @@ protected override void MainDbUpgrade()
.WithColumn("Interval").AsInt32()
.WithColumn("LastExecution").AsDateTime();
Create.TableForModel("IndexerDefinitions")
Create.TableForModel("Indexers")
.WithColumn("Enable").AsBoolean()
.WithColumn("Name").AsString().Unique()
.WithColumn("Implementation").AsString()

View File

@ -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()
{
}
}
}

View File

@ -47,9 +47,8 @@ public static void Map()
// .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");

View File

@ -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" />

View File

@ -36,24 +36,9 @@ public Series()
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; }

View File

@ -101,10 +101,11 @@ public Series AddSeries(Series newSeries)
{
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);
}

View File

@ -38,16 +38,13 @@ public void should_be_able_to_add_and_delete_series()
{
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();

View File

@ -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 () {

View File

@ -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;