mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-25 15:22:42 +00:00
Fixed: Last UI reference to nameSlug, remove from model
This commit is contained in:
parent
afc4aeb25f
commit
b0070e0229
17 changed files with 6 additions and 279 deletions
|
@ -66,7 +66,6 @@ class AddNewArtistSearchResult extends Component {
|
|||
const {
|
||||
foreignArtistId,
|
||||
artistName,
|
||||
nameSlug,
|
||||
year,
|
||||
disambiguation,
|
||||
artistType,
|
||||
|
@ -79,7 +78,7 @@ class AddNewArtistSearchResult extends Component {
|
|||
isSmallScreen
|
||||
} = this.props;
|
||||
|
||||
const linkProps = isExistingArtist ? { to: `/artist/${nameSlug}` } : { onPress: this.onPress };
|
||||
const linkProps = isExistingArtist ? { to: `/artist/${foreignArtistId}` } : { onPress: this.onPress };
|
||||
let albums = '1 Album';
|
||||
|
||||
if (albumCount > 1) {
|
||||
|
@ -193,7 +192,6 @@ class AddNewArtistSearchResult extends Component {
|
|||
AddNewArtistSearchResult.propTypes = {
|
||||
foreignArtistId: PropTypes.string.isRequired,
|
||||
artistName: PropTypes.string.isRequired,
|
||||
nameSlug: PropTypes.string.isRequired,
|
||||
year: PropTypes.number,
|
||||
disambiguation: PropTypes.string,
|
||||
artistType: PropTypes.string,
|
||||
|
|
|
@ -19,7 +19,6 @@ class AlbumStudioRow extends Component {
|
|||
const {
|
||||
artistId,
|
||||
status,
|
||||
nameSlug,
|
||||
foreignArtistId,
|
||||
artistName,
|
||||
monitored,
|
||||
|
@ -84,7 +83,6 @@ class AlbumStudioRow extends Component {
|
|||
AlbumStudioRow.propTypes = {
|
||||
artistId: PropTypes.number.isRequired,
|
||||
status: PropTypes.string.isRequired,
|
||||
nameSlug: PropTypes.string.isRequired,
|
||||
foreignArtistId: PropTypes.string.isRequired,
|
||||
artistName: PropTypes.string.isRequired,
|
||||
monitored: PropTypes.bool.isRequired,
|
||||
|
|
|
@ -20,7 +20,6 @@ function createMapStateToProps() {
|
|||
...artist,
|
||||
artistId: artist.id,
|
||||
artistName: artist.artistName,
|
||||
nameSlug: artist.nameSlug,
|
||||
monitored: artist.monitored,
|
||||
status: artist.status,
|
||||
isSaving: artist.isSaving,
|
||||
|
|
|
@ -66,7 +66,6 @@ class ArtistIndexRow extends Component {
|
|||
monitored,
|
||||
status,
|
||||
artistName,
|
||||
nameSlug,
|
||||
foreignArtistId,
|
||||
artistType,
|
||||
qualityProfile,
|
||||
|
@ -79,7 +78,6 @@ class ArtistIndexRow extends Component {
|
|||
trackCount,
|
||||
trackFileCount,
|
||||
totalTrackCount,
|
||||
latestAlbum,
|
||||
path,
|
||||
sizeOnDisk,
|
||||
tags,
|
||||
|
@ -361,7 +359,6 @@ ArtistIndexRow.propTypes = {
|
|||
monitored: PropTypes.bool.isRequired,
|
||||
status: PropTypes.string.isRequired,
|
||||
artistName: PropTypes.string.isRequired,
|
||||
nameSlug: PropTypes.string.isRequired,
|
||||
foreignArtistId: PropTypes.string.isRequired,
|
||||
artistType: PropTypes.string,
|
||||
qualityProfile: PropTypes.object.isRequired,
|
||||
|
|
|
@ -1,126 +0,0 @@
|
|||
import React from 'react';
|
||||
import getProgressBarKind from 'Utilities/Artist/getProgressBarKind';
|
||||
import ProgressBar from 'Components/ProgressBar';
|
||||
import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell';
|
||||
import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector';
|
||||
import QualityProfileNameConnector from 'Settings/Profiles/Quality/QualityProfileNameConnector';
|
||||
import ArtistNameLink from 'Artist/ArtistNameLink';
|
||||
import ArtistIndexItemConnector from 'Artist/Index/ArtistIndexItemConnector';
|
||||
import ArtistIndexActionsCell from './ArtistIndexActionsCell';
|
||||
import ArtistStatusCell from './ArtistStatusCell';
|
||||
|
||||
export default function artistIndexCellRenderers(cellProps) {
|
||||
const {
|
||||
cellKey,
|
||||
dataKey,
|
||||
rowData,
|
||||
...otherProps
|
||||
} = cellProps;
|
||||
|
||||
const {
|
||||
id,
|
||||
monitored,
|
||||
status,
|
||||
name,
|
||||
nameSlug,
|
||||
foreignArtistId,
|
||||
qualityProfileId,
|
||||
nextAiring,
|
||||
previousAiring,
|
||||
albumCount,
|
||||
trackCount,
|
||||
trackFileCount
|
||||
} = rowData;
|
||||
|
||||
const progress = trackCount ? trackFileCount / trackCount * 100 : 100;
|
||||
|
||||
if (dataKey === 'status') {
|
||||
return (
|
||||
<ArtistStatusCell
|
||||
key={cellKey}
|
||||
monitored={monitored}
|
||||
status={status}
|
||||
component={VirtualTableRowCell}
|
||||
{...otherProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (dataKey === 'sortName') {
|
||||
return (
|
||||
<VirtualTableRowCell
|
||||
key={cellKey}
|
||||
{...otherProps}
|
||||
>
|
||||
<ArtistNameLink
|
||||
foreignArtistId={foreignArtistId}
|
||||
name={name}
|
||||
/>
|
||||
</VirtualTableRowCell>
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
if (dataKey === 'qualityProfileId') {
|
||||
return (
|
||||
<VirtualTableRowCell
|
||||
key={cellKey}
|
||||
{...otherProps}
|
||||
>
|
||||
<QualityProfileNameConnector
|
||||
qualityProfileId={qualityProfileId}
|
||||
/>
|
||||
</VirtualTableRowCell>
|
||||
);
|
||||
}
|
||||
|
||||
if (dataKey === 'nextAiring') {
|
||||
return (
|
||||
<RelativeDateCellConnector
|
||||
key={cellKey}
|
||||
date={nextAiring}
|
||||
component={VirtualTableRowCell}
|
||||
{...otherProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (dataKey === 'albumCount') {
|
||||
return (
|
||||
<VirtualTableRowCell
|
||||
key={cellKey}
|
||||
{...otherProps}
|
||||
>
|
||||
{albumCount}
|
||||
</VirtualTableRowCell>
|
||||
);
|
||||
}
|
||||
|
||||
if (dataKey === 'trackProgress') {
|
||||
return (
|
||||
<VirtualTableRowCell
|
||||
key={cellKey}
|
||||
{...otherProps}
|
||||
>
|
||||
<ProgressBar
|
||||
progress={progress}
|
||||
kind={getProgressBarKind(status, monitored, progress)}
|
||||
showText={true}
|
||||
text={`${trackFileCount} / ${trackCount}`}
|
||||
width={125}
|
||||
/>
|
||||
</VirtualTableRowCell>
|
||||
);
|
||||
}
|
||||
|
||||
if (dataKey === 'actions') {
|
||||
return (
|
||||
<ArtistIndexItemConnector
|
||||
key={cellKey}
|
||||
component={ArtistIndexActionsCell}
|
||||
id={id}
|
||||
{...otherProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -63,7 +63,6 @@ public class ArtistResource : RestResource
|
|||
public DateTime Added { get; set; }
|
||||
public AddArtistOptions AddOptions { get; set; }
|
||||
public Ratings Ratings { get; set; }
|
||||
public string NameSlug { get; set; }
|
||||
|
||||
//TODO: Add series statistics as a property of the series (instead of individual properties)
|
||||
}
|
||||
|
@ -102,7 +101,6 @@ public static ArtistResource ToResource(this NzbDrone.Core.Music.Artist model)
|
|||
|
||||
CleanName = model.CleanName,
|
||||
ForeignArtistId = model.ForeignArtistId,
|
||||
NameSlug = model.NameSlug,
|
||||
RootFolderPath = model.RootFolderPath,
|
||||
Genres = model.Genres,
|
||||
Tags = model.Tags,
|
||||
|
@ -142,7 +140,6 @@ public static NzbDrone.Core.Music.Artist ToModel(this ArtistResource resource)
|
|||
ArtistType = resource.ArtistType,
|
||||
CleanName = resource.CleanName,
|
||||
ForeignArtistId = resource.ForeignArtistId,
|
||||
NameSlug = resource.NameSlug,
|
||||
RootFolderPath = resource.RootFolderPath,
|
||||
Genres = resource.Genres,
|
||||
Tags = resource.Tags,
|
||||
|
|
|
@ -67,15 +67,6 @@ public void getting_details_of_invalid_artist()
|
|||
Assert.Throws<BadRequestException>(() => Subject.GetArtistInfo("aaaaaa-aaa-aaaa-aaaa", 1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("We don't return a dothack from Metadata")]
|
||||
public void should_not_have_period_at_start_of_name_slug()
|
||||
{
|
||||
var details = Subject.GetArtistInfo("b6db95cd-88d9-492f-bbf6-a34e0e89b2e5", 1);
|
||||
|
||||
details.Item1.NameSlug.Should().Be("dothack");
|
||||
}
|
||||
|
||||
private void ValidateArtist(Artist artist)
|
||||
{
|
||||
artist.Should().NotBeNull();
|
||||
|
@ -84,7 +75,6 @@ private void ValidateArtist(Artist artist)
|
|||
artist.SortName.Should().Be(Parser.Parser.NormalizeTitle(artist.Name));
|
||||
artist.Overview.Should().NotBeNullOrWhiteSpace();
|
||||
artist.Images.Should().NotBeEmpty();
|
||||
artist.NameSlug.Should().NotBeNullOrWhiteSpace();
|
||||
//series.TvRageId.Should().BeGreaterThan(0);
|
||||
artist.ForeignArtistId.Should().NotBeNullOrWhiteSpace();
|
||||
}
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using FluentValidation.Validators;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.TvTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArtistNameSlugValidatorFixture : CoreTest<ArtistSlugValidator>
|
||||
{
|
||||
private List<Artist> _artist;
|
||||
private TestValidator<Artist> _validator;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_artist = Builder<Artist>.CreateListOfSize(1)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
_validator = new TestValidator<Artist>
|
||||
{
|
||||
v => v.RuleFor(s => s.NameSlug).SetValidator(Subject)
|
||||
};
|
||||
|
||||
Mocker.GetMock<IArtistService>()
|
||||
.Setup(s => s.GetAllArtists())
|
||||
.Returns(_artist);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_valid_if_there_is_an_existing_artist_with_the_same_title_slug()
|
||||
{
|
||||
var series = Builder<Artist>.CreateNew()
|
||||
.With(s => s.Id = 100)
|
||||
.With(s => s.NameSlug = _artist.First().NameSlug)
|
||||
.Build();
|
||||
|
||||
_validator.Validate(series).IsValid.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_valid_if_there_is_not_an_existing_artist_with_the_same_title_slug()
|
||||
{
|
||||
var series = Builder<Artist>.CreateNew()
|
||||
.With(s => s.NameSlug = "MyNameSlug")
|
||||
.Build();
|
||||
|
||||
_validator.Validate(series).IsValid.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_valid_if_there_is_an_existing_artist_with_a_null_title_slug()
|
||||
{
|
||||
_artist.First().NameSlug = null;
|
||||
|
||||
var series = Builder<Artist>.CreateNew()
|
||||
.With(s => s.NameSlug = "MyNameSlug")
|
||||
.Build();
|
||||
|
||||
_validator.Validate(series).IsValid.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_valid_when_updating_an_existing_artist()
|
||||
{
|
||||
_validator.Validate(_artist.First().JsonClone()).IsValid.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -285,7 +285,6 @@
|
|||
<Compile Include="MetadataSource\SearchArtistComparerFixture.cs" />
|
||||
<Compile Include="MetadataSource\SkyHook\SkyHookProxyFixture.cs" />
|
||||
<Compile Include="MusicTests\AddArtistFixture.cs" />
|
||||
<Compile Include="MusicTests\ArtistNameSlugValidatorFixture.cs" />
|
||||
<Compile Include="MusicTests\ArtistRepositoryTests\ArtistRepositoryFixture.cs" />
|
||||
<Compile Include="MusicTests\ArtistServiceTests\AddArtistFixture.cs" />
|
||||
<Compile Include="MusicTests\ArtistServiceTests\UpdateMultipleArtistFixture.cs" />
|
||||
|
|
|
@ -270,7 +270,6 @@ private static Artist MapArtist(ArtistResource resource)
|
|||
artist.ForeignArtistId = resource.Id;
|
||||
artist.Genres = resource.Genres;
|
||||
artist.Overview = resource.Overview;
|
||||
artist.NameSlug = Parser.Parser.CleanArtistName(artist.Name) + "-" + resource.Id.Substring(resource.Id.Length - 6);
|
||||
artist.CleanName = Parser.Parser.CleanArtistName(artist.Name);
|
||||
artist.SortName = Parser.Parser.NormalizeTitle(artist.Name);
|
||||
artist.Disambiguation = resource.Disambiguation;
|
||||
|
|
|
@ -17,8 +17,7 @@ public class AddArtistValidator : AbstractValidator<Artist>, IAddArtistValidator
|
|||
{
|
||||
public AddArtistValidator(RootFolderValidator rootFolderValidator,
|
||||
ArtistPathValidator artistPathValidator,
|
||||
ArtistAncestorValidator artistAncestorValidator,
|
||||
ArtistSlugValidator artistTitleSlugValidator)
|
||||
ArtistAncestorValidator artistAncestorValidator)
|
||||
{
|
||||
RuleFor(c => c.Path).Cascade(CascadeMode.StopOnFirstFailure)
|
||||
.IsValidPath()
|
||||
|
@ -26,7 +25,6 @@ public AddArtistValidator(RootFolderValidator rootFolderValidator,
|
|||
.SetValidator(artistPathValidator)
|
||||
.SetValidator(artistAncestorValidator);
|
||||
|
||||
RuleFor(c => c.NameSlug).SetValidator(artistTitleSlugValidator);// TODO: Check if we are going to use a slug or artistName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ public Album()
|
|||
Genres = new List<string>();
|
||||
Images = new List<MediaCover.MediaCover>();
|
||||
Media = new List<Medium>();
|
||||
Releases = new List<AlbumRelease>();
|
||||
}
|
||||
|
||||
public const string RELEASE_DATE_FORMAT = "yyyy-MM-dd";
|
||||
|
|
|
@ -30,7 +30,6 @@ public Artist()
|
|||
public int DiscogsId { get; set; }
|
||||
public string AMId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string NameSlug { get; set; }
|
||||
public string CleanName { get; set; }
|
||||
public string SortName { get; set; }
|
||||
public string Overview { get; set; }
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
using System.Linq;
|
||||
using FluentValidation.Validators;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Music
|
||||
{
|
||||
public class ArtistSlugValidator : PropertyValidator
|
||||
{
|
||||
private readonly IArtistService _artistService;
|
||||
|
||||
public ArtistSlugValidator(IArtistService artistService)
|
||||
: base("Name slug '{slug}' is in use by artist '{artistName}'")
|
||||
{
|
||||
_artistService = artistService;
|
||||
}
|
||||
|
||||
protected override bool IsValid(PropertyValidatorContext context)
|
||||
{
|
||||
if (context.PropertyValue == null) return true;
|
||||
|
||||
dynamic instance = context.ParentContext.InstanceToValidate;
|
||||
var instanceId = (int)instance.Id;
|
||||
var slug = context.PropertyValue.ToString();
|
||||
|
||||
var conflictingArtist = _artistService.GetAllArtists()
|
||||
.FirstOrDefault(s => s.NameSlug.IsNotNullOrWhiteSpace() &&
|
||||
s.NameSlug.Equals(context.PropertyValue.ToString()) &&
|
||||
s.Id != instanceId);
|
||||
|
||||
if (conflictingArtist == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
context.MessageFormatter.AppendArgument("slug", slug);
|
||||
context.MessageFormatter.AppendArgument("artistName", conflictingArtist.Name);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -74,7 +74,6 @@ private void RefreshArtistInfo(Artist artist)
|
|||
}
|
||||
|
||||
artist.Name = artistInfo.Name;
|
||||
artist.NameSlug = artistInfo.NameSlug;
|
||||
artist.Overview = artistInfo.Overview;
|
||||
artist.Status = artistInfo.Status;
|
||||
artist.CleanName = artistInfo.CleanName;
|
||||
|
|
|
@ -38,7 +38,7 @@ public override void OnGrab(GrabMessage message)
|
|||
environmentVariables.Add("Lidarr_EventType", "Grab");
|
||||
environmentVariables.Add("Lidarr_Artist_Id", artist.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_Name", artist.Name);
|
||||
environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId);
|
||||
environmentVariables.Add("Lidarr_Artist_Type", artist.ArtistType);
|
||||
environmentVariables.Add("Lidarr_Release_AlbumCount", remoteAlbum.Albums.Count.ToString());
|
||||
environmentVariables.Add("Lidarr_Release_AlbumReleaseDates", string.Join(",", remoteAlbum.Albums.Select(e => e.ReleaseDate)));
|
||||
|
@ -67,7 +67,7 @@ public override void OnDownload(DownloadMessage message)
|
|||
environmentVariables.Add("Lidarr_Artist_Id", artist.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_Name", artist.Name);
|
||||
environmentVariables.Add("Lidarr_Artist_Path", artist.Path);
|
||||
environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId);
|
||||
environmentVariables.Add("Lidarr_Artist_Type", artist.ArtistType);
|
||||
environmentVariables.Add("Lidarr_TrackFile_Id", trackFile.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_TrackFile_TrackCount", trackFile.Tracks.Value.Count.ToString());
|
||||
|
@ -102,7 +102,7 @@ public override void OnRename(Artist artist)
|
|||
environmentVariables.Add("Lidarr_Artist_Id", artist.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_Name", artist.Name);
|
||||
environmentVariables.Add("Lidarr_Artist_Path", artist.Path);
|
||||
environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId);
|
||||
environmentVariables.Add("Lidarr_Artist_Type", artist.ArtistType);
|
||||
|
||||
ExecuteScript(environmentVariables);
|
||||
|
|
|
@ -795,7 +795,6 @@
|
|||
<Compile Include="Music\ArtistNameNormalizer.cs" />
|
||||
<Compile Include="Music\AlbumService.cs" />
|
||||
<Compile Include="Music\AlbumRepository.cs" />
|
||||
<Compile Include="Music\ArtistSlugValidator.cs" />
|
||||
<Compile Include="Music\ArtistRepository.cs" />
|
||||
<Compile Include="Music\ArtistService.cs" />
|
||||
<Compile Include="Music\Commands\RefreshArtistCommand.cs" />
|
||||
|
|
Loading…
Reference in a new issue