enabled and indexerId placeholder

This commit is contained in:
Jacob 2019-06-10 23:33:13 -05:00 committed by Taloth Saldono
parent 31cff12e43
commit 5cb1896af0
3 changed files with 39 additions and 29 deletions

View File

@ -30,7 +30,7 @@ function EditReleaseProfileModalContent(props) {
const { const {
id, id,
enableProfile, enabled,
required, required,
ignored, ignored,
preferred, preferred,
@ -52,9 +52,9 @@ function EditReleaseProfileModalContent(props) {
<FormInputGroup <FormInputGroup
type={inputTypes.CHECK} type={inputTypes.CHECK}
name="enableProfile" name="enabled"
helpText="Check to enable release profile" helpText="Check to enable release profile"
{...enableProfile} {...enabled}
onChange={onInputChange} onChange={onInputChange}
/> />
</FormGroup> </FormGroup>

View File

@ -8,10 +8,12 @@ import { setReleaseProfileValue, saveReleaseProfile } from 'Store/Actions/settin
import EditReleaseProfileModalContent from './EditReleaseProfileModalContent'; import EditReleaseProfileModalContent from './EditReleaseProfileModalContent';
const newReleaseProfile = { const newReleaseProfile = {
enabled: false,
required: '', required: '',
ignored: '', ignored: '',
preferred: [], preferred: [],
includePreferredWhenRenaming: false, includePreferredWhenRenaming: false,
indexer: 0,
tags: [] tags: []
}; };

View File

@ -30,37 +30,45 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger.Debug("Checking if release meets restrictions: {0}", subject); _logger.Debug("Checking if release meets restrictions: {0}", subject);
var title = subject.Release.Title; var title = subject.Release.Title;
var restrictions = _releaseProfileService.AllForTags(subject.Series.Tags); List<ReleaseProfile> restrictions = _releaseProfileService.AllForTags(subject.Series.Tags);
var required = restrictions.Where(r => r.Required.IsNotNullOrWhiteSpace()); foreach (ReleaseProfile restriction in restrictions)
var ignored = restrictions.Where(r => r.Ignored.IsNotNullOrWhiteSpace());
foreach (var r in required)
{ {
var requiredTerms = r.Required.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList(); // TODO: attach Enabled and IndexerId fields to restriction
/*if (!restriction.Enabled || restriction.IndexerId != subject.Release.IndexerId)
var foundTerms = ContainsAny(requiredTerms, title);
if (foundTerms.Empty())
{ {
var terms = string.Join(", ", requiredTerms); continue;
_logger.Debug("[{0}] does not contain one of the required terms: {1}", title, terms); }*/
return Decision.Reject("Does not contain one of the required terms: {0}", terms);
var required = restrictions.Where(r => r.Required.IsNotNullOrWhiteSpace());
var ignored = restrictions.Where(r => r.Ignored.IsNotNullOrWhiteSpace());
foreach (var r in required)
{
var requiredTerms = r.Required.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
var foundTerms = ContainsAny(requiredTerms, title);
if (foundTerms.Empty())
{
var terms = string.Join(", ", requiredTerms);
_logger.Debug("[{0}] does not contain one of the required terms: {1}", title, terms);
return Decision.Reject("Does not contain one of the required terms: {0}", terms);
}
}
foreach (var r in ignored)
{
var ignoredTerms = r.Ignored.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
var foundTerms = ContainsAny(ignoredTerms, title);
if (foundTerms.Any())
{
var terms = string.Join(", ", foundTerms);
_logger.Debug("[{0}] contains these ignored terms: {1}", title, terms);
return Decision.Reject("Contains these ignored terms: {0}", terms);
}
} }
} }
foreach (var r in ignored)
{
var ignoredTerms = r.Ignored.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
var foundTerms = ContainsAny(ignoredTerms, title);
if (foundTerms.Any())
{
var terms = string.Join(", ", foundTerms);
_logger.Debug("[{0}] contains these ignored terms: {1}", title, terms);
return Decision.Reject("Contains these ignored terms: {0}", terms);
}
}
_logger.Debug("[{0}] No restrictions apply, allowing", subject); _logger.Debug("[{0}] No restrictions apply, allowing", subject);
return Decision.Accept(); return Decision.Accept();
} }