From 2137b5607f2456725b25340f4099387586b0297f Mon Sep 17 00:00:00 2001 From: Finn Date: Mon, 4 Sep 2017 16:12:03 +0100 Subject: [PATCH 1/2] Fixed Org account editing for portal --- lib/Pear/LocalLoop/Controller/Api/User.pm | 44 +++++++++++++++-------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/User.pm b/lib/Pear/LocalLoop/Controller/Api/User.pm index 555c902..e017e19 100644 --- a/lib/Pear/LocalLoop/Controller/Api/User.pm +++ b/lib/Pear/LocalLoop/Controller/Api/User.pm @@ -60,28 +60,42 @@ sub post_account { if ( defined $user_result ) { my $email = $user_result->email; - my $full_name; - my $display_name; - my $postcode; #Needs elsif added for trader page for this similar relevant entry if ( $user_result->type eq 'customer' ) { - $full_name = $user_result->entity->customer->full_name; - $display_name = $user_result->entity->customer->display_name; - $postcode = $user_result->entity->customer->postcode; + my $full_name = $user_result->entity->customer->full_name; + my $display_name = $user_result->entity->customer->display_name; + my $postcode = $user_result->entity->customer->postcode; + return $c->render( json => { + success => Mojo::JSON->true, + full_name => $full_name, + display_name => $display_name, + email => $email, + postcode => $postcode, + }); } elsif ( $user_result->type eq 'organisation' ) { - $display_name = $user_result->entity->organisation->name; + my $name = $user_result->entity->organisation->name; + my $postcode = $user_result->entity->organisation->postcode; + my $street_name = $user_result->entity->organisation->street_name; + my $town = $user_result->entity->organisation->town; + return $c->render( json => { + success => Mojo::JSON->true, + town => $town, + name => $name, + street_name => $street_name, + email => $email, + postcode => $postcode, + }); } else { - return; + return $c->render( + json => { + success => Mojo::JSON->false, + message => 'Invalid Server Error.', + }, + status => 500 + ); } - return $c->render( json => { - success => Mojo::JSON->true, - full_name => $full_name, - display_name => $display_name, - email => $email, - postcode => $postcode, - }); } return $c->render( json => { From fabd01f98869a68af6049410deaec315f89786f6 Mon Sep 17 00:00:00 2001 From: Finn Date: Mon, 4 Sep 2017 17:05:10 +0100 Subject: [PATCH 2/2] Fixed for sector in account editing --- lib/Pear/LocalLoop/Controller/Api/User.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Pear/LocalLoop/Controller/Api/User.pm b/lib/Pear/LocalLoop/Controller/Api/User.pm index e017e19..b83f04b 100644 --- a/lib/Pear/LocalLoop/Controller/Api/User.pm +++ b/lib/Pear/LocalLoop/Controller/Api/User.pm @@ -33,6 +33,9 @@ has error_messages => sub { town => { required => { message => 'No town sent.', status => 400 }, }, + sector => { + required => { message => 'No sector sent.', status => 400 }, + }, }; }; @@ -78,10 +81,12 @@ sub post_account { my $postcode = $user_result->entity->organisation->postcode; my $street_name = $user_result->entity->organisation->street_name; my $town = $user_result->entity->organisation->town; + my $sector = $user_result->entity->organisation->sector; return $c->render( json => { success => Mojo::JSON->true, town => $town, name => $name, + sector => $sector, street_name => $street_name, email => $email, postcode => $postcode,