-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* master: MBS-12311: Allow adding annotations to genres (#2492) Add basic genre create/edit tests Remove useless Area::Create _insert_hash MBS-10165: Use edit system for genre editing MBS-10165: Use edit system for genre adding MBS-10165: Use edit system for genre deletion MBS-10165: Basic preparations for genre edits Support genres in formatEntityTypeName
- Loading branch information
Showing
38 changed files
with
766 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package MusicBrainz::Server::Edit::Genre; | ||
use Moose::Role; | ||
use namespace::autoclean; | ||
|
||
use MusicBrainz::Server::Translation qw ( l ); | ||
|
||
sub edit_category { l('Genre') } | ||
|
||
1; | ||
|
||
=head1 COPYRIGHT AND LICENSE | ||
Copyright (C) 2022 MetaBrainz Foundation | ||
This file is part of MusicBrainz, the open internet music database, | ||
and is licensed under the GPL version 2, or (at your option) any | ||
later version: http://www.gnu.org/licenses/gpl-2.0.txt | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package MusicBrainz::Server::Edit::Genre::AddAnnotation; | ||
use Moose; | ||
|
||
use MusicBrainz::Server::Constants qw( $EDIT_GENRE_ADD_ANNOTATION ); | ||
use MusicBrainz::Server::Translation qw( N_l ); | ||
|
||
extends 'MusicBrainz::Server::Edit'; | ||
|
||
with 'MusicBrainz::Server::Edit::Annotation::Edit' => { | ||
model => 'Genre', | ||
edit_name => N_l('Add genre annotation'), | ||
edit_type => $EDIT_GENRE_ADD_ANNOTATION, | ||
}; | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
no Moose; | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package MusicBrainz::Server::Edit::Genre::Create; | ||
use Moose; | ||
|
||
use MusicBrainz::Server::Constants qw( $EDIT_GENRE_CREATE ); | ||
use MusicBrainz::Server::Edit::Types qw( Nullable ); | ||
use MusicBrainz::Server::Entity::Util::JSON qw( to_json_object ); | ||
use MusicBrainz::Server::Translation qw( N_l ); | ||
use aliased 'MusicBrainz::Server::Entity::PartialDate'; | ||
use Moose::Util::TypeConstraints; | ||
use MooseX::Types::Moose qw( Str ); | ||
use MooseX::Types::Structured qw( Dict Optional ); | ||
|
||
use aliased 'MusicBrainz::Server::Entity::Genre'; | ||
|
||
extends 'MusicBrainz::Server::Edit::Generic::Create'; | ||
with 'MusicBrainz::Server::Edit::Role::Preview'; | ||
with 'MusicBrainz::Server::Edit::Genre'; | ||
with 'MusicBrainz::Server::Edit::Role::AlwaysAutoEdit'; | ||
|
||
sub edit_name { N_l('Add genre') } | ||
sub edit_type { $EDIT_GENRE_CREATE } | ||
sub _create_model { 'Genre' } | ||
sub genre_id { shift->entity_id } | ||
|
||
|
||
has '+data' => ( | ||
isa => Dict[ | ||
name => Str, | ||
gid => Optional[Str], | ||
comment => Nullable[Str], | ||
] | ||
); | ||
|
||
sub foreign_keys | ||
{ | ||
my $self = shift; | ||
return { | ||
Genre => [ $self->entity_id ], | ||
}; | ||
} | ||
|
||
sub build_display_data | ||
{ | ||
my ($self, $loaded) = @_; | ||
|
||
return { | ||
name => $self->data->{name}, | ||
comment => $self->data->{comment}, | ||
genre => to_json_object((defined($self->entity_id) && | ||
$loaded->{Genre}{ $self->entity_id }) || | ||
Genre->new( name => $self->data->{name} ) | ||
), | ||
}; | ||
} | ||
|
||
sub edit_template_react { 'AddGenre' }; | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
no Moose; | ||
|
||
1; | ||
|
||
=head1 COPYRIGHT AND LICENSE | ||
Copyright (C) 2022 MetaBrainz Foundation | ||
This file is part of MusicBrainz, the open internet music database, | ||
and is licensed under the GPL version 2, or (at your option) any | ||
later version: http://www.gnu.org/licenses/gpl-2.0.txt | ||
=cut |
Oops, something went wrong.