diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Alert.pm | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Base.pm | 70 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 93 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/EmptyHomes.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 2 |
8 files changed, 79 insertions, 104 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; |