aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Report/New.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm86
1 files changed, 36 insertions, 50 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 66dc20a3a..5df182506 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -221,7 +221,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
$c->forward('setup_categories_and_bodies');
$c->forward('check_for_category');
- my $category = $c->stash->{category};
+ my $category = $c->stash->{category} || "";
my $category_extra = '';
my $generate;
if ( $c->stash->{category_extras}->{$category} && @{ $c->stash->{category_extras}->{$category} } >= 1 ) {
@@ -616,58 +616,47 @@ sub setup_categories_and_bodies : Private {
$c->stash->{unresponsive} = {};
if (keys %bodies == 1 && $first_body->send_method && $first_body->send_method eq 'Refused') {
- $c->stash->{unresponsive}{ALL} = $first_body->id;
- }
-
- # FIXME - implement in cobrand
- if ( $c->cobrand->moniker eq 'emptyhomes' ) {
-
- # add all bodies found to the list
- foreach (@contacts) {
- $bodies_to_list{ $_->body_id } = 1;
+ # If there's only one body, and it's set to refused, we can show the
+ # message immediately, before they select a category.
+ if ($c->action->name eq 'category_extras_ajax' && $c->req->method eq 'POST') {
+ # The mobile app doesn't currently use this, in which case make
+ # sure the message is output, either below with a category, or when
+ # a blank category call is made.
+ $c->stash->{unresponsive}{""} = $first_body->id;
+ } else {
+ $c->stash->{unresponsive}{ALL} = $first_body->id;
}
+ }
- # set our own categories
- @category_options = (
- _('-- Pick a property type --'),
- _('Empty house or bungalow'),
- _('Empty flat or maisonette'),
- _('Whole block of empty flats'),
- _('Empty office or other commercial'),
- _('Empty pub or bar'),
- _('Empty public building - school, hospital, etc.')
- );
-
- } else {
-
- # keysort does not appear to obey locale so use strcoll (see i18n.t)
- @contacts = sort { strcoll( $a->category, $b->category ) } @contacts;
+ # keysort does not appear to obey locale so use strcoll (see i18n.t)
+ @contacts = sort { strcoll( $a->category, $b->category ) } @contacts;
- my %seen;
- foreach my $contact (@contacts) {
+ my %seen;
+ foreach my $contact (@contacts) {
- $bodies_to_list{ $contact->body_id } = 1;
+ $bodies_to_list{ $contact->body_id } = 1;
- unless ( $seen{$contact->category} ) {
- push @category_options, $contact->category;
+ unless ( $seen{$contact->category} ) {
+ push @category_options, $contact->category;
- my $metas = $contact->get_extra_fields;
- $category_extras{ $contact->category } = $metas
- if scalar @$metas;
+ my $metas = $contact->get_extra_fields;
+ $category_extras{ $contact->category } = $metas
+ if scalar @$metas;
- $c->stash->{unresponsive}{$contact->category} = $contact->body_id
- if $contact->email =~ /^REFUSED$/i;
+ my $body_send_method = $bodies{$contact->body_id}->send_method || '';
+ $c->stash->{unresponsive}{$contact->category} = $contact->body_id
+ if !$c->stash->{unresponsive}{ALL} &&
+ ($contact->email =~ /^REFUSED$/i || $body_send_method eq 'Refused');
- $non_public_categories{ $contact->category } = 1 if $contact->non_public;
- }
- $seen{$contact->category} = 1;
+ $non_public_categories{ $contact->category } = 1 if $contact->non_public;
}
+ $seen{$contact->category} = 1;
+ }
- if (@category_options) {
- # If there's an Other category present, put it at the bottom
- @category_options = ( _('-- Pick a category --'), grep { $_ ne _('Other') } @category_options );
- push @category_options, _('Other') if $seen{_('Other')};
- }
+ if (@category_options) {
+ # If there's an Other category present, put it at the bottom
+ @category_options = ( _('-- Pick a category --'), grep { $_ ne _('Other') } @category_options );
+ push @category_options, _('Other') if $seen{_('Other')};
}
$c->cobrand->munge_category_list(\@category_options, \@contacts, \%category_extras)
@@ -849,12 +838,7 @@ sub process_report : Private {
my $first_area = ( values %$areas )[0];
my $first_body = ( values %$bodies )[0];
- if ( $c->cobrand->moniker eq 'emptyhomes' ) {
-
- $bodies = join( ',', @{ $c->stash->{bodies_to_list} } ) || -1;
- $report->bodies_str( $bodies );
-
- } elsif ( $report->category ) {
+ if ( $report->category ) {
# FIXME All contacts were fetched in setup_categories_and_bodies,
# so can this DB call also be avoided?
@@ -1034,6 +1018,8 @@ sub tokenize_user : Private {
};
$c->stash->{token_data}{facebook_id} = $c->session->{oauth}{facebook_id}
if $c->get_param('oauth_need_email') && $c->session->{oauth}{facebook_id};
+ $c->stash->{token_data}{twitter_id} = $c->session->{oauth}{twitter_id}
+ if $c->get_param('oauth_need_email') && $c->session->{oauth}{twitter_id};
}
=head2 save_user_and_report
@@ -1061,7 +1047,7 @@ sub save_user_and_report : Private {
$report->bodies_str( undef ) if $report->bodies_str eq '-1';
# if there is a Message Manager message ID, pass it back to the client view
- if ($c->cobrand->moniker eq 'fixmybarangay' && $c->get_param('external_source_id') =~ /^\d+$/) {
+ if (($c->get_param('external_source_id') || "") =~ /^\d+$/) {
$c->stash->{external_source_id} = $c->get_param('external_source_id');
$report->external_source_id( $c->get_param('external_source_id') );
$report->external_source( $c->config->{MESSAGE_MANAGER_URL} ) ;