Fix admin login test and required changes for entity upgrade
This commit is contained in:
parent
6cd3113912
commit
18992784b2
4 changed files with 32 additions and 21 deletions
|
@ -5,10 +5,10 @@ sub under {
|
|||
my $c = shift;
|
||||
|
||||
if ( $c->is_user_authenticated ) {
|
||||
return 1 if defined $c->current_user->administrator;
|
||||
return 1 if $c->current_user->is_admin;
|
||||
}
|
||||
$c->redirect_to('/');
|
||||
return undef;
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub home {
|
||||
|
@ -16,8 +16,8 @@ sub home {
|
|||
|
||||
my $user_rs = $c->schema->resultset('User');
|
||||
my $token_rs = $c->schema->resultset('AccountToken');
|
||||
my $pending_orgs_rs = $c->schema->resultset('PendingOrganisation');
|
||||
my $pending_transaction_rs = $c->schema->resultset('PendingTransaction');
|
||||
my $pending_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 1 });
|
||||
my $pending_transaction_rs = $pending_orgs_rs->entity->sales;
|
||||
$c->stash(
|
||||
user_count => $user_rs->count,
|
||||
tokens => {
|
||||
|
|
10
lib/Pear/LocalLoop/Schema/ResultSet/Entity.pm
Normal file
10
lib/Pear/LocalLoop/Schema/ResultSet/Entity.pm
Normal file
|
@ -0,0 +1,10 @@
|
|||
package Pear::LocalLoop::Schema::ResultSet::Entity;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::ResultSet';
|
||||
|
||||
sub sales { shift->search_related('sales', @_) }
|
||||
|
||||
1;
|
10
lib/Pear/LocalLoop/Schema/ResultSet/Organisation.pm
Normal file
10
lib/Pear/LocalLoop/Schema/ResultSet/Organisation.pm
Normal file
|
@ -0,0 +1,10 @@
|
|||
package Pear::LocalLoop::Schema::ResultSet::Organisation;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::ResultSet';
|
||||
|
||||
sub entity { shift->search_related('entity', @_) }
|
||||
|
||||
1;
|
Reference in a new issue