diff options
21 files changed, 83 insertions, 126 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 04dfaf409..0e34ea64b 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -81,7 +81,7 @@ sub index : Path : Args(0) { $c->stash->{alerts} = \%alert_counts; - my $contacts = $c->model('DB::Contact')->summary_count( $c->cobrand->contact_restriction ); + my $contacts = $c->model('DB::Contact')->summary_count(); my %contact_counts = map { $_->confirmed => $_->get_column('confirmed_count') } $contacts->all; diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm index ff92a7d2d..40dde455e 100644 --- a/perllib/FixMyStreet/App/Controller/Alert.pm +++ b/perllib/FixMyStreet/App/Controller/Alert.pm @@ -27,8 +27,6 @@ Show the alerts page sub index : Path('') : Args(0) { my ( $self, $c ) = @_; - $c->stash->{cobrand_form_elements} = $c->cobrand->form_elements('alerts'); - unless ( $c->req->referer && $c->req->referer =~ /fixmystreet\.com/ ) { $c->forward( 'add_recent_photos', [10] ); } @@ -149,7 +147,6 @@ sub updates : Path('updates') : Args(0) { $c->stash->{email} = $c->req->param('rznvy'); $c->stash->{problem_id} = $c->req->param('id'); - $c->stash->{cobrand_form_elements} = $c->cobrand->form_elements('alerts'); } =head2 confirm @@ -508,8 +505,6 @@ sub setup_request : Private { $c->stash->{rznvy} ||= $c->user->email; } - $c->stash->{cobrand_form_elements} = $c->cobrand->form_elements('alerts'); - return 1; } diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 6596615c6..166f9d58e 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -100,10 +100,6 @@ sub format_problem_for_display : Private { $c->stash->{banner} = $c->cobrand->generate_problem_banner($problem); - $c->stash->{cobrand_alert_fields} = $c->cobrand->form_elements('/alerts'); - $c->stash->{cobrand_update_fields} = - $c->cobrand->form_elements('/updateForm'); - ( $c->stash->{short_latitude}, $c->stash->{short_longitude} ) = map { Utils::truncate_coordinate($_) } ( $problem->latitude, $problem->longitude ); diff --git a/perllib/FixMyStreet/Cobrand/Base.pm b/perllib/FixMyStreet/Cobrand/Base.pm new file mode 100644 index 000000000..00b47d7da --- /dev/null +++ b/perllib/FixMyStreet/Cobrand/Base.pm @@ -0,0 +1,70 @@ +package FixMyStreet::Cobrand::Base; + +use strict; +use warnings; + +=head2 new + + my $cobrand = $class->new; + my $cobrand = $class->new( { c => $c } ); + +Create a new cobrand object, optionally setting the context. + +You probably shouldn't need to do this and should get the cobrand object via a +method in L<FixMyStreet::Cobrand> instead. + +=cut + +sub new { + my $class = shift; + my $self = shift || {}; + return bless $self, $class; +} + +=head2 moniker + + $moniker = $cobrand_class->moniker(); + +Returns a moniker that can be used to identify this cobrand. By default this is +the last part of the class name lowercased - eg 'F::C::SomeCobrand' becomes +'somecobrand'. + +=cut + +sub moniker { + my $class = ref( $_[0] ) || $_[0]; # deal with object or class + my ($last_part) = $class =~ m{::(\w+)$}; + $last_part = lc($last_part); + return '' if $last_part eq 'default'; + return $last_part; +} + +=head2 is_default + + $bool = $cobrand->is_default(); + +Returns true if this is the default cobrand, false otherwise. + +=cut + +sub is_default { + my $self = shift; + return $self->moniker eq ''; +} + +=head2 path_to_web_templates + + $path = $cobrand->path_to_web_templates( ); + +Returns the path to the templates for this cobrand - by default +"templates/web/$moniker" + +=cut + +sub path_to_web_templates { + my $self = shift; + return FixMyStreet->path_to( 'templates/web', $self->moniker ); +} + +1; + diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index b5a1cd8d3..aeb956680 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -1,4 +1,5 @@ package FixMyStreet::Cobrand::Default; +use base 'FixMyStreet::Cobrand::Base'; use strict; use warnings; @@ -10,69 +11,6 @@ use Carp; use mySociety::MaPit; use mySociety::PostcodeUtil; -=head2 new - - my $cobrand = $class->new; - my $cobrand = $class->new( { c => $c } ); - -Create a new cobrand object, optionally setting the context. - -You probably shouldn't need to do this and should get the cobrand object via a -method in L<FixMyStreet::Cobrand> instead. - -=cut - -sub new { - my $class = shift; - my $self = shift || {}; - return bless $self, $class; -} - -=head2 moniker - - $moniker = $cobrand_class->moniker(); - -Returns a moniker that can be used to identify this cobrand. By default this is -the last part of the class name lowercased - eg 'F::C::SomeCobrand' becomes -'somecobrand'. - -=cut - -sub moniker { - my $class = ref( $_[0] ) || $_[0]; # deal with object or class - my ($last_part) = $class =~ m{::(\w+)$}; - $last_part = lc($last_part); - return '' if $last_part eq 'default'; - return $last_part; -} - -=head2 is_default - - $bool = $cobrand->is_default(); - -Returns true if this is the default cobrand, false otherwise. - -=cut - -sub is_default { - my $self = shift; - return $self->moniker eq ''; -} - -=head2 path_to_web_templates - - $path = $cobrand->path_to_web_templates( ); - -Returns the path to the templates for this cobrand - by default -"templates/web/$moniker" - -=cut - -sub path_to_web_templates { - my $self = shift; - return FixMyStreet->path_to( 'templates/web', $self->moniker ); -} - =head1 country Returns the country that this cobrand operates in, as an ISO3166-alpha2 code. @@ -114,17 +52,6 @@ empty string and site key 0 if the cobrand uses all the data. sub site_restriction { return ( "", 0, {} ) } -=head2 contact_restriction - -Return a contact restriction clause if the cobrand uses a subset of the -FixMyStreet contact data. - -=cut - -sub contact_restriction { - {}; -} - =head2 restriction Return a restriction to pull out data saved while using the cobrand site. @@ -315,15 +242,6 @@ sub disambiguate_location { }; } -=head2 form_elements - -Parameters are FORM_NAME, QUERY. Return HTML for any extra needed elements for -FORM_NAME - -=cut - -sub form_elements { '' } - =head2 cobrand_data_for_generic_update Parameter is UPDATE_DATA, a reference to a hash of non-cobranded update data. @@ -422,15 +340,6 @@ Return any params to be added to responses sub header_params { return {} } -=head2 root_path_js - -Parameter is QUERY. Return some js to set the root path from which AJAX queries -should be made. - -=cut - -sub root_path_js { 'var root_path = "";' } - =head2 site_title Return the title to be used in page heads. diff --git a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm index 189daee0c..6885f6a95 100644 --- a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm +++ b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm @@ -1,5 +1,5 @@ package FixMyStreet::Cobrand::EmptyHomes; -use base 'FixMyStreet::Cobrand::Default'; +use base 'FixMyStreet::Cobrand::FixMyStreet'; use strict; use warnings; diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm new file mode 100644 index 000000000..242194e01 --- /dev/null +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -0,0 +1,5 @@ +package FixMyStreet::Cobrand::FixMyStreet; +use base 'FixMyStreet::Cobrand::Default'; + +1; + diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 570c90c46..9aaa8eca0 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -1,5 +1,5 @@ package FixMyStreet::Cobrand::UKCouncils; -use base 'FixMyStreet::Cobrand::Default'; +use base 'FixMyStreet::Cobrand::FixMyStreet'; use strict; use warnings; diff --git a/templates/web/default/admin/report_edit.html b/templates/web/default/admin/report_edit.html index 79207192d..cbba1b3b0 100644 --- a/templates/web/default/admin/report_edit.html +++ b/templates/web/default/admin/report_edit.html @@ -14,10 +14,6 @@ <li><label for='detail'>[% loc('Details:') %]</label><br><textarea name='detail' id='detail' cols=60 rows=10>[% problem.detail | html %]</textarea></li> <li>[% loc('Co-ordinates:') %] [% problem.latitude %], [% problem.longitude %] ( [% loc('originally entered') %] [% problem.postcode | html %] , [% IF problem.used_map %][% loc('used map') %][% ELSE %][% loc("didn't use map") %][% END %])</li> <li>[% loc('For council(s):') %] [% IF problem.council %][% problem.council %][% ELSE %]<em>[% loc('None' ) %]</em>[% END %] ([% loc('other areas:') %] [% problem.areas | remove('^,') | remove( ',$' ) %])</li> -<li><label for="anonymous">[% loc('Anonymous:') %]</label> <select name="anonymous" id="anonymous"> -<option [% 'selected ' IF problem.anonymous %]value="1">[% loc('Yes') %]</option> -<option [% 'selected ' IF !problem.anonymous %]value="0">[% loc('No') %]</option> -</select></li> <li><label for="state">[% loc('State:') %]</label> <select name="state" id="state"> [% FOREACH state IN [ ['confirmed', loc('Open')], ['investigating', loc('Investigating')], ['planned', loc('Planned')], ['in progress', @@ -27,6 +23,10 @@ [% END %] </select></li> <li>[% loc('Category:') %] [% problem.category | html %] </li> +<li><label for="anonymous">[% loc('Anonymous:') %]</label> <select name="anonymous" id="anonymous"> +<option [% 'selected ' IF problem.anonymous %]value="1">[% loc('Yes') %]</option> +<option [% 'selected ' IF !problem.anonymous %]value="0">[% loc('No') %]</option> +</select></li> <li>[% loc('Name:') %] <input type='text' name='name' id='name' value='[% problem.name | html %]'></li> <li>[% loc('Email:') %] <input type='text' id='email' name='email' value='[% problem.user.email | html %]'> [% PROCESS abuse_button %] [% PROCESS flag_button user=problem.user %]</li> <li>[% loc('Phone:') %] [% problem.user.phone | html %]</li> diff --git a/templates/web/default/alert/index.html b/templates/web/default/alert/index.html index f717ad58c..d8478cf98 100644 --- a/templates/web/default/alert/index.html +++ b/templates/web/default/alert/index.html @@ -22,7 +22,6 @@ within a certain distance of a particular location.') %] postcode or street name and area:' ) %] <input type="text" name="pc" value="[% pc | html %]"> <input type="submit" value="[% loc('Go') %]"> - [% cobrand_form_elements %] </p> </form> diff --git a/templates/web/default/alert/list.html b/templates/web/default/alert/list.html index 36bfaffd9..c763331cc 100644 --- a/templates/web/default/alert/list.html +++ b/templates/web/default/alert/list.html @@ -22,8 +22,6 @@ <input type="hidden" name="type" value="local"> <input type="hidden" name="pc" value="[% pc | html %]"> - [% cobrand_form_elements %] - [% IF photos.size %] <div id="alert_photos"> <h2>[% loc('Photos of recent nearby reports') %]</h2> diff --git a/templates/web/default/alert/updates.html b/templates/web/default/alert/updates.html index 76b5ef23e..5efc41bac 100644 --- a/templates/web/default/alert/updates.html +++ b/templates/web/default/alert/updates.html @@ -15,7 +15,6 @@ <input type="hidden" name="id" value="[% problem_id | html %]"> <input type="hidden" name="type" value="updates"> <input type="submit" value="[% loc('Subscribe') %]"> -[% cobrand_form_elements %] </form> diff --git a/templates/web/default/around/around_index.html b/templates/web/default/around/around_index.html index 3e6d96acd..c07eb2ca2 100644 --- a/templates/web/default/around/around_index.html +++ b/templates/web/default/around/around_index.html @@ -15,7 +15,6 @@ <form action="[% c.uri_for('/around') %]" method="get" name="postcodeForm" id="postcodeForm"> <label for="pc">[% question %]:</label> <input type="text" name="pc" value="[% pc | html %]" id="pc" size="10" maxlength="200"> <input type="submit" value="[% loc('Go') %]" id="submit"> -[% c.cobrand.form_elements('postcodeForm') %] [% IF partial_token %] <input type="hidden" name="partial" value="[% partial_token.token %]"> diff --git a/templates/web/default/around/display_location.html b/templates/web/default/around/display_location.html index bebc787e2..b5705a77b 100755 --- a/templates/web/default/around/display_location.html +++ b/templates/web/default/around/display_location.html @@ -40,7 +40,6 @@ <input type="hidden" name="map_override" value="[% c.req.params.map_override | html %]"> [% END %] <input type="hidden" name="pc" value="[% pc | html %]"> -[% c.cobrand.form_elements('mapForm') %] <input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% short_latitude | html %]"> <input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% short_longitude | html %]"> diff --git a/templates/web/default/contact/index.html b/templates/web/default/contact/index.html index 2c0c2ff02..50e8d3845 100644 --- a/templates/web/default/contact/index.html +++ b/templates/web/default/contact/index.html @@ -92,8 +92,6 @@ <textarea class="required" name="message" id="form_message" rows="7" cols="50">[% message | html %]</textarea></div> <div class="checkbox"><input type="submit" value="[% loc('Post') %]"></div> -[% c.cobrand.form_elements('contactForm') %] - </form> [% INCLUDE 'contact/address.html' %] diff --git a/templates/web/default/index.html b/templates/web/default/index.html index eaf8804db..06f3ef771 100644 --- a/templates/web/default/index.html +++ b/templates/web/default/index.html @@ -32,7 +32,6 @@ <span><input type="text" name="pc" value="" id="pc" size="10" maxlength="200"> <input type="submit" value="[% loc('Go') %]" id="submit"> </span> - [% c.cobrand.form_elements('postcodeForm') %] </form> <div id="front_intro"> diff --git a/templates/web/default/questionnaire/index.html b/templates/web/default/questionnaire/index.html index a7e5ad60c..5b48f8915 100644 --- a/templates/web/default/questionnaire/index.html +++ b/templates/web/default/questionnaire/index.html @@ -21,8 +21,6 @@ <input type="hidden" name="token" value="[% token | html %]"> -[% c.cobrand.form_elements('questionnaireForm') %] - [% IF c.cobrand.moniker == 'emptyhomes' %] [% IF num_questionnaire == 1 %] [% loc('<p>Getting empty homes back into use can be difficult. You shouldn’t expect diff --git a/templates/web/default/report/display.html b/templates/web/default/report/display.html index 1e320e1b4..999d332d2 100644 --- a/templates/web/default/report/display.html +++ b/templates/web/default/report/display.html @@ -41,7 +41,6 @@ <input type="hidden" name="id" value="[% problem.id %]"> <input type="hidden" name="type" value="updates"> <input type="submit" value="[% loc('Subscribe') %]"> - [% cobrand_alert_fields %] </form> <a href="[% c.uri_for( '/rss', problem.id ) %]"> @@ -192,8 +191,6 @@ [% END %] - [% cobrand_update_fields %] - </form> </div> diff --git a/templates/web/default/report/new/fill_in_details.html b/templates/web/default/report/new/fill_in_details.html index 701a9bafa..22d1ee739 100644 --- a/templates/web/default/report/new/fill_in_details.html +++ b/templates/web/default/report/new/fill_in_details.html @@ -9,12 +9,10 @@ <input type="hidden" name="map_override" value="[% c.req.params.map_override | html %]"> [% END %] <input type="hidden" name="pc" value="[% pc | html %]"> -[% c.cobrand.form_elements('mapForm') %] [% ELSE %] <form action="[% c.uri_for('/report/new') %]" method="post" name="mapSkippedForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %] class="validate"> <input type="hidden" name="pc" value="[% pc | html %]"> <input type="hidden" name="skipped" value="1"> -[% c.cobrand.form_elements('mapSkippedForm') %] [% END %] <input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% short_latitude | html %]"> diff --git a/templates/web/emptyhomes/around/display_location.html b/templates/web/emptyhomes/around/display_location.html index 2b2a8e9f0..888c8717e 100755 --- a/templates/web/emptyhomes/around/display_location.html +++ b/templates/web/emptyhomes/around/display_location.html @@ -22,7 +22,6 @@ <input type="hidden" name="map_override" value="[% c.req.params.map_override | html %]"> [% END %] <input type="hidden" name="pc" value="[% pc | html %]"> -[% c.cobrand.form_elements('mapForm') %] <input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% short_latitude | html %]"> <input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% short_longitude | html %]"> diff --git a/templates/web/emptyhomes/index.html b/templates/web/emptyhomes/index.html index 595dae0fd..bd7261f49 100644 --- a/templates/web/emptyhomes/index.html +++ b/templates/web/emptyhomes/index.html @@ -48,7 +48,6 @@ The TV series launched a campaign for action and while this is running, our <a h <span><input type="text" name="pc" value="" id="pc" size="10" maxlength="200"> <input type="submit" value="[% loc('Go') %]" id="submit"> </span> - [% c.cobrand.form_elements('postcodeForm') %] </form> <div id="front_intro"> |