[mb-commits] branch, data-nes, updated. Correctly redirect after creating relationships

MusicBrainz Git Server <[email protected]> Mon, 04 Feb 2013 08:52:51 +0000
Newsgroups gmane.comp.audio.musicbrainz.cvs
Message-ID <E1U2HnH-0005VH-7c@wiley>
The branch, data-nes has been updated
       via  http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=6a9f4af999e21c5f1866268cf3f25542b123aac9 (commit)
      from  http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=b97e1cb4720aa655181429a84396a68fe5116bdc (commit)

Summary of changes:
 .../Server/Controller/Edit/Relationship.pm         |   27 +++----------------
 lib/MusicBrainz/Server/Data/Utils.pm               |   20 ++++++++++++++
 2 files changed, 25 insertions(+), 22 deletions(-)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6a9f4af999e21c5f1866268cf3f25542b123aac9
Author: Oliver Charles <[email protected]>
Date:   Mon Feb 4 11:48:02 2013 +0000

    Correctly redirect after creating relationships

diff --git a/lib/MusicBrainz/Server/Controller/Edit/Relationship.pm b/lib/MusicBrainz/Server/Controller/Edit/Relationship.pm
index eab41f9..3a256c9 100644
--- a/lib/MusicBrainz/Server/Controller/Edit/Relationship.pm
+++ b/lib/MusicBrainz/Server/Controller/Edit/Relationship.pm
@@ -4,7 +4,7 @@ use Moose;
 BEGIN { extends 'MusicBrainz::Server::Controller' };
 
 use MusicBrainz::Server::Constants qw( $EDIT_RELATIONSHIP_DELETE );
-use MusicBrainz::Server::Data::Utils qw( type_to_model );
+use MusicBrainz::Server::Data::Utils qw( type_to_controller type_to_model );
 use MusicBrainz::Server::Entity::Link;
 use MusicBrainz::Server::Entity::NES::Relationship;
 use MusicBrainz::Server::Entity::Tree::Work;
@@ -275,7 +275,7 @@ sub create : Local RequireAuth Edit
 
         delete $c->session->{relationship};
         my $redirect = $c->req->params->{returnto} ||
-            $c->uri_for_action($c->controller(type_to_model($type0))->action_for('show'), [ $source_gid ]);
+            $c->uri_for_action($c->controller(type_to_controller($type0))->action_for('show'), [ $source_gid ]);
         $c->response->redirect($redirect);
         $c->detach;
     }
@@ -362,26 +362,9 @@ sub create_url : Local RequireAuth Edit
                 )
             );
 
-            # my $e0 = $types[0] eq 'url' ? $url : $entity;
-            # my $e1 = $types[1] eq 'url' ? $url : $entity;
-
-            # $c->stash( url => $form->field('url')->value );
-            # $c->model('MB')->with_transaction(sub {
-            #     $self->try_and_insert(
-            #         $c, $form,
-            #         @types,
-            #         entity0 => $e0,
-            #         entity1 => $e1,
-            #         link_type_id => $form->field('link_type_id')->value,
-            #         attributes => \@attributes,
-            #         ended => 0
-            #     ) or $self->detach_existing($c);
-            # });
-
-            # my $redirect = $c->controller(type_to_model($type))->action_for('show');
-            # $c->response->redirect($c->uri_for_action($redirect, [ $gid ]));
-            # $c->detach;
-
+            my $redirect = $c->controller(type_to_controller($type))->action_for('show');
+            $c->response->redirect($c->uri_for_action($redirect, [ $gid ]));
+            $c->detach;
         }
     });
 }
diff --git a/lib/MusicBrainz/Server/Data/Utils.pm b/lib/MusicBrainz/Server/Data/Utils.pm
index 308b121..4554f7e 100644
--- a/lib/MusicBrainz/Server/Data/Utils.pm
+++ b/lib/MusicBrainz/Server/Data/Utils.pm
@@ -49,6 +49,7 @@ our @EXPORT_OK = qw(
     remove_equal
     take_while
     trim
+    type_to_controller
     type_to_model
 );
 
@@ -66,6 +67,20 @@ Readonly my %TYPE_TO_MODEL => (
     'work'          => 'NES::Work',
 );
 
+Readonly my %TYPE_TO_CONTROLLER => (
+    'annotation'    => 'Annotation',
+    'artist'        => 'Artist',
+    'cdstub'        => 'CDStub',
+    'editor'        => 'Editor',
+    'freedb'        => 'FreeDB',
+    'label'         => 'Label',
+    'recording'     => 'Recording',
+    'release'       => 'Release',
+    'release_group' => 'ReleaseGroup',
+    'url'           => 'URL',
+    'work'          => 'Work',
+);
+
 sub copy_escape {
     my $str = shift;
     $str =~ s/\n/\\n/g;
@@ -336,6 +351,11 @@ sub type_to_model
     return $TYPE_TO_MODEL{$_[0]} || die "$_[0] is not a type that has a model";
 }
 
+sub type_to_controller
+{
+    return $TYPE_TO_CONTROLLER{$_[0]} || die "$_[0] is not a type that has a controller";
+}
+
 sub model_to_type
 {
     my %map = reverse %TYPE_TO_MODEL;

-----------------------------------------------------------------------


hooks/post-receive
-- 
mb_server