Skip to content
Permalink
Browse files

Make version tags mandatory again.

  • Loading branch information...
perlDreamer committed Oct 26, 2011
1 parent d0b3be1 commit 4bfabb9469c92c43de9a32c6773339c811b4cf7f
Showing with 405 additions and 489 deletions.
  1. +0 −9 docs/migration.txt
  2. +1 −69 lib/WebGUI/Asset.pm
  3. +4 −1 lib/WebGUI/Asset/EMSSubmission.pm
  4. +0 −1 lib/WebGUI/Asset/EMSSubmissionForm.pm
  5. +2 −2 lib/WebGUI/Asset/Post.pm
  6. +1 −1 lib/WebGUI/Asset/Post/Thread.pm
  7. +2 −2 lib/WebGUI/Asset/Sku/Subscription.pm
  8. +1 −1 lib/WebGUI/Asset/Wobject/Collaboration.pm
  9. +18 −1 lib/WebGUI/Asset/Wobject/StoryArchive.pm
  10. +5 −8 lib/WebGUI/AssetHelper/Copy.pm
  11. +7 −7 lib/WebGUI/AssetHelper/CopyBranch.pm
  12. +0 −2 lib/WebGUI/AssetHelper/CreateShortcut.pm
  13. +0 −7 lib/WebGUI/AssetHelper/Duplicate.pm
  14. +1 −1 lib/WebGUI/AssetHelper/EditBranch.pm
  15. +2 −3 lib/WebGUI/AssetHelper/Image/Crop.pm
  16. +1 −2 lib/WebGUI/AssetHelper/Image/Resize.pm
  17. +1 −2 lib/WebGUI/AssetHelper/Image/Rotate.pm
  18. +1 −6 lib/WebGUI/AssetHelper/Lock.pm
  19. +29 −1 lib/WebGUI/AssetVersioning.pm
  20. +1 −1 lib/WebGUI/Fork.pm
  21. +1 −1 lib/WebGUI/Shop/Credit.pm
  22. +27 −27 lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm
  23. +4 −24 t/Asset/Asset.t
  24. +6 −11 t/Asset/AssetClipboard.t
  25. +0 −10 t/Asset/AssetExportHtml.t
  26. +0 −12 t/Asset/AssetLineage.t
  27. +0 −3 t/Asset/AssetMetaData.t
  28. +1 −13 t/Asset/AssetPackage.t
  29. +9 −8 t/Asset/AssetVersion.t
  30. +16 −7 t/Asset/EMSSubmissionForm.t
  31. +0 −4 t/Asset/Event.t
  32. +0 −4 t/Asset/Event/permissions.t
  33. +0 −2 t/Asset/File.t
  34. +0 −4 t/Asset/File/GalleryFile/Photo/00base.t
  35. +0 −4 t/Asset/File/GalleryFile/Photo/adjustOrientation.t
  36. +0 −4 t/Asset/File/GalleryFile/Photo/exif.t
  37. +9 −6 t/Asset/File/GalleryFile/Photo/navigation.t
  38. +9 −0 t/Asset/File/GalleryFile/Photo/view.t
  39. +5 −6 t/Asset/Post/Thread.t
  40. +0 −2 t/Asset/Post/Thread/getAdjacentThread.t
  41. +0 −4 t/Asset/Post/Thread/permission.t
  42. +15 −9 t/Asset/Post/archiving.t
  43. +3 −4 t/Asset/Post/committing.t
  44. +2 −5 t/Asset/Post/notification.t
  45. +0 −4 t/Asset/Post/permission.t
  46. +15 −9 t/Asset/Post/trashing.t
  47. +6 −1 t/Asset/Shortcut/forms.t
  48. +3 −0 t/Asset/Sku/EMSRibbon.t
  49. +3 −0 t/Asset/Sku/EMSTicket.t
  50. +3 −0 t/Asset/Sku/EMSToken.t
  51. +31 −7 t/Asset/Sku/Product.t
  52. +3 −0 t/Asset/Sku/Subscription.t
  53. +3 −5 t/Asset/Snippet.t
  54. +4 −0 t/Asset/Story.t
  55. +3 −11 t/Asset/Template.t
  56. +1 −2 t/Asset/WikiPage.t
  57. +0 −2 t/Asset/WikiPage/permissions.t
  58. +0 −18 t/Asset/Wobject/Calendar.t
  59. +1 −7 t/Asset/Wobject/Collaboration.t
  60. +13 −4 t/Asset/Wobject/Collaboration/getThreads.t
  61. +5 −0 t/Asset/Wobject/Collaboration/permission.t
  62. +12 −6 t/Asset/Wobject/Collaboration/templateVariables.t
  63. +4 −0 t/Asset/Wobject/DataForm.t
  64. +8 −16 t/Asset/Wobject/EventManagementSystem.t
  65. +0 −6 t/Asset/Wobject/Gallery/search.t
  66. +0 −8 t/Asset/Wobject/GalleryAlbum/addArchive.t
  67. +8 −8 t/Asset/Wobject/GalleryAlbum/navigation.t
  68. +0 −4 t/Asset/Wobject/GalleryAlbum/view.t
  69. +9 −1 t/Asset/Wobject/InOutBoard.t
  70. +9 −3 t/Asset/Wobject/Matrix.t
  71. +3 −0 t/Asset/Wobject/ProjectManager.t
  72. +4 −11 t/Asset/Wobject/Search.t
  73. +0 −5 t/Asset/Wobject/Search/searchroot.t
  74. +6 −12 t/Asset/Wobject/StoryArchive.t
  75. +3 −0 t/Asset/Wobject/Survey.t
  76. +6 −0 t/Asset/Wobject/Thingy.t
  77. +1 −3 t/Asset/Wobject/Thingy/indexing.t
  78. +3 −0 t/AssetHelper/ChangeUrl.t
  79. +1 −2 t/AssetHelper/Copy.t
  80. +6 −6 t/AssetHelper/CopyBranch.t
  81. +2 −0 t/AssetHelper/CreateShortcut.t
  82. +2 −0 t/AssetHelper/ExportHtml.t
  83. +2 −0 t/AssetHelper/Lock.t
  84. +3 −0 t/AssetHelper/Product/ExportCSV.t
  85. +5 −1 t/Auth/mech.t
  86. +0 −2 t/Form/Template.t
  87. +3 −0 t/Keyword.t
  88. +0 −2 t/Macro/RootTitle.t
  89. +1 −0 t/Shop/TransactionItem.t
  90. +11 −17 t/VersionTag.t
  91. +4 −0 t/Workflow/Activity/ArchiveOldStories.t
  92. +5 −0 t/Workflow/Activity/ExtendCalendarRecurrences.t
  93. +6 −1 t/Workflow/Activity/NotifyAboutLowStock.t
  94. +0 −4 t/tests/Test/WebGUI/Asset.pm
@@ -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
@@ -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;
@@ -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') {
@@ -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;
@@ -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",
@@ -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;
}

@@ -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;
@@ -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 });
}
}
}
@@ -45,7 +45,7 @@ property lastPostId => (
property lastPostDate => (
noFormPost => 1,
fieldType => "dateTime",
default => undef,
default => 0,
);
property karma => (
noFormPost => 1,
@@ -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" );

@@ -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',
@@ -121,6 +121,7 @@ use WebGUI::Asset::Wobject::Folder;
use WebGUI::Paginator;
use WebGUI::Keyword;
use WebGUI::Search;
use WebGUI::VersionTag;

use File::Path;

@@ -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({
@@ -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();
@@ -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;
@@ -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
@@ -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;
@@ -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,
@@ -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);
@@ -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},
);
@@ -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,
@@ -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' ) {
@@ -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,
@@ -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));
@@ -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),
};
Oops, something went wrong.

0 comments on commit 4bfabb9

Please sign in to comment.
You can’t perform that action at this time.