From ff263374ec1b9611294997f811c2dff91e12b817 Mon Sep 17 00:00:00 2001 From: Finn Date: Fri, 25 Aug 2017 15:25:52 +0100 Subject: [PATCH] Added endpoints for organisation sector --- lib/Pear/LocalLoop/Controller/Admin/Organisations.pm | 4 ++++ lib/Pear/LocalLoop/Controller/Admin/Users.pm | 2 ++ lib/Pear/LocalLoop/Controller/Api/Register.pm | 2 ++ lib/Pear/LocalLoop/Controller/Api/User.pm | 2 ++ lib/Pear/LocalLoop/Schema/Result/Organisation.pm | 4 ++++ templates/admin/organisations/add_org.html.ep | 1 + templates/admin/organisations/valid_read.html.ep | 1 + templates/admin/users/read.html.ep | 4 ++++ 8 files changed, 20 insertions(+) diff --git a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm index 178d9f7..4492b36 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm @@ -28,6 +28,7 @@ sub add_org_submit { $validation->required('name'); $validation->optional('street_name'); $validation->required('town'); + $validation->optional('sector'); $validation->optional('postcode')->postcode; if ( $validation->has_error ) { @@ -43,6 +44,7 @@ sub add_org_submit { name => $validation->param('name'), street_name => $validation->param('street_name'), town => $validation->param('town'), + sector => $validation->param('sector'), postcode => $validation->param('postcode'), }); } finally { @@ -78,6 +80,7 @@ sub valid_edit { $validation->required('name'); $validation->required('street_name'); $validation->required('town'); + $validation->optional('sector'); $validation->required('postcode')->postcode; if ( $validation->has_error ) { @@ -94,6 +97,7 @@ sub valid_edit { name => $validation->param('name'), street_name => $validation->param('street_name'), town => $validation->param('town'), + sector => $validation->param('sector'), postcode => $validation->param('postcode'), }); } ); diff --git a/lib/Pear/LocalLoop/Controller/Admin/Users.pm b/lib/Pear/LocalLoop/Controller/Admin/Users.pm index 2fbc110..064ffba 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Users.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Users.pm @@ -68,6 +68,7 @@ sub edit { $validation->required('name'); $validation->required('street_name'); $validation->required('town'); + $validation->optional('sector'); } if ( $validation->has_error ) { @@ -107,6 +108,7 @@ sub edit { name => $validation->param('name'), street_name => $validation->param('street_name'), town => $validation->param('town'), + sector => $validation->param('sector'), postcode => $validation->param('postcode'), }); $user->update({ diff --git a/lib/Pear/LocalLoop/Controller/Api/Register.pm b/lib/Pear/LocalLoop/Controller/Api/Register.pm index da6805a..dfff302 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Register.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Register.pm @@ -75,6 +75,7 @@ sub post_register{ $validation->required('name'); $validation->required('street_name'); $validation->required('town'); + $validation->required('sector'); } return $c->api_validation_error if $validation->has_error; @@ -112,6 +113,7 @@ sub post_register{ name => $validation->param('name'), street_name => $validation->param('street_name'), town => $validation->param('town'), + sector => $validation->param('sector'), postcode => $validation->param('postcode'), }); $c->schema->resultset('User')->create({ diff --git a/lib/Pear/LocalLoop/Controller/Api/User.pm b/lib/Pear/LocalLoop/Controller/Api/User.pm index 12ef04b..fce779a 100644 --- a/lib/Pear/LocalLoop/Controller/Api/User.pm +++ b/lib/Pear/LocalLoop/Controller/Api/User.pm @@ -128,6 +128,7 @@ sub post_account_update { $validation->required('name'); $validation->required('street_name'); $validation->required('town'); + $validation->required('sector'); } return $c->api_validation_error if $validation->has_error; @@ -154,6 +155,7 @@ sub post_account_update { name => $validation->param('name'), street_name => $validation->param('street_name'), town => $validation->param('town'), + sector => $validation->param('sector'), postcode => $validation->param('postcode'), }); $user->update({ diff --git a/lib/Pear/LocalLoop/Schema/Result/Organisation.pm b/lib/Pear/LocalLoop/Schema/Result/Organisation.pm index e5a30a3..f9f6348 100644 --- a/lib/Pear/LocalLoop/Schema/Result/Organisation.pm +++ b/lib/Pear/LocalLoop/Schema/Result/Organisation.pm @@ -34,6 +34,10 @@ __PACKAGE__->add_columns( size => 16, is_nullable => 1, }, + sector => { + data_type => "varchar", + size => 1, + is_nullable => 1, ); __PACKAGE__->set_primary_key('id'); diff --git a/templates/admin/organisations/add_org.html.ep b/templates/admin/organisations/add_org.html.ep index 07cf699..3e45d51 100644 --- a/templates/admin/organisations/add_org.html.ep +++ b/templates/admin/organisations/add_org.html.ep @@ -21,6 +21,7 @@
  • +
  • diff --git a/templates/admin/organisations/valid_read.html.ep b/templates/admin/organisations/valid_read.html.ep index 9fd3e97..12d67a6 100644 --- a/templates/admin/organisations/valid_read.html.ep +++ b/templates/admin/organisations/valid_read.html.ep @@ -20,6 +20,7 @@
  • +
  • diff --git a/templates/admin/users/read.html.ep b/templates/admin/users/read.html.ep index 202efed..8e6cb47 100644 --- a/templates/admin/users/read.html.ep +++ b/templates/admin/users/read.html.ep @@ -72,6 +72,10 @@ +
    + + +
    % } else {

    User is not a customer or an organisation