aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm18
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm12
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Body.pm10
-rw-r--r--perllib/FixMyStreet/DB/Result/Contact.pm16
-rw-r--r--perllib/FixMyStreet/DB/Result/ContactsHistory.pm6
-rw-r--r--perllib/FixMyStreet/SendReport/Email.pm2
-rw-r--r--perllib/FixMyStreet/SendReport/EmptyHomes.pm2
-rw-r--r--perllib/FixMyStreet/SendReport/NI.pm2
-rw-r--r--perllib/FixMyStreet/SendReport/Open311.pm2
11 files changed, 43 insertions, 31 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index fcbde1bd9..8c37f0f2e 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -233,15 +233,15 @@ sub council_list : Path('council_list') : Args(0) {
my $contacts = $c->model('DB::Contact')->search(
undef,
{
- select => [ 'area_id', { count => 'id' }, { count => \'case when deleted then 1 else null end' },
+ select => [ 'body_id', { count => 'id' }, { count => \'case when deleted then 1 else null end' },
{ count => \'case when confirmed then 1 else null end' } ],
- as => [qw/area_id c deleted confirmed/],
- group_by => [ 'area_id' ],
+ as => [qw/body_id c deleted confirmed/],
+ group_by => [ 'body_id' ],
result_class => 'DBIx::Class::ResultClass::HashRefInflator'
}
);
- my %council_info = map { $_->{area_id} => $_ } $contacts->all;
+ my %council_info = map { $_->{body_id} => $_ } $contacts->all;
my @no_info = grep { !$council_info{$_} } @councils_ids;
my @one_plus_deleted = grep { $council_info{$_} && $council_info{$_}->{deleted} } @councils_ids;
@@ -294,7 +294,7 @@ sub update_contacts : Private {
my $contact = $c->model('DB::Contact')->find_or_new(
{
- area_id => $c->stash->{area_id},
+ body_id => $c->stash->{area_id},
category => $category,
}
);
@@ -328,7 +328,7 @@ sub update_contacts : Private {
my $contacts = $c->model('DB::Contact')->search(
{
- area_id => $c->stash->{area_id},
+ body_id => $c->stash->{area_id},
category => { -in => \@categories },
}
);
@@ -390,7 +390,7 @@ sub display_contacts : Private {
my $area_id = $c->stash->{area_id};
my $contacts = $c->model('DB::Contact')->search(
- { area_id => $area_id },
+ { body_id => $area_id },
{ order_by => ['category'] }
);
@@ -450,7 +450,7 @@ sub council_edit : Path('council_edit') : Args(2) {
my $contact = $c->model('DB::Contact')->search(
{
- area_id => $area_id,
+ body_id => $area_id,
category => $category
}
)->first;
@@ -459,7 +459,7 @@ sub council_edit : Path('council_edit') : Args(2) {
my $history = $c->model('DB::ContactsHistory')->search(
{
- area_id => $area_id,
+ body_id => $area_id,
category => $category
},
{
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index 040b0d3e6..54faf906a 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -168,7 +168,7 @@ sub get_services : Private {
"4326/$lon,$lat",
type => $area_types);
$categories = $categories->search( {
- area_id => [ keys %$all_councils ],
+ body_id => [ keys %$all_councils ],
} );
}
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 823b38e02..57cf1de49 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -584,7 +584,7 @@ sub setup_categories_and_councils : Private {
= $c #
->model('DB::Contact') #
->not_deleted #
- ->search( { area_id => [ keys %$all_councils ] } ) #
+ ->search( { body_id => [ keys %$all_councils ] } ) #
->all;
# variables to populate
@@ -600,7 +600,7 @@ sub setup_categories_and_councils : Private {
# add all areas found to the list
foreach (@contacts) {
- $area_ids_to_list{ $_->area_id } = 1;
+ $area_ids_to_list{ $_->body_id } = 1;
}
# set our own categories
@@ -638,7 +638,7 @@ sub setup_categories_and_councils : Private {
my %seen;
foreach my $contact (@contacts) {
- $area_ids_to_list{ $contact->area_id } = 1;
+ $area_ids_to_list{ $contact->body_id } = 1;
unless ( $seen{$contact->category} ) {
push @category_options, $contact->category;
@@ -839,7 +839,7 @@ sub process_report : Private {
->not_deleted #
->search(
{
- area_id => [ keys %$councils ],
+ body_id => [ keys %$councils ],
category => $report->category
}
)->all;
@@ -853,7 +853,7 @@ sub process_report : Private {
# construct the council string:
# 'x,x' - x are council IDs that have this category
# 'x,x|y,y' - x are council IDs that have this category, y council IDs with *no* contact
- my $council_string = join( ',', map { $_->area_id } @contacts );
+ my $council_string = join( ',', map { $_->body_id } @contacts );
$council_string .=
'|' . join( ',', @{ $c->stash->{missing_details_councils} } )
if $council_string && @{ $c->stash->{missing_details_councils} };
@@ -879,7 +879,7 @@ sub process_report : Private {
$report->non_public( 1 );
}
- $c->cobrand->process_extras( $c, $contacts[0]->area_id, \@extra );
+ $c->cobrand->process_extras( $c, $contacts[0]->body_id, \@extra );
if ( @extra ) {
$c->stash->{report_meta} = { map { $_->{name} => $_ } @extra };
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 808959784..e13d915af 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -657,7 +657,7 @@ sub get_council_sender {
if ( $council_config && $council_config->can_be_devolved ) {
# look up via category
- my $config = FixMyStreet::App->model("DB::Contact")->search( { area_id => $area_id, category => $category } )->first;
+ my $config = FixMyStreet::App->model("DB::Contact")->search( { body_id => $area_id, category => $category } )->first;
if ( $config->send_method ) {
return { method => $config->send_method, config => $config };
} else {
diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm
index 76835cbde..6071ef33e 100644
--- a/perllib/FixMyStreet/DB/Result/Body.pm
+++ b/perllib/FixMyStreet/DB/Result/Body.pm
@@ -50,10 +50,16 @@ __PACKAGE__->belongs_to(
on_update => "CASCADE",
},
);
+__PACKAGE__->has_many(
+ "contacts",
+ "FixMyStreet::DB::Result::Contact",
+ { "foreign.body_id" => "self.id" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-12 16:29:16
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7G4lkjrgUBXKmadSuK8emA
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-13 12:34:57
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YiDf4mhoPlG5cnxCIrqZxw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm
index 0fef2f56b..b9bfd8610 100644
--- a/perllib/FixMyStreet/DB/Result/Contact.pm
+++ b/perllib/FixMyStreet/DB/Result/Contact.pm
@@ -18,8 +18,8 @@ __PACKAGE__->add_columns(
is_nullable => 0,
sequence => "contacts_id_seq",
},
- "area_id",
- { data_type => "integer", is_nullable => 0 },
+ "body_id",
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"category",
{ data_type => "text", default_value => "Other", is_nullable => 0 },
"email",
@@ -48,11 +48,17 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
);
__PACKAGE__->set_primary_key("id");
-__PACKAGE__->add_unique_constraint("contacts_area_id_category_idx", ["area_id", "category"]);
+__PACKAGE__->add_unique_constraint("contacts_body_id_category_idx", ["body_id", "category"]);
+__PACKAGE__->belongs_to(
+ "body",
+ "FixMyStreet::DB::Result::Body",
+ { id => "body_id" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-10 15:33:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:T1jcv40rbTqZbwDziGTYCA
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-13 12:34:33
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:imXq3EtrC0FrQwj+E2xfBw
__PACKAGE__->filter_column(
extra => {
diff --git a/perllib/FixMyStreet/DB/Result/ContactsHistory.pm b/perllib/FixMyStreet/DB/Result/ContactsHistory.pm
index deb00fb95..7126d91c9 100644
--- a/perllib/FixMyStreet/DB/Result/ContactsHistory.pm
+++ b/perllib/FixMyStreet/DB/Result/ContactsHistory.pm
@@ -20,7 +20,7 @@ __PACKAGE__->add_columns(
},
"contact_id",
{ data_type => "integer", is_nullable => 0 },
- "area_id",
+ "body_id",
{ data_type => "integer", is_nullable => 0 },
"category",
{ data_type => "text", default_value => "Other", is_nullable => 0 },
@@ -40,8 +40,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("contacts_history_id");
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dN2ueIDoP3d/+Mg1UDqsMw
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-12 16:37:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sxflEBBn0Mn0s3MroWnWFA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm
index b69436dd7..0aa5348e7 100644
--- a/perllib/FixMyStreet/SendReport/Email.pm
+++ b/perllib/FixMyStreet/SendReport/Email.pm
@@ -15,7 +15,7 @@ sub build_recipient_list {
my $contact = FixMyStreet::App->model("DB::Contact")->find( {
deleted => 0,
- area_id => $council,
+ body_id => $council,
category => $row->category
} );
diff --git a/perllib/FixMyStreet/SendReport/EmptyHomes.pm b/perllib/FixMyStreet/SendReport/EmptyHomes.pm
index 4a6f058fe..4eea72540 100644
--- a/perllib/FixMyStreet/SendReport/EmptyHomes.pm
+++ b/perllib/FixMyStreet/SendReport/EmptyHomes.pm
@@ -13,7 +13,7 @@ sub build_recipient_list {
foreach my $council ( keys %{ $self->councils } ) {
my $contact = FixMyStreet::App->model("DB::Contact")->find( {
deleted => 0,
- area_id => $council,
+ body_id => $council,
category => 'Empty property',
} );
diff --git a/perllib/FixMyStreet/SendReport/NI.pm b/perllib/FixMyStreet/SendReport/NI.pm
index 810ee60e2..482df7e90 100644
--- a/perllib/FixMyStreet/SendReport/NI.pm
+++ b/perllib/FixMyStreet/SendReport/NI.pm
@@ -12,7 +12,7 @@ sub build_recipient_list {
foreach my $council ( keys %{ $self->councils } ) {
my $contact = FixMyStreet::App->model("DB::Contact")->find( {
deleted => 0,
- area_id => $council,
+ body_id => $council,
category => $row->category
} );
diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm
index 8d7a418af..e2620f3b9 100644
--- a/perllib/FixMyStreet/SendReport/Open311.pm
+++ b/perllib/FixMyStreet/SendReport/Open311.pm
@@ -70,7 +70,7 @@ sub send {
# FIXME: we've already looked this up before
my $contact = FixMyStreet::App->model("DB::Contact")->find( {
deleted => 0,
- area_id => $conf->area_id,
+ body_id => $conf->area_id,
category => $row->category
} );