almost done fixing addRevision changes

This commit is contained in:
Doug Bell 2010-11-16 11:18:41 -06:00
parent 3ce9198220
commit 1866c593ea
25 changed files with 186 additions and 199 deletions

View file

@ -455,7 +455,9 @@ sub www_editSubmissionSave {
my $formParams = $self->processForm;
if( $formParams->{_isValid} ) {
delete $formParams->{_isValid};
$self->addRevision($formParams);
my $tag = WebGUI::VersionTag->getWorking( $session );
my $newRevision = $self->addRevision({%$formParams,tagId => $tag->getId, status => "pending",});
$newRevision->setVersionLock;
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { override => 1, allowComments => 0 });
$self = $self->cloneFromDb;
$self->sendEmailUpdate;

View file

@ -334,7 +334,9 @@ sub www_editSubmissionFormSave {
my $formParams = $self->processForm();
if( $formParams->{_isValid} ) {
delete $formParams->{_isValid};
$self->addRevision($formParams);
my $tag = WebGUI::VersionTag->getWorking( $self->session );
my $newRevision = $self->addRevision({%$formParams,tagId => $tag->getId, status => "pending",});
$newRevision->setVersionLock;
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
$self = $self->cloneFromDb;
return $self->getParent->www_viewSubmissionQueue;

View file

@ -1391,16 +1391,7 @@ override processEditForm => sub {
return \@errors;
}
# Since we may be adding more events, set out version tag to be active if needed
# Leave the original version tag available, we will need to reactivate it before returning
my $activeVersionTag = WebGUI::VersionTag->getWorking($session, 'nocreate');
# if our version tag is active, we don't need a new one, and don't need to reactivate anything later
if ($activeVersionTag && $activeVersionTag->getId eq $self->get('tagId')) {
undef $activeVersionTag;
}
else {
WebGUI::VersionTag->new($session, $self->tagId)->setWorking;
}
my $tag = WebGUI::VersionTag->getWorking( $session );
### Form is verified, fix properties
if (!$session->form->hasParam('groupIdView')) {
@ -1535,8 +1526,6 @@ override processEditForm => sub {
if ($recurrence_new) {
my $new_id = $self->setRecurrence($recurrence_new);
if (! $new_id) {
$activeVersionTag->setWorking
if $activeVersionTag;
return ["There is something wrong with your recurrence pattern."];
}
@ -1592,14 +1581,15 @@ override processEditForm => sub {
# Add a revision
$properties{ startDate } = $event->startDate;
$properties{ endDate } = $event->endDate;
$properties{ tagId } = $tag->getId;
$properties{ status } = "pending";
# addRevision returns the new revision
$event = $event->addRevision(\%properties, undef, { skipAutoCommitWorkflows => 1 });
$event = $event->addRevision(\%properties);
$event->setVersionLock;
}
}
}
$activeVersionTag->setWorking
if $activeVersionTag;
delete $self->{_storageLocation};
return undef;

View file

@ -321,7 +321,9 @@ sub www_annotate {
return $session->privilege->insufficient() unless $self->canEdit;
return $session->privilege->locked() unless $self->canEditIfLocked;
if (1) {
my $newSelf = $self->addRevision();
my $tag = WebGUI::VersionTag->getWorking( $session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
delete $newSelf->{_storageLocation};
$newSelf->getStorageLocation->annotate($newSelf->filename,$newSelf,$session->form);
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
@ -540,7 +542,9 @@ sub www_rotate {
return $session->privilege->insufficient() unless $self->canEdit;
return $session->privilege->locked() unless $self->canEditIfLocked;
if (defined $session->form->process("Rotate")) {
my $newSelf = $self->addRevision();
my $tag = WebGUI::VersionTag->getWorking( $session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
delete $newSelf->{_storageLocation};
$newSelf->getStorageLocation->rotate($newSelf->filename,$session->form->process("Rotate"));
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
@ -599,7 +603,9 @@ sub www_resize {
return $session->privilege->insufficient() unless $self->canEdit;
return $session->privilege->locked() unless $self->canEditIfLocked;
if ($session->form->process("newWidth") || $session->form->process("newHeight")) {
my $newSelf = $self->addRevision();
my $tag = WebGUI::VersionTag->getWorking( $session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
delete $newSelf->{_storageLocation};
$newSelf->getStorageLocation->resize($newSelf->filename,$session->form->process("newWidth"),$session->form->process("newHeight"));
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
@ -707,7 +713,9 @@ sub www_crop {
if ($session->form->process("Width") || $session->form->process("Height")
|| $session->form->process("Top") || $session->form->process("Left")) {
my $newSelf = $self->addRevision();
my $tag = WebGUI::VersionTag->getWorking( $session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
delete $newSelf->{_storageLocation};
$newSelf->getStorageLocation->crop(
$newSelf->filename,

View file

@ -837,7 +837,9 @@ sub www_editDuplicate {
next PROP unless lc $properties->{ $prop }->{ fieldType } eq "template";
next PROP unless $asset->get( $prop ) eq $self->getId;
if ( $properties->{ $prop }->{ namespace } eq $self->get( "namespace" ) ) {
$asset->addRevision( { $prop => $newTemplate->getId } );
my $tag = WebGUI::VersionTag->getWorking( $session );
$asset->addRevision( { $prop => $newTemplate->getId, tagId => $tag->getId, status => "pending" } );
$asset->setVersionLock;
# Auto-commit our revision if necessary
# TODO: This needs to be handled automatically somehow...
@ -1087,9 +1089,12 @@ sub www_styleWizard {
</div>
</body>
</html>';
return $self->addRevision({
my $tag = WebGUI::VersionTag->getWorking( $self->session );
my $newSelf = $self->addRevision({
template=>$style
})->www_edit;
});
$newSelf->setVersionLock;
return $newSelf->www_edit;
} else {
$output = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl}).WebGUI::Form::hidden($self->session,{name=>"func", value=>"styleWizard"});
$output .= WebGUI::Form::hidden($self->session,{name=>"proceed", value=>"manageAssets"}) if ($form->get("proceed"));

View file

@ -1423,7 +1423,9 @@ sub www_deleteFieldConfirm {
unless $self->canEdit;
return $self->session->privilege->locked
unless $self->canEditIfLocked;
my $newSelf = $self->addRevision;
my $tag = WebGUI::VersionTag->getWorking( $self->session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
$newSelf->deleteField($self->session->form->process("fieldName"));
$newSelf->{_mode} = 'form';
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
@ -1450,7 +1452,9 @@ sub www_deleteTabConfirm {
unless $self->canEdit;
return $self->session->privilege->locked
unless $self->canEditIfLocked;
my $newSelf = $self->addRevision;
my $tag = WebGUI::VersionTag->getWorking( $self->session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
$newSelf->deleteTab($self->session->form->process("tabId"));
$newSelf->{_mode} = 'form';
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
@ -1667,7 +1671,9 @@ sub www_editFieldSave {
$field{isMailField} = 1;
}
my $newSelf = $self->addRevision;
my $tag = WebGUI::VersionTag->getWorking( $session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
if ($fieldName) {
if ($fieldName ne $newName) {
$newSelf->renameField($fieldName, $newName);
@ -1923,7 +1929,9 @@ sub www_moveFieldDown {
unless $self->canEdit;
return $self->session->privilege->locked
unless $self->canEditIfLocked;
my $newSelf = $self->addRevision;
my $tag = WebGUI::VersionTag->getWorking( $self->session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
my $fieldName = $self->session->form->process('fieldName');
$newSelf->moveFieldDown($fieldName);
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
@ -1983,7 +1991,9 @@ sub www_moveFieldUp {
unless $self->canEdit;
return $self->session->privilege->locked
unless $self->canEditIfLocked;
my $newSelf = $self->addRevision;
my $tag = WebGUI::VersionTag->getWorking( $self->session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
my $fieldName = $self->session->form->process('fieldName');
$newSelf->moveFieldUp($fieldName);
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
@ -2044,7 +2054,9 @@ sub www_moveTabRight {
unless $self->canEdit;
return $self->session->privilege->locked
unless $self->canEditIfLocked;
my $newSelf = $self->addRevision;
my $tag = WebGUI::VersionTag->getWorking( $self->session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
my $tabId = $self->session->form->process('tabId');
$newSelf->moveTabRight($tabId);
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
@ -2100,7 +2112,9 @@ sub www_moveTabLeft {
unless $self->canEdit;
return $self->session->privilege->locked
unless $self->canEditIfLocked;
my $newSelf = $self->addRevision;
my $tag = WebGUI::VersionTag->getWorking( $self->session );
my $newSelf = $self->addRevision({ tagId => $tag->getId, status => "pending" });
$newSelf->setVersionLock;
my $tabId = $self->session->form->process('tabId');
$newSelf->moveTabLeft($tabId);
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);

View file

@ -771,8 +771,11 @@ sub processFileSynopsis {
if ( $asset->synopsis ne $synopsis ) {
my $properties = $asset->get;
$properties->{ synopsis } = $synopsis;
$properties->{ tagId } = $newVersionTag->getId;
$properties->{ status } = "pending";
$asset->addRevision( $properties, undef, { skipAutoCommitWorkflows => 1 } );
my $newRev = $asset->addRevision( $properties );
$newRev->setVersionLock;
}
}
@ -1440,7 +1443,9 @@ sub www_edit {
if ( ! Exception::Class->caught() ) {
# Add revision and create a new version tag by doing so
my $newRevision = $asset->addRevision;
my $tag = WebGUI::VersionTag->create( $session, { workflowId => $asset->getAutoCommitWorkflowId } );
my $newRevision = $asset->addRevision({ tagId => $tag->getId, status => "pending" });
$newRevision->setVersionLock;
# Rotate photo (i.e. all attached image files) by 90° CCW
$newRevision->rotate(-90);
# Auto-commit version tag
@ -1458,7 +1463,9 @@ sub www_edit {
if ( Exception::Class->caught() ) {
# Add revision and create a new version tag by doing so
my $newRevision = $asset->addRevision;
my $tag = WebGUI::VersionTag->create( $session, { workflowId => $asset->getAutoCommitWorkflowId } );
my $newRevision = $asset->addRevision({ tagId => $tag->getId, status => "pending" });
$newRevision->setVersionLock;
# Rotate photo (i.e. all attached image files) by 90° CW
$newRevision->rotate(90);
# Auto-commit version tag

View file

@ -322,9 +322,11 @@ a new asset revision.
sub www_setContentPositions {
my $self = shift;
return $self->session->privilege->insufficient() unless ($self->canEdit);
$self->addRevision({
my $tag = WebGUI::VersionTag->getWorking( $self->session );
my $newSelf = $self->addRevision({
contentPositions=>$self->session->form->process("map")
});
$newSelf->setVersionLock;
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
return "Map set: ".$self->session->form->process("map");
}

View file

@ -554,12 +554,20 @@ sub www_ajaxEditPointSave {
unless $asset && $asset->canEdit;
$asset = $asset->addRevision;
}
my $errors = $asset->processAjaxEditForm;
# Commit!
if ( $asset->getAutoCommitWorkflowId ) {
if ( $self->hasBeenCommitted) {
my $tag = WebGUI::VersionTag->create( $session, {
workflowId => $asset->getAutoCommitWorkflowId,
} );
$asset->update({
tagId => $tag->getId,
status => "pending",
});
$asset->setVersionLock;
$asset->requestAutoCommit;
}
else {

View file

@ -837,18 +837,16 @@ sub submitObjectEdit {
. $self->revisionDate );
# New revision should be created and then committed automatically
my $oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate');
my $newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', });
$newVersionTag->setWorking;
# Create the new revision
$survey = $self->addRevision;
$survey = $self->addRevision({
tagId => $newVersionTag->getId,
status => "pending",
});
$newVersionTag->commit();
$survey = $survey->cloneFromDb;
#Restore the old one, if it exists
$oldVersionTag->setWorking() if $oldVersionTag;
}
# See if any special actions were requested..