diff options
author | Chris Mytton <chrism@mysociety.org> | 2020-03-16 18:14:00 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2020-03-31 09:58:58 +0100 |
commit | ac6eb28d588eeac702f9f1a6806c6939b1d67fb3 (patch) | |
tree | b9f1a01c783129a405e7fde4fca5683cb157952a | |
parent | dd34deb13359f4a225850031e40723c6f15bd804 (diff) |
[Highways England] cobrand behaviour config
Anonymous reports only
Don't allow updates on fixed or closed reports
Various required problem/admin restriction fns.
Only England, no photos.
4 files changed, 92 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm index 5e91d517c..ee4754827 100644 --- a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm +++ b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm @@ -4,6 +4,38 @@ use parent 'FixMyStreet::Cobrand::UK'; use strict; use warnings; +sub council_url { 'highwaysengland' } + +sub site_key { 'highwaysengland' } + +sub restriction { { cobrand => shift->moniker } } + +sub hide_areas_on_reports { 1 } + +sub all_reports_single_body { { name => 'Highways England' } } + +sub body { + my $self = shift; + my $body = FixMyStreet::DB->resultset('Body')->search({ name => 'Highways England' })->first; + return $body; +} + +# Copying of functions from UKCouncils that are needed here also - factor out to a role of some sort? +sub cut_off_date { '' } +sub problems_restriction { FixMyStreet::Cobrand::UKCouncils::problems_restriction($_[0], $_[1]) } +sub problems_on_map_restriction { $_[0]->problems_restriction($_[1]) } +sub problems_sql_restriction { FixMyStreet::Cobrand::UKCouncils::problems_sql_restriction($_[0], $_[1]) } +sub users_restriction { FixMyStreet::Cobrand::UKCouncils::users_restriction($_[0], $_[1]) } +sub updates_restriction { FixMyStreet::Cobrand::UKCouncils::updates_restriction($_[0], $_[1]) } +sub base_url { FixMyStreet::Cobrand::UKCouncils::base_url($_[0]) } + +sub admin_allow_user { + my ( $self, $user ) = @_; + return 1 if $user->is_superuser; + return undef unless defined $user->from_body; + return $user->from_body->name eq 'Highways England'; +} + sub enter_postcode_text { 'Enter a location, road name or postcode' } sub example_places { @@ -13,4 +45,58 @@ sub example_places { sub allow_photo_upload { 0 } +sub allow_anonymous_reports { 'button' } + +sub admin_user_domain { 'highwaysengland.co.uk' } + +sub anonymous_account { + my $self = shift; + return { + email => $self->feature('anonymous_account') . '@' . $self->admin_user_domain, + name => 'Anonymous user', + }; +} + +sub updates_disallowed { + my ($self, $problem) = @_; + return 1 if $problem->is_fixed || $problem->is_closed; + return 1 if $problem->get_extra_metadata('closed_updates'); + return 0; +} + +# Bypass photo requirement, we have none +sub recent_photos { + my ( $self, $area, $num, $lat, $lon, $dist ) = @_; + return $self->problems->recent if $area eq 'front'; + return []; +} + +sub area_check { + my ( $self, $params, $context ) = @_; + + my $areas = $params->{all_areas}; + $areas = { + map { $_->{id} => $_ } + # If no country, is prefetched area and can assume is E + grep { ($_->{country} || 'E') eq 'E' } + values %$areas + }; + return $areas if %$areas; + + my $error_msg = 'Sorry, this site only covers England.'; + return ( 0, $error_msg ); +} + +sub fetch_area_children { + my $self = shift; + + my $areas = FixMyStreet::MapIt::call('areas', $self->area_types); + $areas = { + map { $_->{id} => $_ } + grep { ($_->{country} || 'E') eq 'E' } + values %$areas + }; + return $areas; +} + 1; diff --git a/templates/web/highwaysengland/report/form/user.html b/templates/web/highwaysengland/report/form/user.html new file mode 100644 index 000000000..1167f1f9a --- /dev/null +++ b/templates/web/highwaysengland/report/form/user.html @@ -0,0 +1,6 @@ +<!-- report/form/user.html --> +<div class="js-new-report-user-hidden form-section-preview form-section-preview--next"> + <button name="report_anonymously" value="yes" class="btn btn--block js-new-report-submit">Report anonymously</button> + <small>No personal details will be stored.</small> +</div> +<!-- /report/form/user.html --> diff --git a/templates/web/highwaysengland/report/form/user_loggedout.html b/templates/web/highwaysengland/report/form/user_loggedout.html new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/templates/web/highwaysengland/report/form/user_loggedout.html diff --git a/templates/web/highwaysengland/report/new/form_user_loggedin.html b/templates/web/highwaysengland/report/new/form_user_loggedin.html new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/templates/web/highwaysengland/report/new/form_user_loggedin.html |