diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index 7ace853..a58e075 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -173,6 +173,7 @@ sub startup { $api_public->post('/register')->to('api-register#post_register'); $api_public->post('/logout')->to('api-auth#post_logout'); $api_public->post('/feedback')->to('api-feedback#post_feedback'); + $api_public->post('/check-device-token')->to('api-devices#check_token'); $api_public->post('/add-device-token')->to('api-devices#add_token'); $api_public->post('/get-topics')->to('api-sendmessage#get_topics'); @@ -282,8 +283,7 @@ sub startup { $admin_routes->post('/categories')->to('admin-categories#create'); $admin_routes->get('/categories/:id')->to('admin-categories#get'); $admin_routes->post('/categories/:id')->to('admin-categories#update'); - $admin_routes->post('/categories/:id/delete') - ->to('admin-categories#del'); + $admin_routes->post('/categories/:id/delete')->to('admin-categories#del'); $admin_routes->get('/users')->to('admin-users#index'); $admin_routes->get('/users/:id')->to('admin-users#read'); diff --git a/lib/Pear/LocalLoop/Command/codepoint_open.pm b/lib/Pear/LocalLoop/Command/codepoint_open.pm index b4570b4..adcaf0e 100644 --- a/lib/Pear/LocalLoop/Command/codepoint_open.pm +++ b/lib/Pear/LocalLoop/Command/codepoint_open.pm @@ -55,7 +55,7 @@ sub run { { key => 'primary' }, ); } - + return 1; } diff --git a/lib/Pear/LocalLoop/Command/dev_transactions.pm b/lib/Pear/LocalLoop/Command/dev_transactions.pm index adcdf51..614f723 100644 --- a/lib/Pear/LocalLoop/Command/dev_transactions.pm +++ b/lib/Pear/LocalLoop/Command/dev_transactions.pm @@ -90,7 +90,7 @@ sub run { } } } - + return 1; } diff --git a/lib/Pear/LocalLoop/Command/latlong_setup.pm b/lib/Pear/LocalLoop/Command/latlong_setup.pm index 9c34136..81c0db7 100644 --- a/lib/Pear/LocalLoop/Command/latlong_setup.pm +++ b/lib/Pear/LocalLoop/Command/latlong_setup.pm @@ -29,7 +29,7 @@ sub run { ); $result->update( { distance => $distance } ) if defined $distance; } - + return 1; } @@ -55,7 +55,7 @@ sub _set_lat_long_for_result { ); } } - + return 1; } diff --git a/lib/Pear/LocalLoop/Command/leaderboard.pm b/lib/Pear/LocalLoop/Command/leaderboard.pm index bd5df60..91c09b6 100644 --- a/lib/Pear/LocalLoop/Command/leaderboard.pm +++ b/lib/Pear/LocalLoop/Command/leaderboard.pm @@ -71,7 +71,7 @@ sub run { } } } - + return 1; } diff --git a/lib/Pear/LocalLoop/Command/recalc_leaderboards.pm b/lib/Pear/LocalLoop/Command/recalc_leaderboards.pm index 5ea8fa5..ed61d6e 100644 --- a/lib/Pear/LocalLoop/Command/recalc_leaderboards.pm +++ b/lib/Pear/LocalLoop/Command/recalc_leaderboards.pm @@ -13,7 +13,7 @@ sub run { my $leaderboard_rs = $self->app->schema->resultset('Leaderboard'); $leaderboard_rs->recalculate_all; - + return 1; } diff --git a/lib/Pear/LocalLoop/Command/recur_transactions.pm b/lib/Pear/LocalLoop/Command/recur_transactions.pm index 58bf927..78268f8 100644 --- a/lib/Pear/LocalLoop/Command/recur_transactions.pm +++ b/lib/Pear/LocalLoop/Command/recur_transactions.pm @@ -153,7 +153,7 @@ sub run { $recur_result->update( { last_updated => $purchase_time } ); } - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin.pm b/lib/Pear/LocalLoop/Controller/Admin.pm index 01049d3..e130761 100644 --- a/lib/Pear/LocalLoop/Controller/Admin.pm +++ b/lib/Pear/LocalLoop/Controller/Admin.pm @@ -34,7 +34,7 @@ sub home { pending => $pending_feedback_rs->count, }, ); - + return 1; } @@ -54,7 +54,7 @@ sub auth_login { . "]" ); $c->redirect_to('/admin'); } - + return 1; } @@ -63,7 +63,7 @@ sub auth_logout { $c->logout; $c->redirect_to('/admin'); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin/Categories.pm b/lib/Pear/LocalLoop/Controller/Admin/Categories.pm index bb539c6..c5b1687 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Categories.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Categories.pm @@ -12,7 +12,7 @@ sub idx { my $category_rs = $c->result_set; $category_rs->result_class('DBIx::Class::ResultClass::HashRefInflator'); $c->stash( categories => [ $category_rs->all ] ); - + return 1; } @@ -45,7 +45,7 @@ sub create { $c->result_set->create( { name => $category_name } ); } $c->redirect_to('/admin/categories'); - + return 1; } @@ -62,7 +62,7 @@ sub get { $c->flash( error => 'No Category found' ); $c->redirect_to('/admin/categories'); } - + return 1; } @@ -101,7 +101,7 @@ sub update { $c->flash( error => 'No Category found' ); $c->redirect_to('/admin/categories'); } - + return 1; } @@ -120,7 +120,7 @@ sub del { $c->flash( error => 'No Category found' ); } $c->redirect_to('/admin/categories'); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm b/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm index 2a39fb1..ccffb5e 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm @@ -18,7 +18,7 @@ sub idx { }, ); $c->stash( feedback_rs => $feedback_rs ); - + return 1; } @@ -34,7 +34,7 @@ sub get { $c->flash( error => 'No Feedback found' ); $c->redirect_to('/admin/feedback'); } - + return 1; } @@ -52,7 +52,7 @@ sub actioned { $c->flash( error => 'No Feedback found' ); $c->redirect_to('/admin/feedback'); } - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin/Import.pm b/lib/Pear/LocalLoop/Controller/Admin/Import.pm index 43a8945..01514ed 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Import.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Import.pm @@ -21,7 +21,7 @@ sub idx { }, ); $c->stash( import_rs => $import_rs ); - + return 1; } @@ -48,13 +48,13 @@ sub list { import_org_rs => $import_org_rs, import_lookup_rs => $import_lookup_rs, ); - + return 1; } sub get_add { my $c = shift; - + return 1; } @@ -71,7 +71,7 @@ sub post_add { } ); - ## no critic (InputOutput::RequireBriefOpen) + ## no critic (InputOutput::RequireBriefOpen) open my $fh, '<', \$csv_data; # List context returns the actual headers @@ -100,7 +100,7 @@ sub post_add { } my $csv_output = $csv->getline_hr_all($fh); - + close $fh; ## use critic @@ -157,7 +157,7 @@ sub post_add { $c->flash( success => 'Created Value Set' ); $c->redirect_to( '/admin/import/' . $value_set->id ); - + return 1; } @@ -172,7 +172,7 @@ sub _csv_flash_error { #csv_data => $c->param('csv'), date_format => $c->param('date_format'), ); - + return 1; } @@ -223,7 +223,7 @@ sub get_user { lookup => $lookup_result, user_name => $user_name, ); - + return 1; } @@ -274,7 +274,7 @@ sub get_org { lookup => $lookup_result, org_name => $org_name, ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin/ImportFrom.pm b/lib/Pear/LocalLoop/Controller/Admin/ImportFrom.pm index b55916f..2c08780 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/ImportFrom.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/ImportFrom.pm @@ -15,7 +15,7 @@ sub idx { ]; $c->app->max_request_size(104857600); - + return 1; } @@ -127,12 +127,11 @@ sub org_search { }, ); - my @results = ( - map { { label => $_->name, value => $_->entity->id, } } $rs->all - ); + my @results = + ( map { { label => $_->name, value => $_->entity->id, } } $rs->all ); $c->render( json => \@results ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm index 620949f..e9cd313 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm @@ -21,13 +21,13 @@ sub list { ); $c->stash( orgs_rs => $orgs_rs, ); - + return 1; } sub add_org { my $c = shift; - + return 1; } @@ -91,7 +91,7 @@ sub add_org_submit { $c->redirect_to( '/admin/organisations/' . $organisation->id ); } }; - + return 1; } @@ -118,12 +118,12 @@ sub valid_read { transactions => $transactions, associations => $assoc, ); - + return 1; } sub valid_edit { - my ($c, $warning) = @_; + my ( $c, $warning ) = @_; my $validation = $c->validation; $validation->required('name'); @@ -191,7 +191,7 @@ sub valid_edit { } }; $c->redirect_to( '/admin/organisations/' . $c->param('id') ); - + return 1; } @@ -222,7 +222,7 @@ sub merge_list { org_result => $org_result, org_rs => $org_rs, ); - + return 1; } @@ -251,7 +251,7 @@ sub merge_detail { org_result => $org_result, target_result => $target_result, ); - + return 1; } @@ -309,7 +309,7 @@ sub merge_confirm { } $c->redirect_to( '/admin/organisations/' . $org_id . '/merge/' . $target_id ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin/Reports.pm b/lib/Pear/LocalLoop/Controller/Admin/Reports.pm index 8040fdf..6362701 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Reports.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Reports.pm @@ -59,7 +59,7 @@ sub transaction_data { json => { json => { data => $transaction_data } }, html => { transaction_rs => encode_json($transaction_data) }, ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin/Tokens.pm b/lib/Pear/LocalLoop/Controller/Admin/Tokens.pm index eb3ec8d..356a372 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Tokens.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Tokens.pm @@ -12,7 +12,7 @@ sub idx { my $token_rs = $c->result_set; $token_rs->result_class('DBIx::Class::ResultClass::HashRefInflator'); $c->stash( tokens => [ $token_rs->all ] ); - + return 1; } @@ -45,7 +45,7 @@ sub create { $c->result_set->create( { name => $token_name } ); } $c->redirect_to('/admin/tokens'); - + return 1; } @@ -62,7 +62,7 @@ sub get { $c->flash( error => 'No Token found' ); $c->redirect_to('/admin/tokens'); } - + return 1; } @@ -95,7 +95,7 @@ sub update { $c->flash( error => 'No Token found' ); $c->redirect_to('/admin/tokens'); } - + return 1; } @@ -113,7 +113,7 @@ sub del { $c->flash( error => 'No Token found' ); } $c->redirect_to('/admin/tokens'); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin/Transactions.pm b/lib/Pear/LocalLoop/Controller/Admin/Transactions.pm index 23d5b18..a88902f 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Transactions.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Transactions.pm @@ -68,7 +68,7 @@ sub index { count => $count, }, ); - + return 1; } @@ -86,7 +86,7 @@ sub read { $c->flash( error => 'No transaction found' ); $c->redirect_to('/admin/transactions'); } - + return 1; } @@ -103,7 +103,7 @@ sub image { else { $c->reply->static('image/no_transaction.jpg'); } - + return 1; } @@ -126,7 +126,7 @@ sub delete { $c->flash( error => 'No transaction found' ); $c->redirect_to('/admin/transactions'); } - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Admin/Users.pm b/lib/Pear/LocalLoop/Controller/Admin/Users.pm index 292a0f9..b77589e 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Users.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Users.pm @@ -34,7 +34,7 @@ sub index { } ); $c->stash( user_rs => $user_rs ); - + return 1; } @@ -63,14 +63,14 @@ sub read { $c->flash( error => 'No User found' ); $c->redirect_to('/admin/users'); } - + return 1; } ## no critic (Subroutines::ProhibitBuiltinHomonyms) sub update { ## use critic - my ($c, $error) = @_; + my ( $c, $error ) = @_; my $id = $c->param('id'); @@ -199,7 +199,7 @@ sub update { } $c->redirect_to( '/admin/users/' . $id ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Api/Auth.pm b/lib/Pear/LocalLoop/Controller/Api/Auth.pm index 64ca702..a40d6a7 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Auth.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Auth.pm @@ -124,6 +124,8 @@ sub post_login { sub post_logout { my $c = shift; + print STDERR "TEST"; + my $session_key = $c->req->json('/session_key'); my $session_result = @@ -139,7 +141,7 @@ sub post_logout { message => 'Logged Out', } ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Api/Sendmessage.pm b/lib/Pear/LocalLoop/Controller/Api/Sendmessage.pm index 399360e..3cbee6a 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Sendmessage.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Sendmessage.pm @@ -9,10 +9,6 @@ use Carp; has error_messages => sub { return { - #devicetokens => { - # required => { message => 'Device token is required', status => 400 }, - # in_resultset => { message => 'Device token not found', status => 400 }, - #}, topic => { required => { message => 'Topic is required', status => 400 }, }, @@ -27,12 +23,8 @@ has error_messages => sub { }; }; -=begin comment - Credit: Peter Scott/StackOverflow - https://stackoverflow.com/a/53357961/4580273 - Credit: jeffez/StackOverflow - https://stackoverflow.com/q/56556438/4580273 -=cut +# Credit: Peter Scott/StackOverflow https://stackoverflow.com/a/53357961/4580273 +# Credit: jeffez/StackOverflow https://stackoverflow.com/q/56556438/4580273 my $jwt = create_jwt_from_path_and_scopes( './localspend-47012.json', 'email https://www.googleapis.com/auth/cloud-platform' ); @@ -104,7 +96,6 @@ sub post_message { my $validation = $c->validation; $validation->input( $c->stash->{api_json} ); -#$validation->required('devicetokens')->in_resultset('token', $c->schema->resultset('DeviceToken')); $validation->required('topic'); $validation->required('sender') ->in_resultset( 'name', $c->schema->resultset('Organisation') ); diff --git a/lib/Pear/LocalLoop/Controller/Api/Stats.pm b/lib/Pear/LocalLoop/Controller/Api/Stats.pm index 2e8bef1..e4afde4 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Stats.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Stats.pm @@ -460,12 +460,11 @@ sub post_leaderboards { my @leaderboard_array = $today_values->all; if ( $validation->param('type') =~ /total$/ ) { - ## no critic (ValuesAndExpressions::ProhibitCommaSeparatedStatements) + ## no critic (ValuesAndExpressions::ProhibitCommaSeparatedStatements) @leaderboard_array = ( map { { - %$_, - value => $_->{value} / 100000 + %$_, value => $_->{value} / 100000 } } @leaderboard_array ); @@ -545,7 +544,7 @@ sub post_leaderboards_paged { $values_count = $today_values->pager->total_entries; if ( $validation->param('type') =~ /total$/ ) { - ## no critic (ValuesAndExpressions::ProhibitCommaSeparatedStatements) + ## no critic (ValuesAndExpressions::ProhibitCommaSeparatedStatements) @leaderboard_array = ( map { { diff --git a/lib/Pear/LocalLoop/Controller/Api/V1/Supplier/Location.pm b/lib/Pear/LocalLoop/Controller/Api/V1/Supplier/Location.pm index ae5d049..087287e 100644 --- a/lib/Pear/LocalLoop/Controller/Api/V1/Supplier/Location.pm +++ b/lib/Pear/LocalLoop/Controller/Api/V1/Supplier/Location.pm @@ -122,7 +122,7 @@ sub idx { } }, ); - + return 1; } @@ -206,7 +206,7 @@ sub trail_load { } }, ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Controller/Root.pm b/lib/Pear/LocalLoop/Controller/Root.pm index 9106a7f..bf286d8 100644 --- a/lib/Pear/LocalLoop/Controller/Root.pm +++ b/lib/Pear/LocalLoop/Controller/Root.pm @@ -9,7 +9,7 @@ sub index { # if ( $c->is_user_authenticated ) { # $c->redirect_to('/home'); # } - + return 1; } @@ -32,7 +32,7 @@ sub auth_login { else { $c->redirect_to('/'); } - + return 1; } @@ -41,13 +41,13 @@ sub auth_logout { $c->logout; $c->redirect_to('/'); - + return 1; } sub home { my $c = shift; - + return 1; } diff --git a/lib/Pear/LocalLoop/Import/LCCCsv/Postcodes.pm b/lib/Pear/LocalLoop/Import/LCCCsv/Postcodes.pm index e44be58..22438b8 100644 --- a/lib/Pear/LocalLoop/Import/LCCCsv/Postcodes.pm +++ b/lib/Pear/LocalLoop/Import/LCCCsv/Postcodes.pm @@ -24,7 +24,7 @@ sub import_csv { while ( my $row = $self->get_csv_line ) { $self->_row_to_result($row); } - + return 1; } @@ -47,7 +47,7 @@ sub _row_to_result { return if $postcode_r->ward; $postcode_r->update( { ward_id => $ward->id } ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Import/LCCCsv/Suppliers.pm b/lib/Pear/LocalLoop/Import/LCCCsv/Suppliers.pm index d0df5c6..7e3dcd5 100644 --- a/lib/Pear/LocalLoop/Import/LCCCsv/Suppliers.pm +++ b/lib/Pear/LocalLoop/Import/LCCCsv/Suppliers.pm @@ -22,7 +22,7 @@ sub import_csv { while ( my $row = $self->get_csv_line ) { $self->_row_to_result($row); } - + return 1; } @@ -34,7 +34,8 @@ sub _row_to_result { my $address = ( defined $addr2 ? ( $row->{"address line 2"} . ' ' . $addr2 ) - : $row->{"address line 2"} ); + : $row->{"address line 2"} + ); return if $self->external_result->organisations->find( @@ -58,7 +59,7 @@ sub _row_to_result { } } ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Import/LCCCsv/Transactions.pm b/lib/Pear/LocalLoop/Import/LCCCsv/Transactions.pm index c711a8b..4ad3616 100644 --- a/lib/Pear/LocalLoop/Import/LCCCsv/Transactions.pm +++ b/lib/Pear/LocalLoop/Import/LCCCsv/Transactions.pm @@ -46,7 +46,7 @@ sub import_csv { while ( my $row = $self->get_csv_line ) { $self->_row_to_result( $row, $lcc_org ); } - + return 1; } @@ -183,7 +183,7 @@ sub _row_to_result { ), } ); - + return 1; } diff --git a/lib/Pear/LocalLoop/Plugin/BootstrapPagination.pm b/lib/Pear/LocalLoop/Plugin/BootstrapPagination.pm index b69cad3..f8e9917 100644 --- a/lib/Pear/LocalLoop/Plugin/BootstrapPagination.pm +++ b/lib/Pear/LocalLoop/Plugin/BootstrapPagination.pm @@ -99,11 +99,15 @@ sub register { if ( $number eq ".." && $last_num < $actual ) { my $offset = ceil( ( $actual - $round ) / 2 ) + 1; $html .= "