diff options
-rw-r--r-- | perllib/FixMyStreet/App/Form/ManifestTheme.pm | 13 | ||||
-rw-r--r-- | t/app/controller/admin/manifesttheme.t | 5 | ||||
-rw-r--r-- | templates/web/base/admin/manifesttheme/form.html | 2 |
3 files changed, 13 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Form/ManifestTheme.pm b/perllib/FixMyStreet/App/Form/ManifestTheme.pm index 7f3b629c0..aa2d467d6 100644 --- a/perllib/FixMyStreet/App/Form/ManifestTheme.pm +++ b/perllib/FixMyStreet/App/Form/ManifestTheme.pm @@ -6,6 +6,7 @@ use Digest::SHA qw(sha1_hex); use File::Basename; use HTML::FormHandler::Moose; use FixMyStreet::App::Form::I18N; +use List::MoreUtils qw(uniq); extends 'HTML::FormHandler::Model::DBIC'; use namespace::autoclean; @@ -14,7 +15,7 @@ has 'cobrand' => ( isa => 'Str', is => 'ro' ); has '+widget_name_space' => ( default => sub { ['FixMyStreet::App::Form::Widget'] } ); has '+widget_tags' => ( default => sub { { wrapper_tag => 'p' } } ); has '+item_class' => ( default => 'ManifestTheme' ); -has_field 'cobrand' => ( required => 0 ); +has_field 'cobrand' => ( type => 'Select', empty_select => 'Select a cobrand', required => 1 ); has_field 'name' => ( required => 1 ); has_field 'short_name' => ( required => 1 ); has_field 'background_colour' => ( required => 0 ); @@ -22,13 +23,13 @@ has_field 'theme_colour' => ( required => 0 ); has_field 'icon' => ( required => 0, type => 'Upload', label => "Add icon" ); has_field 'delete_icon' => ( type => 'Multiple' ); -before 'update_model' => sub { - my $self = shift; - $self->item->cobrand($self->cobrand) if $self->cobrand && !$self->item->cobrand; -}; - sub _build_language_handle { FixMyStreet::App::Form::I18N->new } +sub options_cobrand { + my @cobrands = uniq sort map { $_->{moniker} } FixMyStreet::Cobrand->available_cobrand_classes; + return map { $_ => $_ } @cobrands; +} + sub validate { my $self = shift; diff --git a/t/app/controller/admin/manifesttheme.t b/t/app/controller/admin/manifesttheme.t index 11802cffc..9a86bdeb7 100644 --- a/t/app/controller/admin/manifesttheme.t +++ b/t/app/controller/admin/manifesttheme.t @@ -9,7 +9,7 @@ my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super Us $mech->log_in_ok( $superuser->email ); FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'lincolnshire', 'fixmystreet' ], + ALLOWED_COBRANDS => [ 'lincolnshire', 'tfl', 'fixmystreet' ], }, sub { ok $mech->host('lincolnshire.fixmystreet.com'); @@ -107,6 +107,7 @@ subtest "cobrand admin lets you add an icon to an existing theme" => sub { short_name => "Lincs FMS", background_colour => "#663399", theme_colour => "rgb(102, 51, 153)", + cobrand => 'lincolnshire', icon => [ $sample_jpeg, undef, Content_Type => 'image/jpeg' ], }, ); @@ -149,6 +150,7 @@ subtest "cobrand admin rejects non-images" => sub { short_name => "Lincs FMS", background_colour => "#663399", theme_colour => "rgb(102, 51, 153)", + cobrand => 'lincolnshire', icon => [ $sample_pdf, undef, Content_Type => 'application/pdf' ], }, ); @@ -196,6 +198,7 @@ subtest "can delete theme" => sub { short_name => "Lincs FMS", background_colour => "#663399", theme_colour => "rgb(102, 51, 153)", + cobrand => "lincolnshire", icon => [ $sample_jpeg, undef, Content_Type => 'image/jpeg' ], }, ); diff --git a/templates/web/base/admin/manifesttheme/form.html b/templates/web/base/admin/manifesttheme/form.html index 13ed60e04..4c97f292e 100644 --- a/templates/web/base/admin/manifesttheme/form.html +++ b/templates/web/base/admin/manifesttheme/form.html @@ -23,6 +23,8 @@ [% IF show_all %] [% form.field('cobrand').render | safe %] + [% ELSE %] + <input type=hidden name=cobrand value='[% c.cobrand.moniker %]' /> [% END %] <table> |