diff options
author | Marius Halden <marius.h@lden.org> | 2017-05-28 21:31:42 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2017-05-28 21:31:42 +0200 |
commit | 987124b09a32248414faf4d0d6615d43b29ac6f6 (patch) | |
tree | a549db8af723c981d3b346e855f25d6fd5ff8aa7 /perllib/FixMyStreet/Cobrand | |
parent | dbf56159e44c1560a413022451bf1a1c4cb22a52 (diff) | |
parent | a085b63ce09f87e83b75cda9b9cd08aadfe75d61 (diff) |
Merge tag 'v2.0.4' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/Cobrand')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Base.pm | 26 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bristol.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 33 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 58 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FiksGataMi.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 21 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixaMinGata.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Greenwich.pm | 15 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Harrogate.pm | 290 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 89 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/SeeSomething.pm | 135 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UK.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/WestBerkshire.pm | 16 |
14 files changed, 235 insertions, 475 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Base.pm b/perllib/FixMyStreet/Cobrand/Base.pm index 5a9842233..ea2b8f410 100644 --- a/perllib/FixMyStreet/Cobrand/Base.pm +++ b/perllib/FixMyStreet/Cobrand/Base.pm @@ -38,6 +38,20 @@ sub moniker { return $last_part; } +=head2 asset_moniker + + $moniker = $cobrand_class->asset_moniker(); + +Same as moniker, except for the cobrand with the 'fixmystreet' moniker, when it +returns 'fixmystreet.com', as to avoid confusion that's where its assets are. + +=cut + +sub asset_moniker { + my $self = shift; + return $self->moniker eq 'fixmystreet' ? 'fixmystreet.com' : $self->moniker; +} + =head2 is_default $bool = $cobrand->is_default(); @@ -51,6 +65,18 @@ sub is_default { return $self->moniker eq 'default'; } +=head2 call_hook + + $cobrand->call_hook(foo => 1, 2, 3); # calls $cobrand->foo(1, 2, 3) if it exists + +=cut + +sub call_hook { + my ($self, $method_name, @args) = @_; + my $method = $self->can($method_name) or return; + return $self->$method(@args); +} + # NB: this Base class is for 'meta' features. To add base methods for all cobrands, # you may want to look at FMS::Cobrand::Default instead! diff --git a/perllib/FixMyStreet/Cobrand/Bristol.pm b/perllib/FixMyStreet/Cobrand/Bristol.pm index ecb19b867..fa7f98666 100644 --- a/perllib/FixMyStreet/Cobrand/Bristol.pm +++ b/perllib/FixMyStreet/Cobrand/Bristol.pm @@ -40,6 +40,10 @@ sub disambiguate_location { }; } +sub get_geocoder { + return 'OSM'; # use OSM geocoder +} + sub pin_colour { my ( $self, $p, $context ) = @_; return 'grey' if $p->state eq 'not responsible'; diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index 2d0cb86f1..169175947 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -3,6 +3,7 @@ use parent 'FixMyStreet::Cobrand::UKCouncils'; use strict; use warnings; +use DateTime::Format::W3CDTF; sub council_id { return 2482; } sub council_area { return 'Bromley'; } @@ -111,5 +112,37 @@ sub title_list { return ["MR", "MISS", "MRS", "MS", "DR"]; } +sub open311_config { + my ($self, $row, $h, $params) = @_; + + my $extra = $row->get_extra_fields; + push @$extra, + { name => 'report_url', + value => $h->{url} }, + { name => 'report_title', + value => $row->title }, + { name => 'public_anonymity_required', + value => $row->anonymous ? 'TRUE' : 'FALSE' }, + { name => 'email_alerts_requested', + value => 'FALSE' }, # always false as can never request them + { name => 'requested_datetime', + value => DateTime::Format::W3CDTF->format_datetime($row->confirmed->set_nanosecond(0)) }, + { name => 'email', + value => $row->user->email }; + + # make sure we have last_name attribute present in row's extra, so + # it is passed correctly to Bromley as attribute[] + if ( $row->cobrand ne 'bromley' ) { + my ( $firstname, $lastname ) = ( $row->name =~ /(\w+)\.?\s+(.+)/ ); + push @$extra, { name => 'last_name', value => $lastname }; + } + + $row->set_extra_fields(@$extra); + + $params->{always_send_latlong} = 0; + $params->{send_notpinpointed} = 1; + $params->{extended_description} = 0; +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 27111deb2..ac70fff08 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -209,14 +209,14 @@ sub base_url { FixMyStreet->config('BASE_URL') } =head2 base_url_for_report Return the base url for a report (might be different in a two-tier county, but -most of the time will be same as base_url). Report may be an object, or a -hashref. +most of the time will be same as base_url_with_lang). Report may be an object, +or a hashref. =cut sub base_url_for_report { my ( $self, $report ) = @_; - return $self->base_url; + return $self->base_url_with_lang; } =head2 base_host @@ -646,27 +646,26 @@ sub admin_pages { $pages->{config} = [ _('Configuration'), 9]; }; # And some that need special permissions - if ( $user->is_superuser || $user->has_body_permission_to('category_edit') ) { + if ( $user->has_body_permission_to('category_edit') ) { my $page_title = $user->is_superuser ? _('Bodies') : _('Categories'); $pages->{bodies} = [ $page_title, 1 ]; $pages->{body} = [ undef, undef ]; } - if ( $user->is_superuser || $user->has_body_permission_to('report_edit') ) { + if ( $user->has_body_permission_to('report_edit') ) { $pages->{reports} = [ _('Reports'), 2 ]; $pages->{report_edit} = [ undef, undef ]; $pages->{update_edit} = [ undef, undef ]; $pages->{abuse_edit} = [ undef, undef ]; } - if ( $user->is_superuser || $user->has_body_permission_to('template_edit') ) { + if ( $user->has_body_permission_to('template_edit') ) { $pages->{templates} = [ _('Templates'), 3 ]; $pages->{template_edit} = [ undef, undef ]; }; - if ( $user->is_superuser || $user->has_body_permission_to('responsepriority_edit') ) { + if ( $user->has_body_permission_to('responsepriority_edit') ) { $pages->{responsepriorities} = [ _('Priorities'), 4 ]; $pages->{responsepriority_edit} = [ undef, undef ]; }; - - if ( $user->is_superuser || $user->has_body_permission_to('user_edit') ) { + if ( $user->has_body_permission_to('user_edit') ) { $pages->{users} = [ _('Users'), 6 ]; $pages->{user_edit} = [ undef, undef ]; } @@ -713,6 +712,7 @@ sub available_permissions { planned_reports => _("Manage shortlist"), contribute_as_another_user => _("Create reports/updates on a user's behalf"), contribute_as_body => _("Create reports/updates as the council"), + view_body_contribute_details => _("See user detail for reports created as the council"), # NB this permission is special in that it can be assigned to users # without their from_body being set. It's included here for @@ -873,13 +873,11 @@ sub get_body_sender { # look up via category my $contact = $body->contacts->search( { category => $category } )->first; - if ( $body->can_be_devolved ) { - if ( $contact->send_method ) { - return { method => $contact->send_method, config => $contact, contact => $contact }; - } else { - return { method => $body->send_method, config => $body, contact => $contact }; - } - } elsif ( $body->send_method ) { + if ( $body->can_be_devolved && $contact->send_method ) { + return { method => $contact->send_method, config => $contact, contact => $contact }; + } + + if ( $body->send_method ) { return { method => $body->send_method, config => $body, contact => $contact }; } @@ -1187,4 +1185,32 @@ sub category_extra_hidden { return 0; } +=head2 reputation_increment_states/reputation_decrement_states + +Get a hashref of states that cause the reporting user's reputation to be +incremented/decremented, if a report is changed to this state upon inspection. + +=cut + +sub reputation_increment_states { {} }; +sub reputation_decrement_states { {} }; + +sub traffic_management_options { + return [ + _("Yes"), + _("No"), + ]; +} + + +=head2 display_days_ago_threshold + +Used to control whether a relative 'n days ago' or absolute date is shown +for problems/updates. If a problem/update's `days_ago` value is <= this figure, +the 'n days ago' format is used. By default the absolute date is always used. + +=cut +sub display_days_ago_threshold { 0 } + + 1; diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm index 5e2473280..0f8516afc 100644 --- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm +++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm @@ -37,7 +37,7 @@ sub pin_colour { sub area_types { my $self = shift; - return $self->next::method() if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING'); + return $self->next::method() if FixMyStreet->staging_flag('skip_checks'); [ 'NKO', 'NFY', 'NRA' ]; } diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index 1fb822893..1052bac0e 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -60,26 +60,5 @@ sub extra_contact_validation { return %errors; } -sub report_form_extras { - ( { name => 'gender', required => 0 }, { name => 'variant', required => 0 } ) -} - -sub ask_gender_question { - my $self = shift; - - return 1 unless $self->{c}->user; - - my $reports = $self->{c}->model('DB::Problem')->search({ - user_id => $self->{c}->user->id, - extra => { like => '%gender%' } - }, { order_by => { -desc => 'id' } }); - - while (my $report = $reports->next) { - my $gender = $report->get_extra_metadata('gender'); - return 0 if $gender =~ /female|male|other|unknown/; - } - return 1; -} - 1; diff --git a/perllib/FixMyStreet/Cobrand/FixaMinGata.pm b/perllib/FixMyStreet/Cobrand/FixaMinGata.pm index 5b78b3fa1..324811008 100644 --- a/perllib/FixMyStreet/Cobrand/FixaMinGata.pm +++ b/perllib/FixMyStreet/Cobrand/FixaMinGata.pm @@ -31,7 +31,7 @@ sub disambiguate_location { sub area_types { my $self = shift; - return $self->next::method() if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING'); + return $self->next::method() if FixMyStreet->staging_flag('skip_checks'); [ 'KOM' ]; } diff --git a/perllib/FixMyStreet/Cobrand/Greenwich.pm b/perllib/FixMyStreet/Cobrand/Greenwich.pm index 7777079a9..700a12782 100644 --- a/perllib/FixMyStreet/Cobrand/Greenwich.pm +++ b/perllib/FixMyStreet/Cobrand/Greenwich.pm @@ -55,4 +55,19 @@ sub contact_email { return join( '@', 'fixmystreet', 'royalgreenwich.gov.uk' ); } +sub reports_per_page { return 20; } + +sub on_map_default_max_pin_age { + return '21 days'; +} + +sub open311_config { + my ($self, $row, $h, $params) = @_; + + my $extra = $row->get_extra_fields; + # Greenwich doesn't have category metadata to fill this + push @$extra, { name => 'external_id', value => $row->id }; + $row->set_extra_fields( @$extra ); +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/Harrogate.pm b/perllib/FixMyStreet/Cobrand/Harrogate.pm deleted file mode 100644 index 8f4a6e2ea..000000000 --- a/perllib/FixMyStreet/Cobrand/Harrogate.pm +++ /dev/null @@ -1,290 +0,0 @@ -package FixMyStreet::Cobrand::Harrogate; -use base 'FixMyStreet::Cobrand::UKCouncils'; - -use strict; -use warnings; -use feature 'say'; - -sub council_id { return 2407; } -sub council_area { return 'Harrogate'; } -sub council_name { return 'Harrogate Borough Council'; } -sub council_url { return 'harrogate'; } -sub is_two_tier { return 1; } # with North Yorkshire CC 2235 - -sub base_url { - my $self = shift; - return $self->next::method() if FixMyStreet->config('STAGING_SITE'); - return 'http://fix.harrogate.gov.uk'; -} - -sub disambiguate_location { - my $self = shift; - my $string = shift; - - my $town = 'Harrogate'; - - # as it's the requested example location, try to avoid a disambiguation page - $town .= ', HG1 1DH' if $string =~ /^\s*king'?s\s+r(?:oa)?d\s*(?:,\s*har\w+\s*)?$/i; - - return { - %{ $self->SUPER::disambiguate_location() }, - town => $town, - centre => '54.0671557690306,-1.59581319536637', - span => '0.370193897090822,0.829517054931808', - bounds => [ 53.8914112467619, -2.00450542308575, 54.2616051438527, -1.17498836815394 ], - }; -} - -sub example_places { - return ( 'HG1 2SG', "King's Road" ); -} - -sub enter_postcode_text { - my ($self) = @_; - return 'Enter a Harrogate district postcode, or street name and area'; -} - -# increase map zoom level so street names are visible -sub default_map_zoom { return 3; } - - -=head2 temp_email_to_update, temp_update_contacts - -Temporary helper routines to update the extra for potholes (temporary setup -hack, cargo-culted from ESCC, may in future be superseded either by -Open311/integration or a better mechanism for manually creating rich contacts). - -Can run with a script or command line like: - - bin/cron-wrapper perl -MFixMyStreet::App -MFixMyStreet::Cobrand::Harrogate -e \ - 'FixMyStreet::Cobrand::Harrogate->new({c => FixMyStreet::App->new})->temp_update_contacts' - -=cut - -sub temp_email_to_update { - return 'CustomerServices@harrogate.gov.uk'; -} - -sub temp_update_contacts { - my $self = shift; - - my $contact_rs = $self->{c}->model('DB::Contact'); - - my $email = $self->temp_email_to_update; - my $_update = sub { - my ($category, $field, $category_details) = @_; - # NB: we're accepting just 1 field, but supply as array [ $field ] - - my $contact = $contact_rs->find_or_create( - { - body_id => $self->council_id, - category => $category, - - confirmed => 1, - deleted => 0, - email => $email, - editor => 'automated script', - note => '', - send_method => '', - whenedited => \'NOW()', - %{ $category_details || {} }, - }, - { - key => 'contacts_body_id_category_idx' - } - ); - - say "Editing category: $category"; - - my %default = ( - variable => 'true', - order => '1', - required => 'no', - datatype => 'string', - datatype_description => 'a string', - ); - - if ($field->{datatype} || '' eq 'boolean') { - my $description = $field->{description}; - %default = ( - %default, - datatype => 'singlevaluelist', - datatype_description => 'Yes or No', - values => { value => [ - { key => ['No'], name => ['No'] }, - { key => ['Yes'], name => ['Yes'] }, - ] }, - ); - } - - $contact->update({ - # XXX: we're just setting extra with the expected layout, - # this could be encapsulated more nicely - extra => { _fields => [ { %default, %$field } ] }, - confirmed => 1, - deleted => 0, - editor => 'automated script', - whenedited => \'NOW()', - note => 'Edited by script as per requirements Dec 2014', - }); - }; - - $_update->( 'Abandoned vehicles', { - code => 'registration', - description => 'Vehicle Registration number:', - }); - - $_update->( 'Dead animals', { - code => 'INFO_TEXT', - variable => 'false', - description => 'We do not remove small species, e.g. squirrels, rabbits, and small birds.', - }); - - $_update->( 'Flyposting', { - code => 'offensive', - description => 'Is it offensive?', - datatype => 'boolean', # mapped onto singlevaluelist - }); - - $_update->( 'Flytipping', { - code => 'size', - description => 'Size?', - datatype => 'singlevaluelist', - values => { value => [ - { key => ['Single Item'], name => ['Single item'] }, - { key => ['Car boot load'], name => ['Car boot load'] }, - { key => ['Small van load'], name => ['Small van load'] }, - { key => ['Transit van load'], name => ['Transit van load'] }, - { key => ['Tipper lorry load'], name => ['Tipper lorry load'] }, - { key => ['Significant load'], name => ['Significant load'] }, - ] }, - }); - - $_update->( 'Graffiti', { - code => 'offensive', - description => 'Is it offensive?', - datatype => 'boolean', # mapped onto singlevaluelist - }); - - $_update->( 'Parks and playgrounds', { - code => 'dangerous', - description => 'Is it dangerous or could cause injury?', - datatype => 'boolean', # mapped onto singlevaluelist - }); - - $_update->( 'Trees', { - code => 'dangerous', - description => 'Is it dangerous or could cause injury?', - datatype => 'boolean', # mapped onto singlevaluelist - }); - - # also ensure that the following categories are created: - for my $category ( - 'Car parking', - 'Dog and litter bins', - 'Dog fouling', - 'Other', - 'Rubbish (refuse and recycling)', - 'Street cleaning', - 'Street lighting', - 'Street nameplates', - ) { - say "Creating $category if required"; - my $contact = $contact_rs->find_or_create( - { - body_id => $self->council_id, - category => $category, - confirmed => 1, - deleted => 0, - email => $email, - editor => 'automated script', - note => 'Created by script as per requirements Dec 2014', - send_method => '', - whenedited => \'NOW()', - } - ); - } - - my @to_delete = ( - 'Parks/landscapes', # delete in favour of to parks and playgrounds - 'Public toilets', # as no longer in specs - ); - say sprintf "Deleting: %s (if present)", join ',' => @to_delete; - $contact_rs->search({ - body_id => $self->council_id, - category => \@to_delete, - deleted => 0 - })->update({ - deleted => 1, - editor => 'automated script', - whenedited => \'NOW()', - note => 'Deleted by script as per requirements Dec 2014', - }); -} - -sub contact_email { - my $self = shift; - return join( '@', 'customerservices', 'harrogate.gov.uk' ); -} - -sub process_additional_metadata_for_email { - my ($self, $problem, $h) = @_; - - my $additional = ''; - if (my $extra = $problem->get_extra_fields) { - $additional = join "\n\n", map { - if ($_->{name} eq 'INFO_TEXT') { - (); - } - else { - sprintf '%s: %s', $_->{description}, $_->{value}; - } - } @$extra; - $additional = "\n\n$additional" if $additional; - } - - $h->{additional_information} = $additional; -} - -sub send_questionnaires { - return 0; -} - -sub munge_category_list { - my ($self, $categories_ref, $contacts_ref, $extras_ref) = @_; - - # we want to know which contacts *only* belong to NYCC - # that's because for shared responsibility, we don't expect - # the user to have to figure out which authority to contact. - - # so we start building up the list of both - my (%harrogate_contacts, %nycc_contacts); - - my $harrogate_id = $self->council_id; # XXX: note reference to council_id as body id! - for my $contact (@$contacts_ref) { - my $category = $contact->category; - if ($contact->body_id == $harrogate_id) { - $harrogate_contacts{$category} = 1; - } - else { - $nycc_contacts{$category}++; - } - } - - # and then remove any that also have Harrogate involvement - delete $nycc_contacts{$_} for keys %harrogate_contacts; - - # here, we simply *mark* the text with (NYCC) at the end, and - # the rest will get done in the template with javascript - my @categories = map { - $nycc_contacts{$_} ? - "$_ (NYCC)" - : $_ - } @$categories_ref; - - # replace the entire list with this transformed one - @$categories_ref = @categories; -} - -1; - diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index dca208e98..3e262a700 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -112,6 +112,29 @@ sub pin_colour { return 'yellow'; } +sub open311_config { + my ($self, $row, $h, $params) = @_; + + my $extra = $row->get_extra_fields; + push @$extra, { name => 'external_id', value => $row->id }; + + if ($h->{closest_address}) { + push @$extra, { name => 'closest_address', value => $h->{closest_address} } + } + if ( $row->used_map || ( !$row->used_map && !$row->postcode ) ) { + push @$extra, { name => 'northing', value => $h->{northing} }; + push @$extra, { name => 'easting', value => $h->{easting} }; + } + $row->set_extra_fields( @$extra ); + + $params->{extended_description} = 'oxfordshire'; +} + +sub open311_pre_send { + my ($self, $row, $open311) = @_; + $open311->endpoints( { requests => 'open311_service_request.cgi' } ); +} + sub on_map_default_status { return 'open'; } sub contact_email { @@ -121,4 +144,70 @@ sub contact_email { sub admin_user_domain { 'oxfordshire.gov.uk' } +sub traffic_management_options { + return [ + "Signs and Cones", + "Stop and Go Boards", + "High Speed Roads", + ]; +} + +sub admin_pages { + my $self = shift; + + my $user = $self->{c}->user; + + my $pages = $self->next::method(); + + # Oxfordshire have a custom admin page for downloading reports in an Exor- + # friendly format which anyone with report_instruct permission can use. + if ( $user->has_body_permission_to('report_instruct') ) { + $pages->{exordefects} = [ ('Download Exor RDI'), 10 ]; + } + if ( $user->has_body_permission_to('defect_type_edit') ) { + $pages->{defecttypes} = [ ('Defect Types'), 11 ]; + $pages->{defecttype_edit} = [ undef, undef ]; + }; + + return $pages; +} + +sub defect_types { + { + SFP2 => "SFP2: sweep and fill <1m2", + POT2 => "POT2", + }; +} + +sub exor_rdi_link_id { 1989169 } +sub exor_rdi_link_length { 50 } + +sub reputation_increment_states { + return { + 'action scheduled' => 1, + }; +} + +sub user_extra_fields { + return [ 'initials' ]; +} + +sub display_days_ago_threshold { 28 } + +sub defect_type_extra_fields { + return [ + 'activity_code', + 'defect_code', + ]; +}; + +sub available_permissions { + my $self = shift; + + my $perms = $self->next::method(); + $perms->{Bodies}->{defect_type_edit} = "Add/edit defect types"; + + return $perms; +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/SeeSomething.pm b/perllib/FixMyStreet/Cobrand/SeeSomething.pm deleted file mode 100644 index 4d4dd000e..000000000 --- a/perllib/FixMyStreet/Cobrand/SeeSomething.pm +++ /dev/null @@ -1,135 +0,0 @@ -package FixMyStreet::Cobrand::SeeSomething; -use parent 'FixMyStreet::Cobrand::UKCouncils'; - -use strict; -use warnings; - -sub council_id { return [ 2520, 2522, 2514, 2546, 2519, 2538, 2535 ]; } -sub council_area { return 'West Midlands'; } -sub council_name { return 'See Something Say Something'; } -sub council_url { return 'seesomething'; } -sub area_types { [ 'MTD' ] } - -sub area_check { - my ( $self, $params, $context ) = @_; - - my $councils = $params->{all_areas}; - my $council_match = grep { $councils->{$_} } @{ $self->council_id }; - - if ($council_match) { - return 1; - } - - return ( 0, "That location is not covered by See Something, Say Something" ); -} - -sub disambiguate_location { - my $self = shift; - my $string = shift; - - my $town = 'West Midlands'; - - return { - %{ $self->SUPER::disambiguate_location() }, - town => $town, - centre => '52.4803101685267,-2.2708272758854', - span => '1.4002794815887,2.06340043925997', - bounds => [ 51.8259444771676, -3.23554082684068, 53.2262239587563, -1.17214038758071 ], - }; -} - -sub example_places { - return ( 'WS1 4NH', 'Austin Drive, Coventry' ); -} - -sub send_questionnaires { - return 0; -} - -sub ask_ever_reported { - return 0; -} - -sub report_sent_confirmation_email { 1; } - -sub report_check_for_errors { return (); } - -sub never_confirm_reports { 1; } - -sub allow_anonymous_reports { 1; } - -sub anonymous_account { return { name => 'Anonymous Submission', email => FixMyStreet->config('DO_NOT_REPLY_EMAIL') }; } - -sub admin_allow_user { - my ( $self, $user ) = @_; - return 1 if ( $user->from_body || $user->is_superuser ); -} - -sub admin_pages { - my $self = shift; - - return { - 'stats' => ['Reports', 0], - }; -}; - -sub admin_stats { - my $self = shift; - my $c = $self->{c}; - - my %filters = (); - - # XXX The below lookup assumes a body ID === MapIt area ID - my %councils = - map { - my $name = $_->name; - $name =~ s/(?:Borough|City) Council//; - ($_->id => $name); - } - $c->model('DB::Body')->search({ id => $self->council_id }); - - $c->stash->{council_details} = \%councils; - - if ( !$c->user_exists || !grep { $_ == $c->user->from_body->id } @{ $self->council_id } ) { - $c->detach( '/page_error_404_not_found' ); - } - - if ( $c->get_param('category') ) { - $filters{category} = $c->get_param('category'); - $c->stash->{category} = $c->get_param('category'); - } - - if ( $c->get_param('subcategory') ) { - $filters{subcategory} = $c->get_param('subcategory'); - $c->stash->{subcategory} = $c->get_param('subcategory'); - } - - if ( $c->get_param('service') ) { - $filters{service} = { -ilike => $c->get_param('service') }; - $c->stash->{service} = $c->get_param('service'); - } - - my $page = $c->get_param('p') || 1; - - my $p = $c->model('DB::Problem')->search( - { - confirmed => { not => undef }, - %filters - }, - { - columns => [ qw( - service category subcategory confirmed bodies_str - ) ], - order_by => { -desc=> [ 'confirmed' ] }, - rows => 20, - } - )->page( $page ); - - $c->stash->{reports} = $p; - $c->stash->{pager} = $p->pager; - - return 1; -} - -1; - diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm index 08ecf0b7d..945af48f8 100644 --- a/perllib/FixMyStreet/Cobrand/UK.pm +++ b/perllib/FixMyStreet/Cobrand/UK.pm @@ -1,5 +1,6 @@ package FixMyStreet::Cobrand::UK; use base 'FixMyStreet::Cobrand::Default'; +use strict; use JSON::MaybeXS; use mySociety::MaPit; @@ -354,13 +355,8 @@ sub get_body_handler_for_problem { my @bodies = values %{$row->bodies}; my %areas = map { %{$_->areas} } @bodies; - foreach my $avail ( FixMyStreet::Cobrand->available_cobrand_classes ) { - my $class = FixMyStreet::Cobrand->get_class_for_moniker($avail->{moniker}); - my $cobrand = $class->new({}); - next unless $cobrand->can('council_id'); - return $cobrand if $areas{$cobrand->council_id}; - } - + my $cobrand = FixMyStreet::Cobrand->body_handler(\%areas); + return $cobrand if $cobrand; return ref $self ? $self : $self->new; } diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index c22224307..e0b6b5298 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -42,13 +42,13 @@ sub restriction { sub problems_restriction { my ($self, $rs) = @_; - return $rs if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING'); + return $rs if FixMyStreet->staging_flag('skip_checks'); return $rs->to_body($self->council_id); } sub updates_restriction { my ($self, $rs) = @_; - return $rs if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING'); + return $rs if FixMyStreet->staging_flag('skip_checks'); return $rs->to_body($self->council_id); } @@ -76,7 +76,7 @@ sub users_restriction { my $or_query = [ from_body => $self->council_id, - id => [ { -in => $problem_user_ids }, { -in => $update_user_ids } ], + 'me.id' => [ { -in => $problem_user_ids }, { -in => $update_user_ids } ], ]; if ($self->can('admin_user_domain')) { my $domain = $self->admin_user_domain; @@ -105,7 +105,7 @@ sub enter_postcode_text { sub area_check { my ( $self, $params, $context ) = @_; - return 1 if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING'); + return 1 if FixMyStreet->staging_flag('skip_checks'); my $councils = $params->{all_areas}; my $council_match = defined $councils->{$self->council_id}; @@ -200,6 +200,7 @@ sub available_permissions { my $perms = $self->next::method(); $perms->{Problems}->{contribute_as_body} = "Create reports/updates as " . $self->council_name; + $perms->{Problems}->{view_body_contribute_details} = "See user detail for reports created as " . $self->council_name; $perms->{Users}->{user_assign_areas} = "Assign users to areas in " . $self->council_name; return $perms; diff --git a/perllib/FixMyStreet/Cobrand/WestBerkshire.pm b/perllib/FixMyStreet/Cobrand/WestBerkshire.pm new file mode 100644 index 000000000..7e98187bb --- /dev/null +++ b/perllib/FixMyStreet/Cobrand/WestBerkshire.pm @@ -0,0 +1,16 @@ +package FixMyStreet::Cobrand::WestBerkshire; +use base 'FixMyStreet::Cobrand::UK'; + +use strict; +use warnings; + +sub council_id { 2619 } + +# non standard west berks end points +sub open311_pre_send { + my ($self, $row, $open311) = @_; + $open311->endpoints( { services => 'Services', requests => 'Requests' } ); +} + +1; + |