fixes to content wizard
This commit is contained in:
parent
3c17dafeb4
commit
ea1a020ab5
2 changed files with 81 additions and 39 deletions
|
|
@ -2053,50 +2053,42 @@ anything.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub processEditForm {
|
sub processEditForm {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %data;
|
my %data;
|
||||||
my $form = $self->session->form;
|
my $form = $self->session->form;
|
||||||
my $overrides = $self->session->config->get("assets/".$self->get("className")."/fields");
|
my $overrides = $self->session->config->get( "assets/" . $self->get("className") . "/fields" );
|
||||||
|
|
||||||
foreach my $property ($self->getProperties) {
|
foreach my $property ( $self->getProperties ) {
|
||||||
my %params = %{$self->getFormProperties($property)};
|
my $fieldType = $self->meta->find_attribute_by_name($property)->fieldType;
|
||||||
|
my $fieldOverrides = $overrides->{$property} || {};
|
||||||
|
my $fieldHash = {
|
||||||
|
tab => "properties",
|
||||||
|
%{ $self->getFormProperties($property) },
|
||||||
|
%{$overrides},
|
||||||
|
name => $property,
|
||||||
|
value => $self->$property,
|
||||||
|
};
|
||||||
|
|
||||||
|
next if ( $fieldHash->{noFormPost} );
|
||||||
|
|
||||||
|
# process the form element
|
||||||
|
$data{$property} = $form->process( $property, $fieldType, $fieldHash->{defaultValue}, $fieldHash );
|
||||||
|
} ## end foreach my $property ( $self...)
|
||||||
|
|
||||||
# apply config file changes
|
|
||||||
foreach my $key (keys %{$overrides->{$property}}) {
|
|
||||||
$params{$key} = $overrides->{$property}{$key};
|
|
||||||
}
|
|
||||||
|
|
||||||
# deal with properties that can't be posted through the form
|
|
||||||
if ($params{noFormPost}) {
|
|
||||||
if ($form->process("assetId") eq "new" && $self->get($property) eq "") {
|
|
||||||
$data{$property} = $params{defaultValue};
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# process the form element
|
|
||||||
$params{name} = $property;
|
|
||||||
$params{value} = $self->$property;
|
|
||||||
$data{$property} = $form->process(
|
|
||||||
$property,
|
|
||||||
$params{fieldType},
|
|
||||||
$params{defaultValue},
|
|
||||||
\%params
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$data{keywords} = $form->process("keywords");
|
$data{keywords} = $form->process("keywords");
|
||||||
if ($self->session->setting->get("metaDataEnabled")) {
|
if ( $self->session->setting->get("metaDataEnabled") ) {
|
||||||
my $meta = $self->getMetaDataFields;
|
my $meta = $self->getMetaDataFields;
|
||||||
foreach my $field (keys %{$meta}) {
|
foreach my $field ( keys %{$meta} ) {
|
||||||
my $value = $form->process("metadata_".$field, $meta->{$field}{fieldType}, $meta->{$field}{defaultValue});
|
my $value
|
||||||
$self->updateMetaData($field, $value);
|
= $form->process( "metadata_" . $field, $meta->{$field}{fieldType}, $meta->{$field}{defaultValue} );
|
||||||
}
|
$self->updateMetaData( $field, $value );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$self->session->db->beginTransaction;
|
$self->session->db->beginTransaction;
|
||||||
$self->update(\%data);
|
$self->update( \%data );
|
||||||
$self->session->db->commit;
|
$self->session->db->commit;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
} ## end sub processEditForm
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -2601,7 +2593,7 @@ sub www_editSave {
|
||||||
##If this is a new asset (www_add), the parent may be locked. We should still be able to add a new asset.
|
##If this is a new asset (www_add), the parent may be locked. We should still be able to add a new asset.
|
||||||
my $isNewAsset = $session->form->process("assetId") eq "new" ? 1 : 0;
|
my $isNewAsset = $session->form->process("assetId") eq "new" ? 1 : 0;
|
||||||
return $session->privilege->locked() if (!$self->canEditIfLocked and !$isNewAsset);
|
return $session->privilege->locked() if (!$self->canEditIfLocked and !$isNewAsset);
|
||||||
return $session->privilege->insufficient() unless $self->canEdit && $session->form->validToken;
|
return $session->privilege->insufficient() unless $self->canEdit;
|
||||||
if ($self->session->config("maximumAssets")) {
|
if ($self->session->config("maximumAssets")) {
|
||||||
my ($count) = $self->session->db->quickArray("select count(*) from asset");
|
my ($count) = $self->session->db->quickArray("select count(*) from asset");
|
||||||
my $i18n = WebGUI::International->new($self->session, "Asset");
|
my $i18n = WebGUI::International->new($self->session, "Asset");
|
||||||
|
|
|
||||||
|
|
@ -308,6 +308,56 @@ sub t_05_purge : Test(3) {
|
||||||
ok ! $exists_in_table, 'assetId removed from all asset tables';
|
ok ! $exists_in_table, 'assetId removed from all asset tables';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub cut_paste : Test(5) {
|
||||||
|
note "cut";
|
||||||
|
my $test = shift;
|
||||||
|
my $session = $test->session;
|
||||||
|
my ($tag, $asset, @parents) = $test->getAnchoredAsset();
|
||||||
|
ok $asset->cut, 'cut returns true if it was cut';
|
||||||
|
is $asset->state, 'clipboard', 'asset state updated';
|
||||||
|
my $session_asset = $session->asset();
|
||||||
|
$session->asset($parents[-1]);
|
||||||
|
ok $asset->canPaste, 'canPaste: allowed to paste here';
|
||||||
|
ok $parents[-1]->paste($asset->assetId), 'paste returns true when it pastes';
|
||||||
|
$asset_prime = $asset->cloneFromDb;
|
||||||
|
is $asset_prime->state, 'published', 'asset state updated';
|
||||||
|
$session->asset($session_asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub addRevision : Tests {
|
||||||
|
note "addRevision";
|
||||||
|
my ( $test ) = @_;
|
||||||
|
my $session = $test->session;
|
||||||
|
my ( $tag, $asset, @parents ) = $test->getAnchoredAsset();
|
||||||
|
$tag->setWorking;
|
||||||
|
|
||||||
|
my $newRevision = $asset->addRevision( { title => "Newly Revised Title" }, $asset->revisionDate+2 );
|
||||||
|
isa_ok( $newRevision, Scalar::Util::blessed( $asset ), "addRevision returns new revision of asset object" );
|
||||||
|
is( $newRevision->title, "Newly Revised Title", "properties set correctly" );
|
||||||
|
is( $newRevision->revisionDate, $asset->revisionDate+2, 'revisionDate set correctly' );
|
||||||
|
is( $newRevision->tagId, $tag->getId, "Added to existing working tag" );
|
||||||
|
|
||||||
|
$newRevision->purgeRevision;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub www_editSave : Tests {
|
||||||
|
note "www_editSave";
|
||||||
|
my ( $test ) = @_;
|
||||||
|
my $session = $test->session;
|
||||||
|
my ( $tag, $asset, @parents ) = $test->getAnchoredAsset();
|
||||||
|
$tag->setWorking;
|
||||||
|
$session->request->setup_body({
|
||||||
|
title => "Newly Saved Title",
|
||||||
|
} );
|
||||||
|
$asset->www_editSave;
|
||||||
|
|
||||||
|
# Get the newly-created revision of the asset
|
||||||
|
my $newRevision = WebGUI::Asset->newPending( $session, $asset->getId );
|
||||||
|
ok( $newRevision->tagId, 'new revision has a tag' );
|
||||||
|
is( $newRevision->tagId, $tag->getId, 'new revision tagId is current working tag' );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue