diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/SeeSomething.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 33 |
5 files changed, 31 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 2c4f73df3..10ef30c90 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -208,7 +208,7 @@ sub rss_area_ward : Path('/rss/area') : Args(2) { $url .= '/' . $c->cobrand->short_name( $c->stash->{ward} ) if $c->stash->{ward}; $c->stash->{qs} = "/$url"; - if ($c->stash->{area}{type} ne 'DIS' && $c->stash->{area}{type} ne 'CTY') { + if ($c->cobrand->moniker eq 'fixmystreet' && $c->stash->{area}{type} ne 'DIS' && $c->stash->{area}{type} ne 'CTY') { # UK-specific types - two possibilites are the same for one-tier councils, so redirect one to the other # With bodies, this should presumably redirect if only one body covers # the area, and then it will need that body's name (rather than diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 1ba6af139..ec7a8a81d 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -633,10 +633,10 @@ sub council_rss_alert_options { ( $_->{id_name} = $_->{short_name} ) =~ tr/+/_/; push @options, { type => 'council', - id => sprintf( 'council:%s:%s', $_->{id}, $_->{id_name} ), + id => sprintf( 'area:%s:%s', $_->{id}, $_->{id_name} ), text => sprintf( _('Problems within %s'), $_->{name}), rss_text => sprintf( _('RSS feed of problems within %s'), $_->{name}), - uri => $c->uri_for( '/rss/reports/' . $_->{short_name} ), + uri => $c->uri_for( '/rss/area/' . $_->{short_name} ), }; } diff --git a/perllib/FixMyStreet/Cobrand/SeeSomething.pm b/perllib/FixMyStreet/Cobrand/SeeSomething.pm index af386429c..5e6d3a8cd 100644 --- a/perllib/FixMyStreet/Cobrand/SeeSomething.pm +++ b/perllib/FixMyStreet/Cobrand/SeeSomething.pm @@ -86,6 +86,7 @@ sub admin_stats { my %filters = (); + # XXX The below lookup assumes a body ID === MapIt area ID my %councils = map { my $name = $_->name; diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index ecea34ddf..65930a092 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -1,6 +1,8 @@ package FixMyStreet::Cobrand::UKCouncils; use base 'FixMyStreet::Cobrand::UK'; +# XXX Things using this cobrand base assume that a body ID === MapIt area ID + use strict; use warnings; diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 5b063ebe5..72a6810bc 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -534,6 +534,17 @@ sub get_ok_json { return decode_json( $res->content ); } +sub delete_body { + my $mech = shift; + my $body = shift; + + $mech->delete_problems_for_body($body->id); + $body->contacts->delete; + $mech->delete_user($_) for $body->users; + $body->body_areas->delete; + $body->delete; +} + sub delete_problems_for_body { my $mech = shift; my $body = shift; @@ -542,6 +553,7 @@ sub delete_problems_for_body { if ( $reports ) { for my $r ( $reports->all ) { $r->comments->delete; + $r->questionnaires->delete; } $reports->delete; } @@ -549,16 +561,21 @@ sub delete_problems_for_body { sub create_body_ok { my $self = shift; - my ( $id, $name ) = @_; - - my $params = { id => $id, name => $name }; - my $body = FixMyStreet::App->model('DB::Body')->find_or_create($params); - $body->update($params); # Make sure - ok $body, "found/created user for $id $name"; + my ( $area_id, $name, %extra ) = @_; + + my $body = FixMyStreet::App->model('DB::Body'); + my $params = { name => $name }; + if ($extra{id}) { + $body = $body->update_or_create({ %$params, id => $extra{id} }, { key => 'primary' }); + } else { + $body = $body->find_or_create($params); + } + ok $body, "found/created body $name"; + $body->body_areas->delete; FixMyStreet::App->model('DB::BodyArea')->find_or_create({ - area_id => $id, - body_id => $id, + area_id => $area_id, + body_id => $body->id, }); return $body; |