diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-08-30 14:37:32 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-09-05 11:59:51 +0100 |
commit | 0430d26eaab142a324206e6444f93d069e56b906 (patch) | |
tree | d055e6b15b0d664a3bb22789b6d4d658e6b393cc | |
parent | 2b8e2e59e63bd5a44070300c507546444296bafc (diff) |
Slightly simplify new report category handling.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 13 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 7 | ||||
-rw-r--r-- | t/app/model/problem.t | 9 |
3 files changed, 6 insertions, 23 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index c41b65e2a..dd7f3f5fa 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -143,6 +143,7 @@ sub report_new_ajax : Path('mobile') : Args(0) { $c->forward('setup_categories_and_bodies'); $c->forward('setup_report_extra_fields'); + $c->forward('check_for_category'); $c->forward('process_report'); $c->forward('process_user'); $c->forward('/photo/process_photo'); @@ -253,10 +254,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) { $c->forward('setup_report_extra_fields'); $c->forward('check_for_category'); - my $category = $c->stash->{category} || ""; - $category = '' if $category eq _('-- Pick a category --'); - - $c->stash->{json_response} = $c->forward('by_category_ajax_data', [ 'one', $category ]); + $c->stash->{json_response} = $c->forward('by_category_ajax_data', [ 'one', $c->stash->{category} ]); $c->forward('send_json_response'); } @@ -949,12 +947,12 @@ sub process_report : Private { 'title', 'detail', 'pc', # 'detail_size', 'may_show_name', # - 'category', # 'subcategory', # 'partial', # 'service', # 'non_public', ); + $params{category} = $c->stash->{category}; # load the report my $report = $c->stash->{report}; @@ -1520,9 +1518,10 @@ sub generate_map : Private { sub check_for_category : Private { my ( $self, $c ) = @_; - $c->stash->{category} = $c->get_param('category') || $c->stash->{report}->category; + my $category = $c->get_param('category') || ''; + $category = '' if $category eq _('Loading...') || $category eq _('-- Pick a category --'); + $c->stash->{category} = $category || $c->stash->{report}->category || ''; - return 1; } =head2 redirect_or_confirm_creation diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 09c6cb06d..8159d7251 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -376,13 +376,6 @@ sub check_for_errors { $errors{name} = _('Please enter your name'); } - if ( $self->category - && $self->category eq _('-- Pick a category --') ) - { - $errors{category} = _('Please choose a category'); - $self->category(undef); - } - return \%errors; } diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 503fa9276..e973febc1 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -106,15 +106,6 @@ for my $test ( } }, { - desc => 'bad category', - changed => { - category => '-- Pick a category --', - }, - errors => { - category => 'Please choose a category', - } - }, - { desc => 'correct category', changed => { category => 'Horse!', |