commit
81794c3200
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using FluentMigrator;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
[Category("DbMigrationTest")]
|
||||
[Category("DbTest")]
|
||||
public abstract class MigrationTest<TMigration> : DbTest where TMigration : MigrationBase
|
||||
{
|
||||
protected override TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
|
||||
{
|
||||
var factory = Mocker.Resolve<DbFactory>();
|
||||
|
||||
var database = factory.Create(MigrationType, m =>
|
||||
{
|
||||
if (m.GetType() == typeof(TMigration))
|
||||
{
|
||||
beforeMigration(m);
|
||||
}
|
||||
});
|
||||
|
||||
var testDb = new TestDatabase(database);
|
||||
Mocker.SetConstant(database);
|
||||
|
||||
return testDb;
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public override void SetupDb()
|
||||
{
|
||||
SetupContainer();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
using NLog;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
|
||||
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||
{
|
||||
public class ProtocolSpecification : IDecisionEngineSpecification
|
||||
{
|
||||
private readonly IPendingReleaseService _pendingReleaseService;
|
||||
private readonly IQualityUpgradableSpecification _qualityUpgradableSpecification;
|
||||
private readonly IDelayProfileService _delayProfileService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public ProtocolSpecification(IDelayProfileService delayProfileService,
|
||||
Logger logger)
|
||||
{
|
||||
_delayProfileService = delayProfileService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public RejectionType Type { get { return RejectionType.Temporary; } }
|
||||
|
||||
public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
var delayProfile = _delayProfileService.BestForTags(subject.Series.Tags);
|
||||
|
||||
if (subject.Release.DownloadProtocol == DownloadProtocol.Usenet && !delayProfile.EnableUsenet)
|
||||
{
|
||||
_logger.Debug("[{0}] Usenet is not enabled for this series", subject.Release.Title);
|
||||
return Decision.Reject("Usenet is not enabled for this series");
|
||||
}
|
||||
|
||||
if (subject.Release.DownloadProtocol == DownloadProtocol.Torrent && !delayProfile.EnableTorrent)
|
||||
{
|
||||
_logger.Debug("[{0}] Torrent is not enabled for this series", subject.Release.Title);
|
||||
return Decision.Reject("Torrent is not enabled for this series");
|
||||
}
|
||||
|
||||
return Decision.Accept();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
function () {
|
||||
|
||||
return function () {
|
||||
|
||||
this.prototype.appendHtml = function(collectionView, itemView, index) {
|
||||
var childrenContainer = collectionView.itemViewContainer ? collectionView.$(collectionView.itemViewContainer) : collectionView.$el;
|
||||
var collection = collectionView.collection;
|
||||
|
||||
// If the index of the model is at the end of the collection append, else insert at proper index
|
||||
if (index >= collection.size() - 1) {
|
||||
childrenContainer.append(itemView.el);
|
||||
} else {
|
||||
var previousModel = collection.at(index + 1);
|
||||
var previousView = this.children.findByModel(previousModel);
|
||||
|
||||
if (previousView) {
|
||||
previousView.$el.before(itemView.$el);
|
||||
}
|
||||
|
||||
else {
|
||||
childrenContainer.append(itemView.el);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
);
|
@ -1,12 +1,12 @@
|
||||
<span class="col-sm-2">
|
||||
<div>{{host}}</div>
|
||||
</span>
|
||||
<span class="col-sm-5">
|
||||
<div>{{remotePath}}</div>
|
||||
</span>
|
||||
<span class="col-sm-4">
|
||||
<div>{{localPath}}</div>
|
||||
</span>
|
||||
<span class="col-sm-1">
|
||||
<div class="col-sm-2">
|
||||
{{host}}
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
{{remotePath}}
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
{{localPath}}
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<div class="pull-right"><i class="icon-nd-edit x-edit" title="" data-original-title="Edit Mapping"></i></div>
|
||||
</span>
|
||||
</div>
|
@ -1,12 +1,12 @@
|
||||
<span class="col-sm-4">
|
||||
<div class="col-sm-4">
|
||||
{{genericTagDisplay required 'label label-success'}}
|
||||
</span>
|
||||
<span class="col-sm-4">
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
{{genericTagDisplay ignored 'label label-danger'}}
|
||||
</span>
|
||||
<span class="col-sm-3">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
{{tagDisplay tags}}
|
||||
</span>
|
||||
<span class="col-sm-1">
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<div class="pull-right"><i class="icon-nd-edit x-edit" title="" data-original-title="Edit"></i></div>
|
||||
</span>
|
||||
</div>
|
@ -0,0 +1,57 @@
|
||||
<div class="col-sm-2">
|
||||
{{#if enableUsenet}}
|
||||
{{#if enableTorrent}}
|
||||
{{#if_eq preferredProtocol compare="usenet"}}
|
||||
Prefer Usenet
|
||||
{{else}}
|
||||
Prefer Torrent
|
||||
{{/if_eq}}
|
||||
{{else}}
|
||||
Only Usenet
|
||||
{{/if}}
|
||||
{{else}}
|
||||
Only Torrent
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
{{#if enableUsenet}}
|
||||
{{#if_eq usenetDelay compare="0"}}
|
||||
No delay
|
||||
{{else}}
|
||||
{{#if_eq usenetDelay compare="1"}}
|
||||
1 minute
|
||||
{{else}}
|
||||
{{usenetDelay}} minutes
|
||||
{{/if_eq}}
|
||||
{{/if_eq}}
|
||||
{{else}}
|
||||
-
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
{{#if enableTorrent}}
|
||||
{{#if_eq torrentDelay compare="0"}}
|
||||
No delay
|
||||
{{else}}
|
||||
{{#if_eq torrentDelay compare="1"}}
|
||||
1 minute
|
||||
{{else}}
|
||||
{{torrentDelay}} minutes
|
||||
{{/if_eq}}
|
||||
{{/if_eq}}
|
||||
{{else}}
|
||||
-
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
{{tagDisplay tags}}
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<div class="pull-right">
|
||||
{{#unless_eq id compare="1"}}
|
||||
<i class="drag-handle icon-reorder x-drag-handle" title="Reorder"/>
|
||||
{{/unless_eq}}
|
||||
|
||||
<i class="icon-nd-edit x-edit" title="Edit"></i>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,24 @@
|
||||
<fieldset class="advanced-setting">
|
||||
<legend>Delay Profiles</legend>
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="rule-setting-list">
|
||||
<div class="rule-setting-header x-header hidden-xs">
|
||||
<div class="row">
|
||||
<span class="col-sm-2">Protocol</span>
|
||||
<span class="col-sm-2">Usenet Delay</span>
|
||||
<span class="col-sm-2">Torrent Delay</span>
|
||||
<span class="col-sm-5">Tags</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rows x-rows"></div>
|
||||
<div class="rule-setting-footer">
|
||||
<div class="pull-right">
|
||||
<span class="add-rule-setting-mapping">
|
||||
<i class="icon-nd-add x-add" title="Add new delay profile" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'vent',
|
||||
'marionette'
|
||||
], function (vent, Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/Profile/Delay/Delete/DelayProfileDeleteViewTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-confirm-delete': '_delete'
|
||||
},
|
||||
|
||||
_delete: function () {
|
||||
var collection = this.model.collection;
|
||||
|
||||
this.model.destroy({
|
||||
wait : true,
|
||||
success: function () {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,13 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>Delete Delay Profile</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Are you sure you want to delete this delay profile?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal">cancel</button>
|
||||
<button class="btn btn-danger x-confirm-delete">delete</button>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,80 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" aria-hidden="true" data-dismiss="modal">×</button>
|
||||
{{#if id}}
|
||||
<h3>Edit - Delay Profile</h3>
|
||||
{{else}}
|
||||
<h3>Add - Delay Profile</h3>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="modal-body indexer-modal">
|
||||
<div class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">Protocol</label>
|
||||
|
||||
<div class="col-sm-1 col-sm-push-5 help-inline">
|
||||
<i class="icon-nd-form-info" title="Choose which protocol(s) to use and which one is preferred when choosing between otherwise equal releases" />
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5 col-sm-pull-1">
|
||||
<select class="form-control x-protocol">
|
||||
<option value="preferUsenet">Prefer Usenet</option>
|
||||
<option value="preferTorrent">Prefer Torrent</option>
|
||||
<option value="onlyUsenet">Only Usenet</option>
|
||||
<option value="onlyTorrent">Only Torrent</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group x-usenet-delay">
|
||||
<label class="col-sm-3 control-label">Usenet Delay</label>
|
||||
|
||||
<div class="col-sm-1 col-sm-push-5 help-inline">
|
||||
<i class="icon-nd-form-info" title="Delay in minutes to wait before grabbing a release from Usenet" />
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5 col-sm-pull-1">
|
||||
<input type="number" class="form-control" name="usenetDelay"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group x-torrent-delay">
|
||||
<label class="col-sm-3 control-label">Torrent Delay</label>
|
||||
|
||||
<div class="col-sm-1 col-sm-push-5 help-inline">
|
||||
<i class="icon-nd-form-info" title="Delay in minutes to wait before grabbing a torrent" />
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5 col-sm-pull-1">
|
||||
<input type="number" class="form-control" name="torrentDelay"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if_eq id compare="1"}}
|
||||
<div class="alert alert-info" role="alert">This is the default profile. It applies to all series that don't have an explicit profile.</div>
|
||||
{{else}}
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">Tags</label>
|
||||
|
||||
<div class="col-sm-1 col-sm-push-5 help-inline">
|
||||
<i class="icon-nd-form-info" title="One or more tags to apply these rules to matching series" />
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5 col-sm-pull-1">
|
||||
<input type="text" class="form-control x-tags">
|
||||
</div>
|
||||
</div>
|
||||
{{/if_eq}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{{#if id}}
|
||||
{{#if_gt id compare="1"}}
|
||||
<button class="btn btn-danger pull-left x-delete">delete</button>
|
||||
{{/if_gt}}
|
||||
{{/if}}
|
||||
<span class="indicator x-indicator"><i class="icon-spinner icon-spin"></i></span>
|
||||
<button class="btn" data-dismiss="modal">cancel</button>
|
||||
<button class="btn btn-primary x-save">save</button>
|
||||
</div>
|
||||
</div>
|
@ -1,3 +1,5 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12" id="profile"/>
|
||||
|
||||
<div class="col-md-12 delay-profile-region" id="delay-profile"/>
|
||||
</div>
|
||||
|
Loading…
Reference in new issue