From 23acb3a9ae438ba59aab8f55f9ffa359fb622faa Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 11 Apr 2013 00:52:38 -0700 Subject: [PATCH] Add series uses all available information --- .../Datastore/Migration/Migration20130324.cs | 1 - NzbDrone.Core/Datastore/TableMapping.cs | 1 + NzbDrone.Core/Tv/SeriesService.cs | 8 +++--- UI/AddSeries/Existing/ImportSeriesView.js | 27 +++++++++---------- UI/AddSeries/Existing/UnmappedFolderModel.js | 2 +- UI/AddSeries/New/AddNewSeriesView.js | 2 -- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs b/NzbDrone.Core/Datastore/Migration/Migration20130324.cs index 5807b0ac4..fe035ac91 100644 --- a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs +++ b/NzbDrone.Core/Datastore/Migration/Migration20130324.cs @@ -29,7 +29,6 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Images").AsString() .WithColumn("RootFolderId").AsInt32() .WithColumn("Folder").AsString().NotNullable() - .WithColumn("Path").AsString().Unique() .WithColumn("Monitored").AsBoolean() .WithColumn("QualityProfileId").AsInt32() .WithColumn("SeasonFolder").AsBoolean() diff --git a/NzbDrone.Core/Datastore/TableMapping.cs b/NzbDrone.Core/Datastore/TableMapping.cs index dc6f5baf3..0c853ae97 100644 --- a/NzbDrone.Core/Datastore/TableMapping.cs +++ b/NzbDrone.Core/Datastore/TableMapping.cs @@ -42,6 +42,7 @@ namespace NzbDrone.Core.Datastore .HasOne(h => h.Episode, h => h.EpisodeId); Mapper.Entity().RegisterModel("Series") + .Ignore(s => s.Path) .HasOne(s => s.RootFolder, s => s.RootFolderId); Mapper.Entity().RegisterModel("Seasons"); diff --git a/NzbDrone.Core/Tv/SeriesService.cs b/NzbDrone.Core/Tv/SeriesService.cs index e0d10b523..66f93b9a1 100644 --- a/NzbDrone.Core/Tv/SeriesService.cs +++ b/NzbDrone.Core/Tv/SeriesService.cs @@ -8,6 +8,7 @@ using NzbDrone.Common; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Eventing; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Datastore; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Model; using NzbDrone.Core.Organizer; @@ -34,17 +35,19 @@ namespace NzbDrone.Core.Tv private readonly IConfigService _configService; private readonly IProvideSeriesInfo _seriesInfoProxy; private readonly IEventAggregator _eventAggregator; + private readonly IBasicRepository _rootFolderRepository; private readonly DiskProvider _diskProvider; private readonly Logger _logger; public SeriesService(ISeriesRepository seriesRepository, IConfigService configServiceService, IProvideSeriesInfo seriesInfoProxy, IEventAggregator eventAggregator, - DiskProvider diskProvider, Logger logger) + IBasicRepository rootFolderRepository, DiskProvider diskProvider, Logger logger) { _seriesRepository = seriesRepository; _configService = configServiceService; _seriesInfoProxy = seriesInfoProxy; _eventAggregator = eventAggregator; + _rootFolderRepository = rootFolderRepository; _diskProvider = diskProvider; _logger = logger; } @@ -88,11 +91,10 @@ namespace NzbDrone.Core.Tv { Ensure.That(() => newSeries).IsNotNull(); - //Todo: If Path is null we need to create the path if(String.IsNullOrWhiteSpace(newSeries.Folder)) { newSeries.Folder = FileNameBuilder.CleanFilename(newSeries.Title); - _diskProvider.CreateDirectory(Path.Combine(newSeries.RootFolder.Value.Path, newSeries.Folder)); + _diskProvider.CreateDirectory(Path.Combine(_rootFolderRepository.Get(newSeries.RootFolderId).Path, newSeries.Folder)); } _logger.Info("Adding Series [{0}] Path: [{1}]", newSeries.Title, newSeries.Path); diff --git a/UI/AddSeries/Existing/ImportSeriesView.js b/UI/AddSeries/Existing/ImportSeriesView.js index cc77ceb0d..13cb74275 100644 --- a/UI/AddSeries/Existing/ImportSeriesView.js +++ b/UI/AddSeries/Existing/ImportSeriesView.js @@ -13,27 +13,23 @@ define([ var self = this; - var seriesId = this.model.get('tvDbId'); - var title = this.model.get('title'); var quality = this.options.qualityProfile.val(); - var path = this.options.folder.path; + var rootFolderId = this.options.rootFolder.id; + var folder = this.options.folder.name; - var model = new NzbDrone.Series.SeriesModel({ - tvDbId : seriesId, - title : title, - qualityProfileId: quality, - path : path - }); + this.model.set('qualityProfileId', quality); + this.model.set('rootFolderId', rootFolderId); + this.model.set('folder', folder); var seriesCollection = new NzbDrone.Series.SeriesCollection(); - seriesCollection.add(model); + seriesCollection.add(this.model); - model.save(undefined, { + this.model.save(undefined, { success: function () { var notificationModel = new NzbDrone.Shared.NotificationModel({ - tvDbId : seriesId, + tvDbId : self.model.get('tvDbId'), title : 'Added', - message: title, + message: self.model.get('title'), level : 'success' }); @@ -52,7 +48,7 @@ define([ events: { 'click .x-btn-search': 'search', - 'keydown .x-txt-search': 'keydown' + 'keydown .x-txt-search': 'keyDown' }, ui: { @@ -88,7 +84,8 @@ define([ }); }, - keydown: function (e) { + keyDown: function (e) { + //Check for enter being pressed var code = (e.keyCode ? e.keyCode : e.which); if(code === 13) { this.search(); diff --git a/UI/AddSeries/Existing/UnmappedFolderModel.js b/UI/AddSeries/Existing/UnmappedFolderModel.js index d6719d6ee..107c508bb 100644 --- a/UI/AddSeries/Existing/UnmappedFolderModel.js +++ b/UI/AddSeries/Existing/UnmappedFolderModel.js @@ -16,7 +16,7 @@ define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfil importItems: function (rootFolderModel) { this.reset(); - var rootFolder = rootFolderModel.get('path'); + var rootFolder = rootFolderModel;//.get('path'); _.each(rootFolderModel.get('unmappedFolders'), function (folder) { this.push(new NzbDrone.AddSeries.Existing.UnmappedFolderModel({ rootFolder: rootFolder, folder: folder})); diff --git a/UI/AddSeries/New/AddNewSeriesView.js b/UI/AddSeries/New/AddNewSeriesView.js index c5d5a2262..f7a6fc728 100644 --- a/UI/AddSeries/New/AddNewSeriesView.js +++ b/UI/AddSeries/New/AddNewSeriesView.js @@ -11,11 +11,9 @@ define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'AddSeries/New/Sear regions: { searchResult: '#search-result' }, - collection: new NzbDrone.Series.SeriesCollection(), onRender: function () { - console.log('binding auto complete'); var self = this; this.ui.seriesSearch