TT#50907 Don't use form caching in WEB UI

Change-Id: I10a7d3f9ace3928a2918d0f16dfeabd2a0aa720b
changes/19/27219/4
Irina Peshinskaya 6 years ago
parent 858905035b
commit 86a2ae7cad

@ -27,6 +27,14 @@ __PACKAGE__->config(namespace => '');
sub auto :Private {
my($self, $c) = @_;
if ($c->request->path =~/^api\//i) {
$c->log->debug("Root::auto: enable cache");
NGCP::Panel::Form::dont_use_cache(0);
} else {
$c->log->debug("Root::auto: disable cache");
NGCP::Panel::Form::dont_use_cache(1);
}
if(defined $c->request->params->{lang} && $c->request->params->{lang} =~ /^\w+$/) {
$c->log->debug("checking language");
if($c->request->params->{lang} eq "en") {

@ -7,14 +7,25 @@ use Module::Load::Conditional qw/can_load/;
use NGCP::Panel::Utils::I18N qw//;
my %forms = ();
our $dont_use_cache = 0;
sub dont_use_cache {
if (scalar @_){
$dont_use_cache = $_[0];
}
return $dont_use_cache;
}
sub get {
my ($name, $c, $create_new) = @_;
my $form;
if(exists $forms{$name}
&& !($forms{$name}->can('ngcp_no_cache') && $forms{$name}->ngcp_no_cache)
$c->log->debug("Form requested: $name; dont_use_cache: $dont_use_cache; create_new: "
.( $create_new // "undefined" ).";");
if( !$dont_use_cache
&& !$create_new
&& exists $forms{$name}
) {
$c->log->debug("form is taken from cache");
$form = $forms{$name};
$form->clear();
$form->ctx($c);

@ -5,10 +5,6 @@ extends 'HTML::FormHandler';
use HTML::FormHandler::Widget::Block::Bootstrap;
#form has dinamic fields, generated by by field_list, that is not triggered when form is taken from the cache.
#Thus we need to recreate form every time.
has 'ngcp_no_cache' => ( default => '1' );
has '+widget_wrapper' => ( default => 'Bootstrap' );
has_field 'submitid' => ( type => 'Hidden' );
sub build_render_list {[qw/submitid fields actions/]}

Loading…
Cancel
Save