TT#47963 Fix emailtemplates put and patch

Change-Id: I26a24c17b42e3f31390de28fd1e5098c6c167861
changes/99/25099/1
Irina Peshinskaya 7 years ago
parent 72c771ec87
commit 83d715230e

@ -100,8 +100,13 @@ sub validate {
name => $name, name => $name,
reseller_id => $reseller_id, reseller_id => $reseller_id,
}); });
my $current_item = $c->stash->{tmpl}; my $current_item = $self->item ? $self->item : $c->stash->{tmpl};
if ($existing_item && (!$current_item || $existing_item->id != $current_item->id)) { my $current_item_id =
$current_item
? ref $current_item eq 'HASH'
? $current_item->{id} : $current_item->id
: undef;
if ($existing_item && (!$current_item_id || $existing_item->id != $current_item_id)) {
$self->field('name')->add_error($c->loc('This name already exists')); $self->field('name')->add_error($c->loc('This name already exists'));
} }
} }

@ -218,6 +218,7 @@ sub validate_form {
my $c = $params{c}; my $c = $params{c};
my $resource = $params{resource}; my $resource = $params{resource};
my $form = $params{form}; my $form = $params{form};
my $item = $params{item};
my $run = $params{run} // 1; my $run = $params{run} // 1;
my $form_params = $params{form_params} // {}; my $form_params = $params{form_params} // {};
@ -246,7 +247,13 @@ sub validate_form {
if($run) { if($run) {
# check keys/vals # check keys/vals
$form->process(params => $resource, posted => 1, %{$form_params} ); $form->process(
params => $resource,
posted => 1,
%{$form_params},
item => $item,
no_update => 1
);
unless($form->validated) { unless($form->validated) {
my $e = join '; ', map { my $e = join '; ', map {
my $in = (defined $_->input && ref $_->input eq 'HASH' && exists $_->input->{id}) ? $_->input->{id} : ($_->input // ''); my $in = (defined $_->input && ref $_->input eq 'HASH' && exists $_->input->{id}) ? $_->input->{id} : ($_->input // '');
@ -1297,6 +1304,7 @@ sub update_item {
c => $c, c => $c,
resource => $resource, resource => $resource,
form => $form, form => $form,
item => $item,
); );
return unless $resource; return unless $resource;
} }

@ -79,6 +79,7 @@ sub update_item {
c => $c, c => $c,
form => $form, form => $form,
resource => $resource, resource => $resource,
item => $item,
); );
if($c->user->roles eq "admin") { if($c->user->roles eq "admin") {
} elsif($c->user->roles eq "reseller") { } elsif($c->user->roles eq "reseller") {

@ -25,7 +25,7 @@ fi
if [ "${SELECT}" = "stable" ] ; then if [ "${SELECT}" = "stable" ] ; then
echo "Test selection: ${SELECT}" echo "Test selection: ${SELECT}"
SELECT=$(echo ./t/api-rest/api-{all-links,balanceintervals,bannedips,bannedusers,billingfees,billingnetworks,billingprofiles,billingzones,calllists,calls,cert-auth,cfdestinationsets,contracts,conversations,customercontacts,customers,faxes,journals,lnp,ncoslevels,pbxdevicemodels,pbxdevices,peeringgroups,peeringrules,peeringinboundrules,peeringservers,preferences,profilepackages,resellers,rewriterules,rewriterulesets,root,soundsets,subscriberregistrations,subscribers,systemcontacts,threads,topuplogs,trustedsources,valid-patch,vouchers,method-override}.t) SELECT=$(echo ./t/api-rest/api-{all-links,balanceintervals,bannedips,bannedusers,billingfees,billingnetworks,billingprofiles,billingzones,calllists,calls,cert-auth,cfdestinationsets,contracts,conversations,customercontacts,customers,emailtemplates,faxes,journals,lnp,ncoslevels,pbxdevicemodels,pbxdevices,peeringgroups,peeringrules,peeringinboundrules,peeringservers,preferences,profilepackages,resellers,rewriterules,rewriterulesets,root,soundsets,subscriberregistrations,subscribers,systemcontacts,threads,topuplogs,trustedsources,valid-patch,vouchers,method-override}.t)
elif [ "${SELECT}" = "fast" ] ; then elif [ "${SELECT}" = "fast" ] ; then
echo "Test selection: ${SELECT}" echo "Test selection: ${SELECT}"
SELECT=$(echo ./t/api-rest/api-{bannedips,bannedusers,billingnetworks,billingzones,calls,cert-auth,cfdestinationsets,ncoslevels,peeringgroups,peeringrules,peeringinboundrules,peeringservers,resellers,rewriterules,root,soundsets,systemcontacts,valid-patch,vouchers,method-override}.t) SELECT=$(echo ./t/api-rest/api-{bannedips,bannedusers,billingnetworks,billingzones,calls,cert-auth,cfdestinationsets,ncoslevels,peeringgroups,peeringrules,peeringinboundrules,peeringservers,resellers,rewriterules,root,soundsets,systemcontacts,valid-patch,vouchers,method-override}.t)

Loading…
Cancel
Save