diff --git a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm index dba62e0..9a9a919 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Organisations.pm @@ -6,8 +6,8 @@ use Try::Tiny; sub list { my $c = shift; - my $valid_orgs_rs = $c->schema->resultset('Organisation'); - my $pending_orgs_rs = $c->schema->resultset('PendingOrganisation'); + my $valid_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 0 }); + my $pending_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 1 }); $c->stash( valid_orgs_rs => $valid_orgs_rs, @@ -85,6 +85,7 @@ sub valid_edit { $validation->required('town'); $validation->optional('sector'); $validation->required('postcode')->postcode; + $validation->optional('pending'); if ( $validation->has_error ) { $c->flash( error => 'The validation has failed' ); @@ -101,6 +102,7 @@ sub valid_edit { town => $validation->param('town'), sector => $validation->param('sector'), postcode => $validation->param('postcode'), + pending => defined $validation->param('pending') ? 0 : 1, }); } ); } finally { diff --git a/lib/Pear/LocalLoop/Schema/Result/Entity.pm b/lib/Pear/LocalLoop/Schema/Result/Entity.pm index 121d560..0321049 100644 --- a/lib/Pear/LocalLoop/Schema/Result/Entity.pm +++ b/lib/Pear/LocalLoop/Schema/Result/Entity.pm @@ -51,4 +51,16 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +sub name { + my $self = shift; + + if ( $self->type eq 'customer' ) { + return $self->customer->display_name; + } elsif ( $self->type eq 'organisation' ) { + return $self->organisation->name; + } else { + return "Unknown Name"; + } +} + 1; diff --git a/templates/admin/organisations/list.html.ep b/templates/admin/organisations/list.html.ep index dad10cf..4db8974 100644 --- a/templates/admin/organisations/list.html.ep +++ b/templates/admin/organisations/list.html.ep @@ -20,7 +20,7 @@
% for my $valid_org ($valid_orgs_rs->all) { - +
%= $valid_org->name
@@ -41,7 +41,7 @@
% } else { % for my $pending_org ($pending_orgs_rs->all) { - +
%= $pending_org->name
diff --git a/templates/admin/organisations/valid_read.html.ep b/templates/admin/organisations/valid_read.html.ep index 2055496..5bbe739 100644 --- a/templates/admin/organisations/valid_read.html.ep +++ b/templates/admin/organisations/valid_read.html.ep @@ -15,20 +15,53 @@

%= $valid_org->name

- +