diff --git a/docs/upgrades/upgrade_7.7.20-7.8.0.pl b/docs/upgrades/upgrade_7.7.20-7.8.0.pl index 99ad07566..4f11f654c 100644 --- a/docs/upgrades/upgrade_7.7.20-7.8.0.pl +++ b/docs/upgrades/upgrade_7.7.20-7.8.0.pl @@ -119,7 +119,7 @@ sub fixEmptyCalendarIcalFeeds { print "DONE!\n" unless $quiet; } - +[ #---------------------------------------------------------------------------- # Add tables for the EMS Submission feature sub addEMSSubmission { @@ -147,7 +147,7 @@ CREATE TABLE EMSSubmission ( price FLOAT, seatsAvailable INT, startDate DATETIME, - duration FLOAT + duration FLOAT, eventNumber INT, location CHAR(100), relatedBadgeGroups MEDIUMTEXT, @@ -159,20 +159,20 @@ CREATE TABLE EMSSubmission ( ESQL $session->db->write( q{ ALTER TABLE EventManagementSystem - ADD COLLUMN eventSubmissionTemplateId CHAR(22) BINARY; }); + ADD COLUMN eventSubmissionTemplateId CHAR(22) BINARY; }); $session->db->write( q{ ALTER TABLE EventManagementSystem - ADD COLLUMN viewEventSubmissionQueueTemplateId CHAR(22) BINARY; }); + ADD COLUMN viewEventSubmissionQueueTemplateId CHAR(22) BINARY; }); $session->db->write( q{ ALTER TABLE EventManagementSystem - ADD COLLUMN editEventSubmissionTemplateId CHAR(22) BINARY; }); + ADD COLUMN editEventSubmissionTemplateId CHAR(22) BINARY; }); $session->db->write( q{ ALTER TABLE EventManagementSystem - ADD COLLUMN eventSubmissionGroups MEDIUMTEXT; }); + ADD COLUMN eventSubmissionGroups MEDIUMTEXT; }); print "DONE!\n" unless $quiet; } - +] #---------------------------------------------------------------------------- # Add the column for featured wiki pages sub addFeaturedPageWiki { diff --git a/lib/WebGUI/Asset/EMSSubmission.pm b/lib/WebGUI/Asset/EMSSubmission.pm index d9e6c9aed..d9fddd05b 100644 --- a/lib/WebGUI/Asset/EMSSubmission.pm +++ b/lib/WebGUI/Asset/EMSSubmission.pm @@ -14,15 +14,11 @@ package WebGUI::Asset::EMSSubmission; =cut +use Class::C3; use strict; use Tie::IxHash; -use base 'WebGUI::Asset'; +use base qw(WebGUI::AssetAspect::Comments WebGUI::Asset); use WebGUI::Utility; -# TODO add AssetAspect::Comment; - -# To get an installer for your wobject, add the Installable AssetAspect -# See WebGUI::AssetAspect::Installable and sbin/installClass.pl for more -# details =head1 NAME @@ -54,7 +50,7 @@ handles revisions to NewAsset Assets. #sub addRevision { # my $self = shift; -# my $newSelf = $self->SUPER::addRevision(@_); +# my $newSelf = $self->next::method(@_); # return $newSelf; #} @@ -102,7 +98,7 @@ sub definition { startDate => { noFormPost => 1, fieldType => "hidden", - defaultValue => $date->toDatabase, + defaultValue => '', label => $EMS_i18n->get("add/edit event start date"), hoverHelp => $EMS_i18n->get("add/edit event start date help"), autoGenerate => 0, @@ -122,14 +118,14 @@ sub definition { label => $EMS_i18n->get("location"), hoverHelp => $EMS_i18n->get("location help"), }, - relateBadgeGroup => { + relatedBadgeGroup => { tab => "properties", fieldType => "checkList", customDrawMethod=> 'drawRelatedBadgeGroupsField', label => $EMS_i18n->get("related badge groups"), hoverHelp => $EMS_i18n->get("related badge groups ticket help"), }, - relateRibbons => { + relatedRibbons => { tab => "properties", fieldType => "checkList", customDrawMethod=> 'drawRelatedRibbonsField', @@ -157,7 +153,7 @@ sub definition { className => 'WebGUI::Asset::EMSSubmission', properties => \%properties, }; - return $class->SUPER::definition( $session, $definition ); + return $class->next::method( $session, $definition ); } ## end sub definition #------------------------------------------------------------------- @@ -172,7 +168,7 @@ whenever a copy action is executed #sub duplicate { # my $self = shift; -# my $newAsset = $self->SUPER::duplicate(@_); +# my $newAsset = $self->next::method(@_); # return $newAsset; #} @@ -186,7 +182,7 @@ Making private. See WebGUI::Asset::indexContent() for additonal details. sub indexContent { my $self = shift; - my $indexer = $self->SUPER::indexContent; + my $indexer = $self->next::method; $indexer->setIsPublic(0); } @@ -200,7 +196,7 @@ See WebGUI::Asset::prepareView() for details. sub prepareView { my $self = shift; - $self->SUPER::prepareView(); + $self->next::method(); my $template = WebGUI::Asset::Template->new( $self->session, $self->get("templateId") ); $template->prepare($self->getMetaDataAsTemplateVariables); $self->{_viewTemplate} = $template; @@ -218,7 +214,7 @@ when /yourAssetUrl?func=editSave is requested/posted. sub processPropertiesFromFormPost { my $self = shift; - $self->SUPER::processPropertiesFromFormPost; + $self->next::method; } #------------------------------------------------------------------- @@ -235,7 +231,7 @@ asset instances, you will need to purge them here. #sub purge { # my $self = shift; -# return $self->SUPER::purge; +# return $self->next::method; #} #------------------------------------------------------------------- @@ -246,10 +242,10 @@ This method is called when data is purged by the system. =cut -sub purgeRevision { - my $self = shift; - return $self->SUPER::purgeRevision; -} +#sub purgeRevision { +# my $self = shift; +# return $self->next::method; +#} #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/EMSSubmissionForm.pm b/lib/WebGUI/Asset/EMSSubmissionForm.pm index 96bfc86bc..a4d9813a0 100644 --- a/lib/WebGUI/Asset/EMSSubmissionForm.pm +++ b/lib/WebGUI/Asset/EMSSubmissionForm.pm @@ -46,6 +46,28 @@ These methods are available from this class: #------------------------------------------------------------------- +=head2 addSubmission + +Creates an EMSSubmission object based on the params + +=cut + +sub addSubmission { + my $self = shift; + my $parent = $self->getParent; + my $session = $self->session; + my $params = shift || {}; + $self->validateSubmission($params); + $parent->addChild({ + className => 'WebGUI::Asset::EMSSubmission', + status => 'pending', + title => $params->{title}, + # TODO add all the fields... + }); +} + +#------------------------------------------------------------------- + =head2 addRevision This method exists for demonstration purposes only. The superclass @@ -235,6 +257,20 @@ sub view { #------------------------------------------------------------------- +=head2 validateSubmission ( ) + +=cut + +sub validateSubmission { + my $self = shift; + my $session = $self->session; +# compare fields passed with field definition +# return true if ok, false if not ok + return 0; +} + +#------------------------------------------------------------------- + =head2 www_edit ( ) Web facing method which is the default edit page. Unless the method needs diff --git a/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm b/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm index d7f035dca..1d7b08202 100644 --- a/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm +++ b/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm @@ -70,7 +70,7 @@ sub execute { my $self = shift; my $session = $self->session; my $root = WebGUI::Asset->getRoot($session); - +return $self->FAILED; my $sth = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::HelpDesk'"); while (my ($assetId) = $sth->array) { diff --git a/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm b/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm index 464492cb5..9682609d6 100644 --- a/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm +++ b/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm @@ -70,7 +70,7 @@ sub execute { my $self = shift; my $session = $self->session; my $root = WebGUI::Asset->getRoot($session); - +return $self->FAILED; my $sth = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::HelpDesk'"); while (my ($assetId) = $sth->array) { diff --git a/t/Asset/EMSSubmissionForm.t b/t/Asset/EMSSubmissionForm.t index 7024b6cc8..ee8ccad28 100644 --- a/t/Asset/EMSSubmissionForm.t +++ b/t/Asset/EMSSubmissionForm.t @@ -15,11 +15,12 @@ use FindBin; use strict; -use lib "$FindBin::Bin/lib"; +use lib "$FindBin::Bin/../lib"; use Test::More; use WebGUI::Group; use WebGUI::User; use WebGUI::Test; # Must use this before any other WebGUI modules +use WebGUI::Test::Activity; use WebGUI::Session; use WebGUI::Asset::Wobject::EventManagementSystem; use WebGUI::Asset::Sku::EMSBadge; @@ -34,7 +35,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -plan tests => 1; # Increment this number for each test you create +plan tests => 200; # Increment this number for each test you create my $submitGroupA = WebGUI::Group->new($session,'new'); my $submitGroupB = WebGUI::Group->new($session,'new'); @@ -65,14 +66,18 @@ sub logout { $session->user({userId => 1}); } #---------------------------------------------------------------------------- # put your tests here -use_ok WebGUI::Asset::EMSSubmissionForm; -use_ok WebGUI::Asset::EMSSubmission; +use_ok 'WebGUI::Asset::EMSSubmissionForm'; +use_ok 'WebGUI::Asset::EMSSubmission'; loginAdmin; # Create a version tag to work in my $versionTag = WebGUI::VersionTag->getWorking($session); $versionTag->set({name=>"EventManagementSystem Test"}); +WebGUI::Test->tagsToRollback($versionTag); + +# Do our work in the import node +my $node = WebGUI::Asset->getImportNode($session); # Add an EMS asset my $ems = $node->addChild({ @@ -84,44 +89,107 @@ my $ems = $node->addChild({ registrationStaffGroupId => $registrars->getId, groupIdView => $attendees->getId }); +# I scooped this out ot WG::Asset::Wobject::EventManagementSystem +# its not pretty, but there is no other way to add a meta field + $ems->setCollateral("EMSEventMetaField", "fieldId",{ + fieldId=> 'new', + label => 'metaField1', + dataType => 'Url', + visible => 1, + required => 1, + possibleValues => '', + defaultValues => '', + },1,1); + + $ems->setCollateral("EMSEventMetaField", "fieldId",{ + fieldId=> 'new', + label => 'metaField2', + dataType => 'Date', + visible => 1, + required => 0, + possibleValues => '', + defaultValues => '', + },1,1); + $versionTag->commit; -WebGUI::Test->tagsToRollback($versionTag); $versionTag = WebGUI::VersionTag->getWorking($session); +WebGUI::Test->tagsToRollback($versionTag); loginRgstr; my $frmA = $ems->addChild({ className => 'WebGUI::Asset::EMSSubmissionForm', + title => 'test A -- long', canSubmitGroup => $submitGroupA->getId, formDescription => q{ TODO = 1 }, }); -isa( $frmA, 'WebGUI::Asset::EMSSubmissionForm' ); +isa_ok( $frmA, 'WebGUI::Asset::EMSSubmissionForm' ); +ok( $frmA->validateSubmission({ + TODO => 1 + }), 'a valid submission' ); +ok( !$frmA->validateSubmission({ + TODO => 1 + }), 'not a valid submission' ); +# TODO: test more field validations +# TODO use meta field in this form my $frmB = $ems->addChild({ className => 'WebGUI::Asset::EMSSubmissionForm', + title => 'test B -- short', canSubmitGroup => $submitGroupB->getId, formDescription => q{ TODO = 1 }, }); +# TODO: test meta field validation + +loginUserA; + +# this one should work +my $sub1 = $frmA->addSubmission({ + title => 'my favorite thing to talk about', +}); + +#this one should fail +my $sub2 = $frmB->addSubmission({ + title => 'why i like to be important', +}); + +loginUserB; + +# should work +my $sub3 = $frmB->addSubmission({ + title => 'five minutes of me', +}); + +loginUserC; + +# should work +my $sub4 = $frmB->addSubmission({ + title => 'why humility is underrated', +}); + +# should work +my $sub5 = $frmA->addSubmission({ + title => 'what you should know about everybody', +}); + +$sub1->addComment({ 'this is a test comment' }); my $TODO = q{ -create submission(s) -comment on submission(s) modify submission(s) change submission status run submission approval activity run submission cleanup activity -} +}; $versionTag->commit; -WebGUI::Test->tagsToRollback($versionTag); #---------------------------------------------------------------------------- # Cleanup END { - +# everything should be entered into the WG::Test cleanup lists... } #vim:ft=perl