aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/open311-populate-service-list2
-rw-r--r--bin/open311-update-reports2
-rwxr-xr-xbin/send-comments2
-rw-r--r--db/schema.sql6
-rw-r--r--db/schema_0027-rename_open311conf.sql12
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm6
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Body.pm (renamed from perllib/FixMyStreet/DB/Result/Open311conf.pm)14
-rw-r--r--perllib/FixMyStreet/DB/Result/Contact.pm4
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm16
-rw-r--r--perllib/FixMyStreet/SendReport/Barnet.pm2
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm2
-rw-r--r--perllib/Open311/PopulateServiceList.pm2
-rw-r--r--t/app/controller/admin.t6
-rw-r--r--t/app/controller/report_new_open311.t2
-rw-r--r--t/cobrand/get_council_sender.t2
-rw-r--r--t/open311/populate-service-list.t18
18 files changed, 59 insertions, 47 deletions
diff --git a/bin/open311-populate-service-list b/bin/open311-populate-service-list
index 232b0a6d4..a0bee2992 100755
--- a/bin/open311-populate-service-list
+++ b/bin/open311-populate-service-list
@@ -14,7 +14,7 @@ my ($opt, $usage) = describe_options(
);
print($usage->text), exit if $opt->help;
-my $council_list = FixMyStreet::App->model('DB::Open311conf')->search( {
+my $council_list = FixMyStreet::App->model('DB::Body')->search( {
send_method => 'Open311'
} );
my $verbose = 0;
diff --git a/bin/open311-update-reports b/bin/open311-update-reports
index 41c9c4546..e7ff34273 100644
--- a/bin/open311-update-reports
+++ b/bin/open311-update-reports
@@ -13,7 +13,7 @@ my $system_user = FixMyStreet::App->model('DB::User')->find_or_create(
}
);
-my $council_list = FixMyStreet::App->model('DB::Open311conf');
+my $council_list = FixMyStreet::App->model('DB::Body');
my $update = Open311::GetUpdates->new(
council_list => $council_list,
diff --git a/bin/send-comments b/bin/send-comments
index 4955cb2f3..caf4b8b91 100755
--- a/bin/send-comments
+++ b/bin/send-comments
@@ -35,7 +35,7 @@ my ($verbose, $nomail) = CronFns::options();
my $base_url = mySociety::Config::get('BASE_URL');
my $site = CronFns::site($base_url);
-my $councils = FixMyStreet::App->model('DB::Open311Conf')->search( {
+my $councils = FixMyStreet::App->model('DB::Body')->search( {
send_method => SEND_METHOD_OPEN311,
send_comments => 1,
} );
diff --git a/db/schema.sql b/db/schema.sql
index 6ebec5689..87b5102c7 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -447,12 +447,12 @@ create table admin_log (
whenedited timestamp not null default ms_current_timestamp()
);
--- Record open 311 configuration details
+-- Record details of reporting bodies, including open311 configuration details
-create table open311conf (
+create table body (
id serial primary key,
area_id integer not null unique,
- endpoint text not null,
+ endpoint text,
jurisdiction text,
api_key text,
send_method text,
diff --git a/db/schema_0027-rename_open311conf.sql b/db/schema_0027-rename_open311conf.sql
new file mode 100644
index 000000000..cef020648
--- /dev/null
+++ b/db/schema_0027-rename_open311conf.sql
@@ -0,0 +1,12 @@
+begin;
+
+ALTER TABLE open311conf RENAME TO body;
+ALTER INDEX open311conf_pkey RENAME TO body_pkey;
+ALTER INDEX open311conf_area_id_key RENAME TO body_area_id_key;
+ALTER TABLE body ALTER COLUMN endpoint DROP NOT NULL;
+ALTER TABLE body DROP CONSTRAINT open311conf_comment_user_id_fkey;
+ALTER TABLE body ADD CONSTRAINT body_comment_user_id_fkey
+ FOREIGN KEY (comment_user_id) REFERENCES users(id);
+ALTER SEQUENCE open311conf_id_seq RENAME TO body_id_seq;
+
+commit;
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 4999d16f2..a96562cd6 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -349,7 +349,7 @@ sub update_contacts : Private {
my %params = map { $_ => $c->req->param($_) || '' } qw/open311_id endpoint jurisdiction api_key area_id send_method send_comments suppress_alerts comment_user_id devolved/;
if ( $params{open311_id} ) {
- my $conf = $c->model('DB::Open311Conf')->find( { id => $params{open311_id} } );
+ my $conf = $c->model('DB::Body')->find( { id => $params{open311_id} } );
$conf->endpoint( $params{endpoint} );
$conf->jurisdiction( $params{jurisdiction} );
@@ -364,7 +364,7 @@ sub update_contacts : Private {
$c->stash->{updated} = _('Configuration updated');
} else {
- my $conf = $c->model('DB::Open311Conf')->find_or_new( { area_id => $params{area_id} } );
+ my $conf = $c->model('DB::Body')->find_or_new( { area_id => $params{area_id} } );
$conf->endpoint( $params{endpoint} );
$conf->jurisdiction( $params{jurisdiction} );
@@ -399,7 +399,7 @@ sub display_contacts : Private {
my @methods = map { $_ =~ s/FixMyStreet::SendReport:://; $_ } keys %{ FixMyStreet::SendReport->get_senders };
$c->stash->{send_methods} = \@methods;
- my $open311 = $c->model('DB::Open311Conf')->search(
+ my $open311 = $c->model('DB::Body')->search(
{ area_id => $area_id }
);
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 86ea693b7..46ec47d9e 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -652,7 +652,7 @@ sub get_council_sender {
my $send_method;
- my $council_config = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => $area_id } )->first;
+ my $council_config = FixMyStreet::App->model("DB::Body")->search( { area_id => $area_id } )->first;
$send_method = $council_config->send_method if $council_config;
if ( $council_config && $council_config->can_be_devolved ) {
diff --git a/perllib/FixMyStreet/DB/Result/Open311conf.pm b/perllib/FixMyStreet/DB/Result/Body.pm
index 8051e27de..76835cbde 100644
--- a/perllib/FixMyStreet/DB/Result/Open311conf.pm
+++ b/perllib/FixMyStreet/DB/Result/Body.pm
@@ -1,5 +1,5 @@
use utf8;
-package FixMyStreet::DB::Result::Open311conf;
+package FixMyStreet::DB::Result::Body;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
@@ -9,19 +9,19 @@ use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
-__PACKAGE__->table("open311conf");
+__PACKAGE__->table("body");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
is_auto_increment => 1,
is_nullable => 0,
- sequence => "open311conf_id_seq",
+ sequence => "body_id_seq",
},
"area_id",
{ data_type => "integer", is_nullable => 0 },
"endpoint",
- { data_type => "text", is_nullable => 0 },
+ { data_type => "text", is_nullable => 1 },
"jurisdiction",
{ data_type => "text", is_nullable => 1 },
"api_key",
@@ -38,7 +38,7 @@ __PACKAGE__->add_columns(
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
-__PACKAGE__->add_unique_constraint("open311conf_area_id_key", ["area_id"]);
+__PACKAGE__->add_unique_constraint("body_area_id_key", ["area_id"]);
__PACKAGE__->belongs_to(
"comment_user",
"FixMyStreet::DB::Result::User",
@@ -52,8 +52,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-08-29 14:04:20
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Yoult8K/ldH6DMAKURtr3Q
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-12 16:29:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7G4lkjrgUBXKmadSuK8emA
# 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 993e3524b..0fef2f56b 100644
--- a/perllib/FixMyStreet/DB/Result/Contact.pm
+++ b/perllib/FixMyStreet/DB/Result/Contact.pm
@@ -51,8 +51,8 @@ __PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("contacts_area_id_category_idx", ["area_id", "category"]);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-08-31 10:29:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:t6yOPhZmedV/eH6AUvHI6w
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-10 15:33:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:T1jcv40rbTqZbwDziGTYCA
__PACKAGE__->filter_column(
extra => {
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index ce197076b..ae5815143 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -99,7 +99,7 @@ __PACKAGE__->add_columns(
"external_source_id",
{ data_type => "text", is_nullable => 1 },
"interest_count",
- { data_type => "integer", is_nullable => 1 },
+ { data_type => "integer", default_value => 0, is_nullable => 1 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->has_many(
@@ -122,8 +122,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-08-31 10:25:34
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mudIAiLAUdmK8gGWIPiq6g
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-10 15:33:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YZzkUjX7Dsxcsm4bXZjIYg
# Add fake relationship to stored procedure table
__PACKAGE__->has_one(
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index 7f43d1a52..1baf15ad1 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -42,15 +42,15 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
- "comments",
- "FixMyStreet::DB::Result::Comment",
- { "foreign.user_id" => "self.id" },
+ "bodies",
+ "FixMyStreet::DB::Result::Body",
+ { "foreign.comment_user_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
- "open311confs",
- "FixMyStreet::DB::Result::Open311conf",
- { "foreign.comment_user_id" => "self.id" },
+ "comments",
+ "FixMyStreet::DB::Result::Comment",
+ { "foreign.user_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
@@ -61,8 +61,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-05-01 16:20:29
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LKi8u5IYnHW1+Mez64nvGg
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-10 15:34:40
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6KOp2hcVLqx28Po7uENTnA
__PACKAGE__->add_columns(
"password" => {
diff --git a/perllib/FixMyStreet/SendReport/Barnet.pm b/perllib/FixMyStreet/SendReport/Barnet.pm
index 9a92686ec..4bee50e57 100644
--- a/perllib/FixMyStreet/SendReport/Barnet.pm
+++ b/perllib/FixMyStreet/SendReport/Barnet.pm
@@ -80,7 +80,7 @@ sub send {
? $h{query} : $nearest_postcode; # use given postcode if available
# note: endpoint can be of form 'https://username:password@url'
- my $council_config = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => COUNCIL_ID_BARNET} )->first;
+ my $council_config = FixMyStreet::App->model("DB::Body")->search( { area_id => COUNCIL_ID_BARNET} )->first;
if ($council_config and $council_config->endpoint) {
$interface->set_proxy($council_config->endpoint);
# Barnet web service doesn't like namespaces in the elements so use a prefix
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index 0b4e037fd..0b71907a0 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -15,7 +15,7 @@ has verbose => ( is => 'ro', default => 0 );
sub fetch {
my $self = shift;
- my $councils = FixMyStreet::App->model('DB::Open311Conf')->search(
+ my $councils = FixMyStreet::App->model('DB::Body')->search(
{
send_method => 'Open311',
send_comments => 1,
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm
index e8ae56833..8637e8431 100644
--- a/perllib/Open311/PopulateServiceList.pm
+++ b/perllib/Open311/PopulateServiceList.pm
@@ -14,7 +14,7 @@ has _current_council => ( is => 'rw' );
has _current_open311 => ( is => 'rw' );
has _current_service => ( is => 'rw' );
-my $council_list = FixMyStreet::App->model('DB::Open311conf');
+my $council_list = FixMyStreet::App->model('DB::Body');
sub process_councils {
my $self = shift;
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 9ec15ec21..43684a206 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -236,7 +236,7 @@ subtest 'check contact updating' => sub {
};
my $open311 =
- FixMyStreet::App->model('DB::Open311Conf')->search( { area_id => 2650 } );
+ FixMyStreet::App->model('DB::Body')->search( { area_id => 2650 } );
$open311->delete if $open311;
subtest 'check open311 configuring' => sub {
@@ -259,7 +259,7 @@ subtest 'check open311 configuring' => sub {
$mech->content_contains('Configuration updated - contacts will be generated automatically later');
$open311 =
- FixMyStreet::App->model('DB::Open311Conf')->search( { area_id => 2650 } );
+ FixMyStreet::App->model('DB::Body')->search( { area_id => 2650 } );
is $open311->count, 1, 'only one configuration';
my $conf = $open311->first;
@@ -283,7 +283,7 @@ subtest 'check open311 configuring' => sub {
$mech->content_contains('Configuration updated');
$open311 =
- FixMyStreet::App->model('DB::Open311Conf')->search( { area_id => 2650 } );
+ FixMyStreet::App->model('DB::Body')->search( { area_id => 2650 } );
is $open311->count, 1, 'only one configuration';
$conf = $open311->first;
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index 55c5a92e8..4b009c746 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -7,7 +7,7 @@ use Web::Scraper;
my $mech = FixMyStreet::TestMech->new;
-my $open311Conf = FixMyStreet::App->model('DB::Open311Conf')->find_or_create( {
+FixMyStreet::App->model('DB::Body')->find_or_create( {
area_id => 2651,
endpoint => 'http://example.com/open311',
jurisdiction => 'mySociety',
diff --git a/t/cobrand/get_council_sender.t b/t/cobrand/get_council_sender.t
index e61f36370..c05864d8a 100644
--- a/t/cobrand/get_council_sender.t
+++ b/t/cobrand/get_council_sender.t
@@ -16,7 +16,7 @@ my $c = FixMyStreet::Cobrand::FixMyStreet->new();
is_deeply $c->get_council_sender( '1000', { type => 'DIS' } ), { method => 'Email' }, 'defaults to email';
is_deeply $c->get_council_sender( '1000', { type => 'LBO' } ), { method=> 'London' }, 'returns london report it if London borough';
-my $conf = FixMyStreet::App->model('DB::Open311Conf')->find_or_create(
+my $conf = FixMyStreet::App->model('DB::Body')->find_or_create(
area_id => 1000,
endpoint => '',
send_method => 'TestMethod'
diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t
index 00026cd9f..8c23e6465 100644
--- a/t/open311/populate-service-list.t
+++ b/t/open311/populate-service-list.t
@@ -24,7 +24,7 @@ subtest 'check basic functionality' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
+ my $council = FixMyStreet::App->model('DB::Body')->new( {
area_id => 1
} );
@@ -54,7 +54,7 @@ subtest 'check non open311 contacts marked as deleted' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
+ my $council = FixMyStreet::App->model('DB::Body')->new( {
area_id => 1
} );
@@ -89,7 +89,7 @@ subtest 'check email changed if matching category' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
+ my $council = FixMyStreet::App->model('DB::Body')->new( {
area_id => 1
} );
@@ -126,7 +126,7 @@ subtest 'check category name changed if updated' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
+ my $council = FixMyStreet::App->model('DB::Body')->new( {
area_id => 1
} );
@@ -179,7 +179,7 @@ subtest 'check conflicting contacts not changed' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Open311Conf')->new( {
+ my $council = FixMyStreet::App->model('DB::Body')->new( {
area_id => 1
} );
@@ -243,7 +243,7 @@ subtest 'check meta data population' => sub {
test_get_returns => { 'services/100.xml' => $meta_xml }
);
- my $council = FixMyStreet::App->model('DB::Open311conf')->new( {
+ my $council = FixMyStreet::App->model('DB::Body')->new( {
area_id => 2482
} );
@@ -432,7 +432,7 @@ for my $test (
my $service_list = get_xml_simple_object( $services_xml );
$service_list = { service => [ $service_list->{ service } ] };
- my $council = FixMyStreet::App->model('DB::Open311conf')->new( {
+ my $council = FixMyStreet::App->model('DB::Body')->new( {
area_id => 1
} );
@@ -505,7 +505,7 @@ subtest 'check attribute ordering' => sub {
test_get_returns => { 'services/100.xml' => $meta_xml }
);
- my $council = FixMyStreet::App->model('DB::Open311conf')->new( {
+ my $council = FixMyStreet::App->model('DB::Body')->new( {
area_id => 1
} );
@@ -611,7 +611,7 @@ subtest 'check bromely skip code' => sub {
test_get_returns => { 'services/100.xml' => $meta_xml }
);
- my $council = FixMyStreet::App->model('DB::Open311conf')->new( {
+ my $council = FixMyStreet::App->model('DB::Body')->new( {
area_id => 2482
} );