Added: Tags support to NetImport (Lists) (#3127)

* Add tags support to NetImport (Lists)

* Keep indentation consistent with current code

* Initialize set of empty tags

* Add tags from list to movie

* Prevent tags used by lists from being removed
This commit is contained in:
Ricardo Amaral 2019-05-02 11:57:40 +01:00 committed by Leonardo Galli
parent 84fab25af7
commit 7a43bf3f60
10 changed files with 47 additions and 4 deletions

View File

@ -24,6 +24,7 @@ namespace NzbDrone.Api.NetImport
resource.RootFolderPath = definition.RootFolderPath;
resource.ShouldMonitor = definition.ShouldMonitor;
resource.MinimumAvailability = definition.MinimumAvailability;
resource.Tags = definition.Tags;
}
protected override void MapToModel(NetImportDefinition definition, NetImportResource resource)
@ -36,6 +37,7 @@ namespace NzbDrone.Api.NetImport
definition.RootFolderPath = resource.RootFolderPath;
definition.ShouldMonitor = resource.ShouldMonitor;
definition.MinimumAvailability = resource.MinimumAvailability;
definition.Tags = resource.Tags;
}
protected override void Validate(NetImportDefinition definition, bool includeWarnings)

View File

@ -1,3 +1,4 @@
using System.Collections.Generic;
using NzbDrone.Core.Movies;
namespace NzbDrone.Api.NetImport
@ -10,5 +11,6 @@ namespace NzbDrone.Api.NetImport
public string RootFolderPath { get; set; }
public int ProfileId { get; set; }
public MovieStatusType MinimumAvailability { get; set; }
public HashSet<int> Tags { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(151)]
public class add_tags_to_net_import : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("NetImport")
.AddColumn("Tags").AsString().Nullable();
Execute.Sql("UPDATE NetImport SET Tags = '[]'");
}
}
}

View File

@ -20,7 +20,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
using (var mapper = _database.GetDataMapper())
{
var usedTags = new[] {"Movies", "Notifications", "DelayProfiles", "Restrictions"}
var usedTags = new[] {"Movies", "Notifications", "DelayProfiles", "Restrictions", "NetImport"}
.SelectMany(v => GetUsedTags(v, mapper))
.Distinct()
.ToArray();

View File

@ -701,6 +701,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
newMovie.Monitored = movie.Monitored;
newMovie.MovieFile = movie.MovieFile;
newMovie.MinimumAvailability = movie.MinimumAvailability;
newMovie.Tags = movie.Tags;
return newMovie;
}

View File

@ -118,6 +118,7 @@ namespace NzbDrone.Core.NetImport
m.ProfileId = ((NetImportDefinition) Definition).ProfileId;
m.Monitored = ((NetImportDefinition) Definition).ShouldMonitor;
m.MinimumAvailability = ((NetImportDefinition) Definition).MinimumAvailability;
m.Tags = ((NetImportDefinition) Definition).Tags;
return m;
}).ToList();
}
@ -170,6 +171,5 @@ namespace NzbDrone.Core.NetImport
return null;
}
}
}

View File

@ -1,4 +1,5 @@
using Marr.Data;
using System.Collections.Generic;
using Marr.Data;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Movies;
@ -7,6 +8,11 @@ namespace NzbDrone.Core.NetImport
{
public class NetImportDefinition : ProviderDefinition
{
public NetImportDefinition()
{
Tags = new HashSet<int>();
}
public bool Enabled { get; set; }
public bool EnableAuto { get; set; }
public bool ShouldMonitor { get; set; }
@ -15,5 +21,6 @@ namespace NzbDrone.Core.NetImport
public LazyLoaded<Profile> Profile { get; set; }
public string RootFolderPath { get; set; }
public override bool Enable => Enabled;
public HashSet<int> Tags { get; set; }
}
}

View File

@ -146,6 +146,7 @@
<Compile Include="Datastore\Migration\144_add_cookies_to_indexer_status.cs" />
<Compile Include="Datastore\Migration\149_convert_regex_required_tags.cs" />
<Compile Include="Datastore\Migration\150_fix_format_tags_double_underscore.cs" />
<Compile Include="Datastore\Migration\151_add_tags_to_net_import.cs" />
<Compile Include="DecisionEngine\Specifications\CustomFormatAllowedByProfileSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\MaximumSizeSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\RequiredIndexerFlagsSpecification.cs" />
@ -1335,4 +1336,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@ -22,6 +22,7 @@ var view = Marionette.ItemView.extend({
profile : '.x-profile',
minimumAvailability : '.x-minimumavailability',
rootFolder : '.x-root-folder',
tags : '.x-tags'
},
events : {
@ -53,6 +54,10 @@ var view = Marionette.ItemView.extend({
this.ui.rootFolder.val(defaultRoot);
}
}
this.ui.tags.tagInput({
model : this.model,
property : 'tags'
});
},
_onBeforeSave : function() {

View File

@ -101,6 +101,14 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Tags</label>
<div class="col-sm-5">
<input type="text" class="form-control x-tags">
</div>
</div>
{{formBuilder}}
</div>
</div>