diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-09-11 15:15:52 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-09-11 15:15:52 +0100 |
commit | 459851ed73ed44af3583e8e82ec22b791fe9531a (patch) | |
tree | d7ba8eb658482cee7e424681a9bcf02d52d0cc75 | |
parent | 2cc255b912dc0f79de270be682a9e85d7fb95d7a (diff) | |
parent | 59f419a4f2ea2a94ba30b43d2dadb6c6fcab3729 (diff) |
Merge branch '1836-slash-category-bug'
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 48 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/ReportExtraFields.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/States.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 3 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 1 |
8 files changed, 11 insertions, 71 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index f1508f0b1..ed40f4565 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -27,7 +27,7 @@ Admin pages =cut -sub begin : Private { +sub auto : Private { my ( $self, $c ) = @_; $c->uri_disposition('relative'); @@ -44,10 +44,6 @@ sub begin : Private { if ( $c->cobrand->moniker eq 'zurich' ) { $c->cobrand->admin_type(); } -} - -sub auto : Private { - my ( $self, $c ) = @_; $c->forward('check_page_allowed'); } @@ -557,10 +553,10 @@ sub fetch_translations : Private { $c->stash->{translations} = $translations; } -sub lookup_body : Private { - my ( $self, $c ) = @_; +sub body : Chained('/') : PathPart('admin/body') : CaptureArgs(1) { + my ( $self, $c, $body_id ) = @_; - my $body_id = $c->stash->{body_id}; + $c->stash->{body_id} = $body_id; my $body = $c->model('DB::Body')->find($body_id); $c->detach( '/page_error_404_not_found', [] ) unless $body; @@ -572,30 +568,6 @@ sub lookup_body : Private { $c->stash->{example_pc} = $example_postcode; } } - - return 1; -} - -sub body_base : Chained('/') : PathPart('admin/body') : CaptureArgs(0) { } - -# This is for if the category name contains a '/' -sub category_edit_all : Chained('body_base') : PathPart('') { - my ( $self, $c, $body_id, @category ) = @_; - my $category = join( '/', @category ); - - $c->stash->{body_id} = $body_id; - $c->forward( 'lookup_body' ); - - my $contact = $c->stash->{body}->contacts->search( { category => $category } )->first; - $c->stash->{contact} = $contact; - - $c->stash->{template} = 'admin/category_edit.html'; - $c->forward( 'category_edit' ); -} - -sub body : Chained('body_base') : PathPart('') : CaptureArgs(1) { - my ( $self, $c, $body_id ) = @_; - $c->stash->{body_id} = $body_id; } sub edit_body : Chained('body') : PathPart('') : Args(0) { @@ -606,7 +578,6 @@ sub edit_body : Chained('body') : PathPart('') : Args(0) { } $c->forward( '/auth/get_csrf_token' ); - $c->forward( 'lookup_body' ); $c->forward( 'fetch_all_bodies' ); $c->forward( 'body_form_dropdowns' ); $c->forward('fetch_languages'); @@ -635,18 +606,15 @@ sub edit_body : Chained('body') : PathPart('') : Args(0) { return 1; } -sub category : Chained('body') : PathPart('') : CaptureArgs(1) { - my ( $self, $c, $category ) = @_; +sub category : Chained('body') : PathPart('') { + my ( $self, $c, @category ) = @_; + my $category = join( '/', @category ); $c->forward( '/auth/get_csrf_token' ); - $c->forward( 'lookup_body' ); + $c->stash->{template} = 'admin/category_edit.html'; my $contact = $c->stash->{body}->contacts->search( { category => $category } )->first; $c->stash->{contact} = $contact; -} - -sub category_edit : Chained('category') : PathPart('') : Args(0) { - my ( $self, $c ) = @_; $c->stash->{translation_col} = 'category'; $c->stash->{object} = $c->stash->{contact}; diff --git a/perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm b/perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm index ef4a0f219..5dab1da2c 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/DefectTypes.pm @@ -6,12 +6,6 @@ use mySociety::ArrayUtils; BEGIN { extends 'Catalyst::Controller'; } -sub begin : Private { - my ( $self, $c ) = @_; - - $c->forward('/admin/begin'); -} - sub index : Path : Args(0) { my ( $self, $c ) = @_; diff --git a/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm b/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm index 0fd9fe023..bdeecc1a3 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm @@ -9,12 +9,6 @@ use FixMyStreet::Integrations::ExorRDI; BEGIN { extends 'Catalyst::Controller'; } -sub begin : Private { - my ( $self, $c ) = @_; - - $c->forward('/admin/begin'); -} - sub index : Path : Args(0) { my ( $self, $c ) = @_; diff --git a/perllib/FixMyStreet/App/Controller/Admin/ReportExtraFields.pm b/perllib/FixMyStreet/App/Controller/Admin/ReportExtraFields.pm index d5ec64698..337fb4bed 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/ReportExtraFields.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/ReportExtraFields.pm @@ -6,12 +6,6 @@ use List::MoreUtils qw(uniq); BEGIN { extends 'Catalyst::Controller'; } -sub begin : Private { - my ( $self, $c ) = @_; - - $c->forward('/admin/begin'); -} - sub index : Path : Args(0) { my ( $self, $c ) = @_; diff --git a/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm b/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm index bae0f71a7..7983a6e4d 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm @@ -5,12 +5,6 @@ use namespace::autoclean; BEGIN { extends 'Catalyst::Controller'; } -sub begin : Private { - my ( $self, $c ) = @_; - - $c->forward('/admin/begin'); -} - sub index : Path : Args(0) { my ( $self, $c ) = @_; diff --git a/perllib/FixMyStreet/App/Controller/Admin/States.pm b/perllib/FixMyStreet/App/Controller/Admin/States.pm index e4c07c9ca..938692af0 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/States.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/States.pm @@ -4,12 +4,6 @@ use namespace::autoclean; BEGIN { extends 'Catalyst::Controller'; } -sub begin : Private { - my ( $self, $c ) = @_; - - $c->forward('/admin/begin'); -} - sub index : Path : Args(0) { my ( $self, $c ) = @_; diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index ea7aee016..5b80a4a08 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -19,9 +19,10 @@ Catalyst Controller. =cut -sub begin : Private { +sub auto : Private { my ($self, $c) = @_; $c->detach( '/auth/redirect' ) unless $c->user; + return 1; } =head2 index diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index 225fbfd41..03b20b087 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -695,6 +695,7 @@ subtest "only superuser can edit bodies" => sub { $user = $mech->log_in_ok( 'dm1@example.org' ); FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'zurich' ], + MAPIT_URL => 'http://mapit.zurich/', }, sub { $mech->get( '/admin/body/' . $zurich->id ); }; |