aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm19
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Buckinghamshire.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm39
5 files changed, 44 insertions, 24 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index acd6ddbf2..84651ad07 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -1647,7 +1647,7 @@ sub user_edit : Path('user_edit') : Args(1) {
if (!$user->from_body) {
# Non-staff users aren't allowed any permissions or to be in an area
$user->admin_user_body_permissions->delete;
- $user->area_id(undef);
+ $user->area_ids(undef);
delete $c->stash->{areas};
delete $c->stash->{fetched_areas_body_id};
} elsif ($c->stash->{available_permissions}) {
@@ -1667,8 +1667,8 @@ sub user_edit : Path('user_edit') : Args(1) {
if ( $user->from_body && $c->user->has_permission_to('user_assign_areas', $user->from_body->id) ) {
my %valid_areas = map { $_->{id} => 1 } @{ $c->stash->{areas} };
- my $new_area = $c->get_param('area_id');
- $user->area_id( $valid_areas{$new_area} ? $new_area : undef );
+ my @area_ids = grep { $valid_areas{$_} } $c->get_param_list('area_ids');
+ $user->area_ids( @area_ids ? \@area_ids : undef );
}
# Handle 'trusted' flag(s)
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index 7979f31f6..d597ff0ea 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -105,15 +105,18 @@ sub index : Path : Args(0) {
# See if we've had anything from the body dropdowns
$c->stash->{category} = $c->get_param('category');
- $c->stash->{ward} = $c->get_param('ward');
- if ($c->user_exists && $c->user->area_id) {
- $c->stash->{ward} = $c->user->area_id;
- $c->stash->{body_name} = join "", map { $children->{$_}->{name} } grep { $children->{$_} } $c->user->area_id;
+ $c->stash->{ward} = [ $c->get_param_list('ward') ];
+ if ($c->user_exists) {
+ if (my @areas = @{$c->user->area_ids || []}) {
+ $c->stash->{ward} = $c->user->area_ids;
+ $c->stash->{body_name} = join " / ", sort map { $children->{$_}->{name} } grep { $children->{$_} } @areas;
+ }
}
} else {
my @bodies = $c->model('DB::Body')->search(undef, {
columns => [ "id", "name" ],
})->active->translated->with_area_count->all_sorted;
+ $c->stash->{ward} = [];
$c->stash->{bodies} = \@bodies;
}
@@ -142,8 +145,8 @@ sub construct_rs_filter : Private {
my ($self, $c, $updates) = @_;
my %where;
- $where{areas} = { 'like', '%,' . $c->stash->{ward} . ',%' }
- if $c->stash->{ward};
+ $where{areas} = [ map { { 'like', "%,$_,%" } } @{$c->stash->{ward}} ]
+ if @{$c->stash->{ward}};
$where{category} = $c->stash->{category}
if $c->stash->{category};
@@ -298,7 +301,7 @@ sub csv_filename {
my %where = (
category => $c->stash->{category},
state => $c->stash->{q_state},
- ward => $c->stash->{ward},
+ ward => join(',', @{$c->stash->{ward}}),
);
$where{body} = $c->stash->{body}->id if $c->stash->{body};
join '-',
@@ -475,7 +478,7 @@ sub generate_csv : Private {
my $filename = $c->stash->{csv}->{filename};
$c->res->content_type('text/csv; charset=utf-8');
- $c->res->header('content-disposition' => "attachment; filename=${filename}.csv");
+ $c->res->header('content-disposition' => "attachment; filename=\"${filename}.csv\"");
$c->res->body( join "", @body );
}
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 975b2fdd5..4c28563de 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -450,7 +450,7 @@ sub summary : Private {
# required to stop errors in generate_grouped_data
$c->stash->{q_state} = '';
- $c->stash->{ward} = $c->get_param('area');
+ $c->stash->{ward} = [ $c->get_param('area') || () ];
$c->stash->{start_date} = $dtf->format_date($start_date);
$c->stash->{end_date} = $c->get_param('end_date');
diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
index ef9848f79..095e80604 100644
--- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
@@ -140,6 +140,8 @@ sub open311_contact_meta_override {
sub process_open311_extras {
my ($self, $c, $body, $extra) = @_;
+ return unless $c->stash->{report}; # Don't care about updates
+
$self->flytipping_body_fix(
$c->stash->{report},
$c->get_param('road-placement'),
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index c50f8834c..bf74e6934 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -36,16 +36,6 @@ __PACKAGE__->add_columns(
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
"is_superuser",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
- "title",
- { data_type => "text", is_nullable => 1 },
- "twitter_id",
- { data_type => "bigint", is_nullable => 1 },
- "facebook_id",
- { data_type => "bigint", is_nullable => 1 },
- "area_id",
- { data_type => "integer", is_nullable => 1 },
- "extra",
- { data_type => "text", is_nullable => 1 },
"created",
{
data_type => "timestamp",
@@ -60,6 +50,16 @@ __PACKAGE__->add_columns(
is_nullable => 0,
original => { default_value => \"now()" },
},
+ "title",
+ { data_type => "text", is_nullable => 1 },
+ "twitter_id",
+ { data_type => "bigint", is_nullable => 1 },
+ "facebook_id",
+ { data_type => "bigint", is_nullable => 1 },
+ "area_ids",
+ { data_type => "integer[]", is_nullable => 1 },
+ "extra",
+ { data_type => "text", is_nullable => 1 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("users_facebook_id_key", ["facebook_id"]);
@@ -119,8 +119,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07035 @ 2018-05-23 18:54:36
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/V7+Ygv/t6VX8dDhNGN16w
+# Created by DBIx::Class::Schema::Loader v0.07035 @ 2019-02-12 15:14:37
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4NBO3A+LfZXOh4Kj/II2LQ
# These are not fully unique constraints (they only are when the *_verified
# is true), but this is managed in ResultSet::User's find() wrapper.
@@ -597,4 +597,19 @@ sub set_last_active {
$self->last_active($time or \'current_timestamp');
}
+has areas_hash => (
+ is => 'ro',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+ my %ids = map { $_ => 1 } @{$self->area_ids || []};
+ return \%ids;
+ },
+);
+
+sub in_area {
+ my ($self, $area) = @_;
+ return $self->areas_hash->{$area};
+}
+
1;