Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make version tags mandatory again.
  • Loading branch information
perlDreamer committed Oct 26, 2011
1 parent d0b3be1 commit 4bfabb9
Show file tree
Hide file tree
Showing 94 changed files with 405 additions and 489 deletions.
9 changes: 0 additions & 9 deletions docs/migration.txt
Expand Up @@ -281,15 +281,6 @@ processPropertiesFromFormPost
-----------------------------
Absurdly long and non-descriptive name, changed to processEditForm

Versioning
----------
New revisions are not created in a "pending" state automatically. VersionTags
are not created by calling addRevision(). If you want a revision to be part of
a version tag, you must set
status => "pending",
tagId => $tag->getId,
explicitly.

Admin Controls
--------------------
The admin controls are now added to the asset with javascript. This javascript
Expand Down
70 changes: 1 addition & 69 deletions lib/WebGUI/Asset.pm
Expand Up @@ -2776,40 +2776,12 @@ sub www_addSave {
return $self->session->style->userStyle($i18n->get("over max assets")) if ($self->session->config->get("maximumAssets") <= $count);
}

# Determine what version tag we should use
my $autoCommitId = $self->getAutoCommitWorkflowId();

my ($workingTag, $oldWorking);
if ( $autoCommitId ) {
$workingTag
= WebGUI::VersionTag->create( $session, {
groupToUse => '12', # Turn Admin On (for lack of something better)
workflowId => $autoCommitId,
} );
}
else {
my $parentAsset;
if ( not defined( $parentAsset = $self->getParent ) ) {
$parentAsset = WebGUI::Asset->newPending( $session, $self->parentId );
}
if ( $parentAsset->hasBeenCommitted ) {
$workingTag = WebGUI::VersionTag->getWorking( $session );
}
else {
$oldWorking = WebGUI::VersionTag->getWorking($session, 'noCreate');
$workingTag = WebGUI::VersionTag->new( $session, $parentAsset->tagId );
$workingTag->setWorking();
}
}

# Add the new asset
my $object;
my $className = $form->process('className','className') || $form->process('class','className');
$object = $self->addChild({
className => $className,
revisedBy => $session->user->userId,
tagId => $workingTag->getId,
status => "pending",
});
if ( !defined $object ) {
my $url = $session->url->page;
Expand All @@ -2819,11 +2791,6 @@ sub www_addSave {
$object->{_parent} = $self;
$object->url(undef);

# More version tag stuff
$object->setVersionLock;
$object->setAutoCommitTag($workingTag) if (defined $autoCommitId);
$oldWorking->setWorking if $oldWorking;

# Process properties from form post
my $errors = $object->processEditForm;
if (ref $errors eq 'ARRAY') {
Expand Down Expand Up @@ -2924,43 +2891,8 @@ sub www_editSave {
return $session->privilege->locked() unless $self->canEditIfLocked;
return $session->privilege->insufficient() unless $self->canEdit;

# Determine what version tag we should use
my $autoCommitId = $self->getAutoCommitWorkflowId();

my ($workingTag, $oldWorking);
if ( $autoCommitId ) {
$workingTag
= WebGUI::VersionTag->create( $session, {
groupToUse => '12', # Turn Admin On (for lack of something better)
workflowId => $autoCommitId,
} );
}
else {
my $parentAsset;
if ( not defined( $parentAsset = $self->getParent ) ) {
$parentAsset = WebGUI::Asset->newPending( $session, $self->parentId );
}
if ( $parentAsset->hasBeenCommitted ) {
$workingTag = WebGUI::VersionTag->getWorking( $session );
}
else {
$oldWorking = WebGUI::VersionTag->getWorking($session, 'noCreate');
$workingTag = WebGUI::VersionTag->new( $session, $parentAsset->tagId );
$workingTag->setWorking();
}
}

# Add the new revision
my $object = $self->addRevision({
revisedBy => $session->user->userId,
tagId => $workingTag->getId,
status => "pending",
});

# More version tag stuff
$object->setVersionLock;
$object->setAutoCommitTag($workingTag) if (defined $autoCommitId);
$oldWorking->setWorking if $oldWorking;
my $object = $self->addRevision();

# Process properties from form post
my $errors = $object->processEditForm;
Expand Down
5 changes: 4 additions & 1 deletion lib/WebGUI/Asset/EMSSubmission.pm
Expand Up @@ -98,11 +98,14 @@ property seatsAvailable => (
property startDate => (
noFormPost => 1,
fieldType => "dateTime",
default => '',
builder => '_default_startDate',
label => [ "add/edit event start date", 'Asset_EMSSubmission' ],
hoverHelp => [ "add/edit event start date help", 'Asset_EMSSubmission' ],
autoGenerate => 0,
);
sub _default_startDate {
return WebGUI::DateTime->new()->toMysql;
}
property duration => (
tab => "properties",
fieldType => "float",
Expand Down
1 change: 0 additions & 1 deletion lib/WebGUI/Asset/EMSSubmissionForm.pm
Expand Up @@ -123,7 +123,6 @@ sub addSubmission {
$newParams->{submissionId} = $self->ems->getNextSubmissionId;
my $newAsset = $self->addChild($newParams);
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, { override => 1, allowComments => 0 });
$self = $self->cloneFromDb;
return $newAsset;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/WebGUI/Asset/Post.pm
Expand Up @@ -344,7 +344,7 @@ sub disqualifyAsLastPost {
$thread->update({ lastPostId => $secondary_post->getId, lastPostDate => $secondary_post->get('creationDate'), });
}
else {
$thread->update({ lastPostId => '', lastPostDate => '', });
$thread->update({ lastPostId => '', lastPostDate => 0 });
}
}
my $cs = $thread->getParent;
Expand All @@ -359,7 +359,7 @@ sub disqualifyAsLastPost {
$cs->update({ lastPostId => $secondary_post->getId, lastPostDate => $secondary_post->get('creationDate'), });
}
else {
$cs->update({ lastPostId => '', lastPostDate => '', });
$cs->update({ lastPostId => '', lastPostDate => 0 });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/WebGUI/Asset/Post/Thread.pm
Expand Up @@ -45,7 +45,7 @@ property lastPostId => (
property lastPostDate => (
noFormPost => 1,
fieldType => "dateTime",
default => undef,
default => 0,
);
property karma => (
noFormPost => 1,
Expand Down
4 changes: 2 additions & 2 deletions lib/WebGUI/Asset/Sku/Subscription.pm
Expand Up @@ -620,13 +620,13 @@ sub www_createSubscriptionCodeBatch {
name => 'name',
label => $i18n->get('batch name'),
hoverHelp => $i18n->get('batch name description'),
value => $session->form->process('name'),
value => $session->form->process('name') || '',
);
$f->addField( "textarea",
name => 'description',
label => $i18n->get('batch description'),
hoverHelp => $i18n->get('batch description description'),
value => $session->form->process("description"),
value => $session->form->process("description") || '',
);
$f->addField( "submit", name => "send" );

Expand Down
2 changes: 1 addition & 1 deletion lib/WebGUI/Asset/Wobject/Collaboration.pm
Expand Up @@ -1379,7 +1379,7 @@ around groupIdView => sub {
my $oldValue = $self->$orig;
my $return = $self->$orig(@_);
# Update the subscription group so if they can't see the collab, they don't get e-mailed
if ( $newValue && $newValue != $oldValue ) {
if ( $newValue && $newValue ne $oldValue ) {
my $instance_data = {
workflowId => 'xR-_GRRbjBojgLsFx3dEMA',
className => 'WebGUI::Asset',
Expand Down
19 changes: 18 additions & 1 deletion lib/WebGUI/Asset/Wobject/StoryArchive.pm
Expand Up @@ -121,6 +121,7 @@ use WebGUI::Asset::Wobject::Folder;
use WebGUI::Paginator;
use WebGUI::Keyword;
use WebGUI::Search;
use WebGUI::VersionTag;

use File::Path;

Expand Down Expand Up @@ -302,7 +303,20 @@ sub getFolder {
my $folder = eval { WebGUI::Asset->newByUrl($session, $folderUrl); };
return $folder if !Exception::Class->caught();

##The requested folder doesn't exist. Make it.
##The requested folder doesn't exist. Make it and autocommit it.

##For a fully automatic commit, save the current tag, create a new one
##with the commit without approval workflow, commit it, then restore
##the original if it exists
my ($oldVersionTag, $newVersionTag);
$oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate');

if ($self->hasBeenCommitted) {
$newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', });
$newVersionTag->setWorking;
$newVersionTag->set({ name => 'Adding folder '. $folderName. ' to archive '. $self->getUrl});
}


##Call SUPER because my addChild calls getFolder
$folder = $self->addChild({
Expand All @@ -313,6 +327,9 @@ sub getFolder {
isHidden => 1,
styleTemplateId => $self->styleTemplateId,
});
$newVersionTag->commit() if $newVersionTag;
##Restore the old one, if it exists
$oldVersionTag->setWorking() if $oldVersionTag;

##Get a new version of the asset from the db with the correct state
$folder = $folder->cloneFromDb();
Expand Down
13 changes: 5 additions & 8 deletions lib/WebGUI/AssetHelper/Copy.pm
Expand Up @@ -72,18 +72,15 @@ sub copy {
my $tree = WebGUI::ProgressTree->new($session, [ $asset->getId ] );
$process->update(sub { $tree->json });
my $newAsset = $asset->duplicate({ state => "clipboard" });

# If we aren't committing, add to a tag
if ( !$args->{commit} ) {
$newAsset->update({
status => "pending",
tagId => WebGUI::VersionTag->getWorking( $session )->getId,
});
}
$newAsset->update({ title => $newAsset->getTitle . ' (copy)'});

$tree->success($asset->getId);
$process->update(sub { $tree->json });

my $tag = WebGUI::VersionTag->getWorking($session);
if ($tag->canAutoCommit) {
$tag->commit;
}
}

1;
14 changes: 7 additions & 7 deletions lib/WebGUI/AssetHelper/CopyBranch.pm
Expand Up @@ -4,6 +4,7 @@ use strict;
use Class::C3;
use base qw/WebGUI::AssetHelper::Copy/;
use Scalar::Util qw{ blessed };
use WebGUI::VersionTag;

=head1 LEGAL
Expand Down Expand Up @@ -122,17 +123,16 @@ sub copyBranch {
$process->update(sub { $tree->json });
my $newAsset = $asset->duplicateBranch( $args->{childrenOnly} ? 1 : 0, 'clipboard' );

# If we aren't committing, add to a tag
if ( !$args->{commit} ) {
$newAsset->update({
status => "pending",
tagId => WebGUI::VersionTag->getWorking( $session )->getId,
});
}
$newAsset->update({ title => $newAsset->getTitle . ' (copy)'});

$tree->success($asset->getId);
$process->update(sub { $tree->json });

my $tag = WebGUI::VersionTag->getWorking($session);
if ($tag->canAutoCommit) {
$tag->commit;
}

}

1;
2 changes: 0 additions & 2 deletions lib/WebGUI/AssetHelper/CreateShortcut.pm
Expand Up @@ -48,8 +48,6 @@ sub process {
my $import = WebGUI::Asset->getImportNode( $session );
my $tag = WebGUI::VersionTag->getWorking( $session );
my $child = $import->addChild({
tagId => $tag->getId,
status => 'pending',
className => 'WebGUI::Asset::Shortcut',
shortcutToAssetId => $asset->getId,
title => $asset->getTitle,
Expand Down
7 changes: 0 additions & 7 deletions lib/WebGUI/AssetHelper/Duplicate.pm
Expand Up @@ -73,13 +73,6 @@ sub duplicate {
$process->update(sub { $tree->json });
my $newAsset = $asset->duplicate;

# If we aren't committing, add to a tag
if ( !$args->{commit} ) {
$newAsset->update({
status => "pending",
tagId => WebGUI::VersionTag->getWorking( $session )->getId,
});
}
$newAsset->update({ title => $newAsset->getTitle . ' (Duplicate)'});

$tree->success($asset->getId);
Expand Down
2 changes: 1 addition & 1 deletion lib/WebGUI/AssetHelper/EditBranch.pm
Expand Up @@ -405,7 +405,7 @@ sub www_editBranchSave {
my $revision;
if (scalar %$newData > 0) {
$revision = $descendant->addRevision(
{ %$newData, tagId => $tag->getId, status => "pending" },
{ %$newData, },
undef,
{skipAutoCommitWorkflows => 1, skipNotification => 1},
);
Expand Down
5 changes: 2 additions & 3 deletions lib/WebGUI/AssetHelper/Image/Crop.pm
Expand Up @@ -157,8 +157,7 @@ sub www_cropSave {
return $session->privilege->locked() unless $asset->canEditIfLocked;

my $tag = WebGUI::VersionTag->getWorking( $session );
$asset = $asset->addRevision({ tagId => $tag->getId, status => "pending" });
$asset->setVersionLock;
$asset = $asset->addRevision();
delete $asset->{_storageLocation};
$asset->getStorageLocation->crop(
$asset->filename,
Expand All @@ -171,7 +170,7 @@ sub www_cropSave {
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });

# We're in admin mode, close the dialog
my $helper = { message => 'Image croped', };
my $helper = { message => 'Image cropped', };
my $text = '<script type="text/javascript">';

if ( ref $helper eq 'HASH' ) {
Expand Down
3 changes: 1 addition & 2 deletions lib/WebGUI/AssetHelper/Image/Resize.pm
Expand Up @@ -146,8 +146,7 @@ sub www_resizeSave {
return $session->privilege->insufficient() unless $asset->canEdit;
return $session->privilege->locked() unless $asset->canEditIfLocked;
my $tag = WebGUI::VersionTag->getWorking($session);
$asset = $asset->addRevision( { tagId => $tag->getId, status => "pending" } );
$asset->setVersionLock;
$asset = $asset->addRevision();
delete $asset->{_storageLocation};
$asset->getStorageLocation->resize(
$asset->filename,
Expand Down
3 changes: 1 addition & 2 deletions lib/WebGUI/AssetHelper/Image/Rotate.pm
Expand Up @@ -91,8 +91,7 @@ sub www_rotateSave {
return $session->privilege->locked() unless $asset->canEditIfLocked;

my $tag = WebGUI::VersionTag->getWorking( $session );
$asset = $asset->addRevision({ tagId => $tag->getId, status => "pending" });
$asset->setVersionLock;
$asset = $asset->addRevision();
delete $asset->{_storageLocation};
$asset->getStorageLocation->rotate($asset->filename,$session->form->process("Rotate"));
$asset->setSize($asset->getStorageLocation->getFileSize($asset->filename));
Expand Down
7 changes: 1 addition & 6 deletions lib/WebGUI/AssetHelper/Lock.pm
Expand Up @@ -53,12 +53,7 @@ sub process {
return { error => sprintf $i18n->get('already locked'), $asset->getTitle};
}

my $tag = WebGUI::VersionTag->getWorking( $session );
$asset = $asset->addRevision({
tagId => $tag->getId,
status => "pending",
});
$asset->setVersionLock;
$asset->addRevision;
return {
message => sprintf($i18n->get('locked asset'), $asset->getTitle),
};
Expand Down

0 comments on commit 4bfabb9

Please sign in to comment.