From 34eeac7fc2408acf74d5ce61cfcecc076b306068 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Fri, 2 Dec 2022 12:59:49 +0100 Subject: [PATCH] MT#56068 fix /api/resellerbrandings reseller_id field * reseller_id is now only mandatory for the 'admin' role Change-Id: Idd090332ed2877b2a2c06c9cce741757cc718737 --- lib/NGCP/Panel/Form/Reseller/BrandingAPI.pm | 11 +------ .../Panel/Form/Reseller/BrandingAPIAdmin.pm | 30 +++++++++++++++++++ lib/NGCP/Panel/Role/API/ResellerBrandings.pm | 7 ++++- 3 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 lib/NGCP/Panel/Form/Reseller/BrandingAPIAdmin.pm diff --git a/lib/NGCP/Panel/Form/Reseller/BrandingAPI.pm b/lib/NGCP/Panel/Form/Reseller/BrandingAPI.pm index f20b552ed3..7f2ea5de38 100644 --- a/lib/NGCP/Panel/Form/Reseller/BrandingAPI.pm +++ b/lib/NGCP/Panel/Form/Reseller/BrandingAPI.pm @@ -3,19 +3,10 @@ package NGCP::Panel::Form::Reseller::BrandingAPI; use HTML::FormHandler::Moose; extends 'NGCP::Panel::Form::Reseller::Branding'; -has_field 'reseller_id' => ( - type => 'PosInteger', - required => 1, - element_attr => { - rel => ['tooltip'], - title => ['The reseller who owns the Branding.'], - }, -); - has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/reseller_id logo css csc_color_primary csc_color_secondary/], + render_list => [qw/logo css csc_color_primary csc_color_secondary/], ); sub update_fields { diff --git a/lib/NGCP/Panel/Form/Reseller/BrandingAPIAdmin.pm b/lib/NGCP/Panel/Form/Reseller/BrandingAPIAdmin.pm new file mode 100644 index 0000000000..7fbbca5897 --- /dev/null +++ b/lib/NGCP/Panel/Form/Reseller/BrandingAPIAdmin.pm @@ -0,0 +1,30 @@ +package NGCP::Panel::Form::Reseller::BrandingAPIAdmin; + +use HTML::FormHandler::Moose; +extends 'NGCP::Panel::Form::Reseller::BrandingAPI'; + +has_field 'reseller_id' => ( + type => 'PosInteger', + required => 1, + element_attr => { + rel => ['tooltip'], + title => ['The reseller who owns the Branding.'], + }, +); + +has_block 'fields' => ( + tag => 'div', + class => [qw/modal-body/], + render_list => [qw/reseller_id logo css csc_color_primary csc_color_secondary/], +); + +sub update_fields { + my ($self) = @_; + + my $c = $self->ctx; + return unless($c); + $self->field('logo')->inactive(1); +} + +1; +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Role/API/ResellerBrandings.pm b/lib/NGCP/Panel/Role/API/ResellerBrandings.pm index 2a58be5b1b..cf74be3d13 100644 --- a/lib/NGCP/Panel/Role/API/ResellerBrandings.pm +++ b/lib/NGCP/Panel/Role/API/ResellerBrandings.pm @@ -41,7 +41,12 @@ sub config_allowed_roles { sub get_form { my ($self, $c) = @_; #use_fields_for_input_without_param - return (NGCP::Panel::Form::get("NGCP::Panel::Form::Reseller::BrandingAPI", $c)); + return NGCP::Panel::Form::get( + $c->user->roles eq "admin" + ? "NGCP::Panel::Form::Reseller::BrandingAPIAdmin" + : "NGCP::Panel::Form::Reseller::BrandingAPI", + $c + ); } sub _item_rs {