nearly 50% functionality
This commit is contained in:
parent
1ec6646671
commit
dbf1e05635
5 changed files with 301 additions and 76 deletions
|
|
@ -196,6 +196,11 @@ sub definition {
|
||||||
fieldType => "hidden",
|
fieldType => "hidden",
|
||||||
defaultValue => '{}',
|
defaultValue => '{}',
|
||||||
},
|
},
|
||||||
|
ticketId => {
|
||||||
|
noFormPost => 1,
|
||||||
|
fieldType => "hidden",
|
||||||
|
defaultValue => '',
|
||||||
|
},
|
||||||
);
|
);
|
||||||
push @{$definition}, {
|
push @{$definition}, {
|
||||||
assetName => $i18n->get('assetName'),
|
assetName => $i18n->get('assetName'),
|
||||||
|
|
|
||||||
|
|
@ -64,15 +64,14 @@ sub addSubmission {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
my $params = shift || {};
|
my $params = shift || {};
|
||||||
return undef if $self->canSubmit;
|
return { isValid => 0, errors => [ 'no permissions' ] } if ! $self->canSubmit;
|
||||||
$params = $self->validateSubmission($params);
|
my $newParams = $self->validateSubmission($params);
|
||||||
# TODO this whould return something so errors can be reported
|
return $newParams if ! $newParams->{isValid} ;
|
||||||
return undef if ! $self->{isValid} ;
|
$newParams->{className} = 'WebGUI::Asset::EMSSubmission';
|
||||||
$params->{className} = 'WebGUI::Asset::EMSSubmission';
|
$newParams->{status} = 'pending';
|
||||||
$params->{status} = 'pending';
|
$newParams->{submissionId} = $self->get('nextSubmissionId');
|
||||||
$params->{submissionId} = $self->get('nextSubmissionId');
|
$self->update({nextSubmissionId => $newParams->{submissionId}+1 });
|
||||||
$self->update({nextSubmissionId => $params->{submissionId}+1 });
|
$self->addChild($newParams);
|
||||||
$self->addChild($params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -322,11 +321,11 @@ sub validateSubmission {
|
||||||
my $submission = shift;
|
my $submission = shift;
|
||||||
my $adminOverride = JSON->new->decode( $submission->{adminOverride} || ' { } ' );
|
my $adminOverride = JSON->new->decode( $submission->{adminOverride} || ' { } ' );
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
my $target = { isValid => 1 };
|
my $target = { isValid => 1, adminOverride => $adminOverride };
|
||||||
my $form = $self->getFormDescription;
|
my $form = $self->getFormDescription;
|
||||||
for my $field (keys %{$form}) {
|
for my $field (keys %{$form}) {
|
||||||
my $value = $submission->{$field} || $form->{field}{default} || '';
|
next if not defined $form->{$field}{type};
|
||||||
next if defined $adminOverride->{$field} && ( $value == $adminOverride->{$field} || $value eq $adminOverride->{$field} );
|
my $value = $submission->{$field} || $form->{$field}{default} || '';
|
||||||
$self->validateSubmissionField( $value, $form->{$field}, $field, $target );
|
$self->validateSubmissionField( $value, $form->{$field}, $field, $target );
|
||||||
}
|
}
|
||||||
return $target;
|
return $target;
|
||||||
|
|
@ -358,6 +357,24 @@ sub validateSubmissionField {
|
||||||
my $fieldDef = shift;
|
my $fieldDef = shift;
|
||||||
my $name = shift;
|
my $name = shift;
|
||||||
my $target = shift;
|
my $target = shift;
|
||||||
|
if( exists $target->{adminOverride}{$name} ) {
|
||||||
|
if( ( $target->{adminOverride}{$name}{type} =~ /(float|integer)/i
|
||||||
|
&& $target->{adminOverride}{$name}{value} == $value )
|
||||||
|
|| $target->{adminOverride}{$name}{value} eq $value
|
||||||
|
) {
|
||||||
|
$target->{$name} = $value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( $value eq '' ) {
|
||||||
|
$target->{$name} = $value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if( $fieldDef->{required} && $value eq '' ) {
|
||||||
|
$target->{isvalid} = 0;
|
||||||
|
push @{$target->{errors}}, $name . ' is a required field';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
my $type = $fieldDef->{type};
|
my $type = $fieldDef->{type};
|
||||||
if( $type eq 'url' ) {
|
if( $type eq 'url' ) {
|
||||||
if( $value !~ /^http:/ ) { # TODO get a better test for Earls
|
if( $value !~ /^http:/ ) { # TODO get a better test for Earls
|
||||||
|
|
@ -365,6 +382,10 @@ sub validateSubmissionField {
|
||||||
push @{$target->{errors}}, $name . ' is not a valid Url';
|
push @{$target->{errors}}, $name . ' is not a valid Url';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
} elsif( $type eq 'integer' ) {
|
||||||
|
$value = int( $value );
|
||||||
|
} elsif( $type eq 'float' ) {
|
||||||
|
; # there is no test here...
|
||||||
} elsif( $type eq 'text' ) {
|
} elsif( $type eq 'text' ) {
|
||||||
; # there is no test here...
|
; # there is no test here...
|
||||||
} elsif( $type eq 'textarea' ) {
|
} elsif( $type eq 'textarea' ) {
|
||||||
|
|
@ -372,7 +393,7 @@ sub validateSubmissionField {
|
||||||
} elsif( $type eq 'selectList' ) {
|
} elsif( $type eq 'selectList' ) {
|
||||||
if( ! grep { $_ eq $value } @{$fieldDef->{options}} ) {
|
if( ! grep { $_ eq $value } @{$fieldDef->{options}} ) {
|
||||||
$target->{isValid} = 0;
|
$target->{isValid} = 0;
|
||||||
push @{$target->{errors}}, $name . ' is not a valid Url';
|
push @{$target->{errors}}, $name . ' is not a valid Selection';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -93,11 +93,7 @@ sub addSubmissionForm {
|
||||||
$params->{className} = 'WebGUI::Asset::EMSSubmissionForm';
|
$params->{className} = 'WebGUI::Asset::EMSSubmissionForm';
|
||||||
$params->{canSubmitGroupId} ||= 2;
|
$params->{canSubmitGroupId} ||= 2;
|
||||||
$self->addGroupToSubmitList($params->{canSubmitGroupId});
|
$self->addGroupToSubmitList($params->{canSubmitGroupId});
|
||||||
# TODO re-edit the Badge view template and save it, see that it gets added after resets
|
return $self->addChild($params);
|
||||||
# TODO see how hard it would be to dump the whole template class to the file system
|
|
||||||
#-- ultimate goal is to figure out what is failing in the test battery...
|
|
||||||
# also add tests for Form_Div
|
|
||||||
$self->addChild($params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -189,32 +185,32 @@ sub definition {
|
||||||
},
|
},
|
||||||
eventSubmissionTemplateId => {
|
eventSubmissionTemplateId => {
|
||||||
fieldType => 'template',
|
fieldType => 'template',
|
||||||
defaultValue => 'eventSubmissionTmplt01',
|
defaultValue => '8tqyQx-LwYUHIWOlKPjJrA',
|
||||||
tab => 'display',
|
tab => 'display',
|
||||||
label => $i18n->get('print ticket template'),
|
label => $i18n->get('event submission template'),
|
||||||
hoverHelp => $i18n->get('print ticket template help'),
|
hoverHelp => $i18n->get('event submission template help'),
|
||||||
namespace => 'EMS/SubmissionForm',
|
namespace => 'EMS/Submission',
|
||||||
},
|
},
|
||||||
viewEventSubmissionQueueTemplateId => {
|
viewEventSubmissionQueueTemplateId => {
|
||||||
fieldType => 'template',
|
fieldType => 'template',
|
||||||
defaultValue => 'eventQueueTmplate00001',
|
defaultValue => 'ktSvKU8riGimhcsxXwqvPQ',
|
||||||
tab => 'display',
|
tab => 'display',
|
||||||
label => $i18n->get('print ticket template'),
|
label => $i18n->get('event submission queue template'),
|
||||||
hoverHelp => $i18n->get('print ticket template help'),
|
hoverHelp => $i18n->get('event submission queue template help'),
|
||||||
namespace => 'EMS/SubmissionQueue',
|
namespace => 'EMS/SubmissionQueue',
|
||||||
},
|
},
|
||||||
editEventSubmissionTemplateId => {
|
eventSubmissionFormTemplateId => {
|
||||||
fieldType => 'template',
|
fieldType => 'template',
|
||||||
defaultValue => 'editEventSubmissionT01',
|
defaultValue => 'ylBSKblMdKpcDSIK2t_Ang',
|
||||||
tab => 'display',
|
tab => 'display',
|
||||||
label => $i18n->get('print ticket template'),
|
label => $i18n->get('event submission form template'),
|
||||||
hoverHelp => $i18n->get('print ticket template help'),
|
hoverHelp => $i18n->get('event submission form template help'),
|
||||||
namespace => 'EMS/EditSubmission',
|
namespace => 'EMS/SubmissionForm',
|
||||||
},
|
},
|
||||||
badgeInstructions => {
|
badgeInstructions => {
|
||||||
fieldType => 'HTMLArea',
|
fieldType => 'HTMLArea',
|
||||||
defaultValue => $i18n->get('default badge instructions'),
|
defaultValue => $i18n->get('default badge instructions'),
|
||||||
tab => 'properties',
|
tab => 'properties',
|
||||||
label => $i18n->get('badge instructions'),
|
label => $i18n->get('badge instructions'),
|
||||||
hoverHelp => $i18n->get('badge instructions help'),
|
hoverHelp => $i18n->get('badge instructions help'),
|
||||||
},
|
},
|
||||||
|
|
@ -498,11 +494,11 @@ returns true if the current user has submission forms in this EMS
|
||||||
sub hasSubmissions {
|
sub hasSubmissions {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return 0 if ! $self->canSubmit;
|
return 0 if ! $self->canSubmit;
|
||||||
my @res = $self->getLineage(['descendants'],{ limit => 1,
|
my $res = $self->getLineage(['descendants'],{ limit => 1,
|
||||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||||
whereClause => q{createdBy='} . $self->session->user->userId . q/'/,
|
whereClause => q{createdBy='} . $self->session->user->userId . q/'/,
|
||||||
} );
|
} );
|
||||||
return scalar(@res);
|
return scalar(@$res);
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -640,6 +636,19 @@ sub www_addRibbonToBadge {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_addSubmissionForm ()
|
||||||
|
|
||||||
|
this will call the www_editSubmissionForm function with assetId == 'new'
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_addSubmissionForm {
|
||||||
|
my $self = shift;
|
||||||
|
$self->www_editSubmiossionForm( { assetId => 'new' } );
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_addTicketsToBadge ()
|
=head2 www_addTicketsToBadge ()
|
||||||
|
|
||||||
Adds selected tickets to a badge. Expects two form parameters, assetId (multiples fine) and badgeId, where assetId represents the ticket and badgeId represents the badge.
|
Adds selected tickets to a badge. Expects two form parameters, assetId (multiples fine) and badgeId, where assetId represents the ticket and badgeId represents the badge.
|
||||||
|
|
@ -816,6 +825,54 @@ sub www_editBadgeGroupSave {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_editSubmissionForm
|
||||||
|
|
||||||
|
is assetId is 'new' edit a blank form, else edit a form with stuff filled in...
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_editSubmissionForm {
|
||||||
|
my $self = shift;
|
||||||
|
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||||
|
# TODO add code to send a list of links if we are not creating a new form and trhere exist more
|
||||||
|
# than one form
|
||||||
|
# -- getlineage for forms in this EMS
|
||||||
|
# if there is one form, then edit that form
|
||||||
|
# if there are more than one form then create a simple page with a link to each form that can be editted
|
||||||
|
|
||||||
|
# this stuff below needs to be converted to use a template...
|
||||||
|
my ($form, $db) = $self->session->quick(qw(form db));
|
||||||
|
my $f = WebGUI::HTMLForm->new($self->session, action=>$self->getUrl);
|
||||||
|
$f->hidden(name=>'func', value=>'editSubmissionFormSave');
|
||||||
|
my $i18n = WebGUI::International->new($self->session, "Asset_EventManagementSystem");
|
||||||
|
$f->hidden(name=>'assetId', value=>$form => 'new' );
|
||||||
|
$f->text(
|
||||||
|
name => 'name',
|
||||||
|
value => '',
|
||||||
|
label => 'junk',
|
||||||
|
hoverHelp => 'help with junk',
|
||||||
|
);
|
||||||
|
$f->submit;
|
||||||
|
return $self->processStyle('<h1>the title </h1>'.$f->print);
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_editSubmissionFormSave
|
||||||
|
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_editSubmissionFormSave {
|
||||||
|
my $self = shift;
|
||||||
|
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||||
|
my $form = $self->session->form;
|
||||||
|
# TOOD call addSubmissionForm or update the submission form...
|
||||||
|
return $self->www_view; # TODO where to go after this???
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_editEventMetaField ( )
|
=head2 www_editEventMetaField ( )
|
||||||
|
|
||||||
Displays the edit form for event meta fields.
|
Displays the edit form for event meta fields.
|
||||||
|
|
@ -2085,6 +2142,22 @@ sub www_moveEventMetaFieldUp {
|
||||||
return $self->www_manageEventMetaFields;
|
return $self->www_manageEventMetaFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#---------------------------------------------
|
||||||
|
=head2 www_newSubmission
|
||||||
|
|
||||||
|
if only one form is available to this user:
|
||||||
|
call the viewSubmission with class and assetID = 'new'
|
||||||
|
else create a list of link that will distinguish the form the userdesires to use.
|
||||||
|
the links should refer to this function and include a formId parameter
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_newSubmission {
|
||||||
|
|
||||||
|
# call viewSubmission or create a list of links
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_printBadge ( )
|
=head2 www_printBadge ( )
|
||||||
|
|
@ -2236,6 +2309,27 @@ sub www_viewSchedule {
|
||||||
sub www_viewSubmission {
|
sub www_viewSubmission {
|
||||||
|
|
||||||
# fill the view submission template
|
# fill the view submission template
|
||||||
|
my $self = shift;
|
||||||
|
return $self->session->privilege->insufficient() unless $self->canView;
|
||||||
|
my $db = $self->session->db;
|
||||||
|
my $rowsPerPage = 25;
|
||||||
|
my $locationsPerPage = $self->get('scheduleColumnsPerPage');
|
||||||
|
|
||||||
|
my @columnNames = map { "'col" . $_ . "'" } ( 1..$locationsPerPage );
|
||||||
|
my $fieldList = join ',', @columnNames;
|
||||||
|
my $dataColumns = join ",\n", map {
|
||||||
|
'{key:' . $_ . ',sortable:false,label:"",formatter:formatViewScheduleItem}'
|
||||||
|
} @columnNames;
|
||||||
|
|
||||||
|
return $self->processStyle(
|
||||||
|
$self->processTemplate({
|
||||||
|
backUrl => $self->getUrl,
|
||||||
|
rowsPerPage => $rowsPerPage,
|
||||||
|
dataColumns => $dataColumns,
|
||||||
|
fieldList => $fieldList,
|
||||||
|
dataSourceUrl => $self->getUrl('func=getScheduleDataJSON'),
|
||||||
|
},$self->get('scheduleTemplateId')));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2248,6 +2342,31 @@ sub www_viewSubmissionQueue {
|
||||||
|
|
||||||
# fill the view submission queue template
|
# fill the view submission queue template
|
||||||
|
|
||||||
|
|
||||||
|
# fill the view submission template
|
||||||
|
my $self = shift;
|
||||||
|
return $self->session->privilege->insufficient() unless $self->canView;
|
||||||
|
my $db = $self->session->db;
|
||||||
|
my $rowsPerPage = 25;
|
||||||
|
my $locationsPerPage = $self->get('scheduleColumnsPerPage');
|
||||||
|
|
||||||
|
my @columnNames = map { "'col" . $_ . "'" } ( 1..$locationsPerPage );
|
||||||
|
my $fieldList = join ',', @columnNames;
|
||||||
|
my $dataColumns = join ",\n", map {
|
||||||
|
'{key:' . $_ . ',sortable:false,label:"",formatter:formatViewScheduleItem}'
|
||||||
|
} @columnNames;
|
||||||
|
|
||||||
|
return $self->processStyle(
|
||||||
|
$self->processTemplate({
|
||||||
|
backUrl => $self->getUrl,
|
||||||
|
rowsPerPage => $rowsPerPage,
|
||||||
|
dataColumns => $dataColumns,
|
||||||
|
fieldList => $fieldList,
|
||||||
|
dataSourceUrl => $self->getUrl('func=getScheduleDataJSON'),
|
||||||
|
},$self->get('scheduleTemplateId')));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1902,6 +1902,42 @@ normal templates.|,
|
||||||
context => q|Label for link to view submissions owned by current user.|,
|
context => q|Label for link to view submissions owned by current user.|,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'event submission template' => {
|
||||||
|
message => q|Event Submission Template|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|Label for the template that is used to submit events.|
|
||||||
|
},
|
||||||
|
|
||||||
|
'event submission template help' => {
|
||||||
|
message => q|This template is used for event submission, most of its contents is composed by the submission form asset based on the description given by the admin who created it.|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|Help text for the event submission form template.|
|
||||||
|
},
|
||||||
|
|
||||||
|
'event submission queue template' => {
|
||||||
|
message => q|Event Submission Queue Template|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|Label for the Event Submission Queue template.|
|
||||||
|
},
|
||||||
|
|
||||||
|
'event submission queue template help' => {
|
||||||
|
message => q|This is the template used to display the Event Submission Queue, used for both submitters and admin.|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|Help text for the Event SUbmission Queue Template.|
|
||||||
|
},
|
||||||
|
|
||||||
|
'event submission form template' => {
|
||||||
|
message => q|Event Submission Form Template|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|Label for the event submission form template.|
|
||||||
|
},
|
||||||
|
|
||||||
|
'event submission form template help' => {
|
||||||
|
message => q|This template is used to describe the event submission form which will be used by submitters to entger their information. This template consists of a few standard fields and a list of optional fields which are turned on by selecting them from the list.|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|Help text for the event submission form template.|
|
||||||
|
},
|
||||||
|
|
||||||
# 'TODO' => {
|
# 'TODO' => {
|
||||||
# message => q|TODO|,
|
# message => q|TODO|,
|
||||||
# lastUpdated => 1147050475,
|
# lastUpdated => 1147050475,
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ use lib "$FindBin::Bin/../lib";
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||||
use WebGUI::Group;
|
use WebGUI::Group;
|
||||||
use WebGUI::User;
|
use WebGUI::User;
|
||||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
|
||||||
use WebGUI::Test::Activity;
|
use WebGUI::Test::Activity;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::Asset::Wobject::EventManagementSystem;
|
use WebGUI::Asset::Wobject::EventManagementSystem;
|
||||||
|
|
@ -33,21 +33,22 @@ use WebGUI::Asset::Sku::EMSToken;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Init
|
# Init
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
my @cleanup = ();
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
plan tests => 50; # Increment this number for each test you create
|
plan tests => 50; # Increment this number for each test you create
|
||||||
|
|
||||||
my $submitGroupA = WebGUI::Group->new($session,'new',{groupName=>'groupA'});
|
(my $submitGroupA = WebGUI::Group->new($session,'new'))->name('groupA');
|
||||||
my $submitGroupB = WebGUI::Group->new($session,'new',{groupName=>'groupB'});
|
(my $submitGroupB = WebGUI::Group->new($session,'new'))->name('groupB');
|
||||||
my $registrars = WebGUI::Group->new($session, 'new',{groupName=>'registrars'});
|
(my $registrars = WebGUI::Group->new($session, 'new'))->name('registrars');
|
||||||
my $attendees = WebGUI::Group->new($session, 'new',{groupName=>'attendees'});
|
(my $attendees = WebGUI::Group->new($session, 'new'))->name('attendees');
|
||||||
|
|
||||||
my $registrar = WebGUI::User->create($session,{username=>'registrar'});
|
(my $registrar = WebGUI::User->new($session,'new'))->update({username=>'registrar'});
|
||||||
my $userA = WebGUI::User->create($session,{username=>'userA'});
|
(my $userA = WebGUI::User->new($session,'new'))->update({username=>'userA'});
|
||||||
my $userB = WebGUI::User->create($session,{username=>'userB'});
|
(my $userB = WebGUI::User->new($session,'new'))->update({username=>'userB'});
|
||||||
my $userC = WebGUI::User->create($session,{username=>'userC'});
|
(my $userC = WebGUI::User->new($session,'new'))->update({username=>'userC'});
|
||||||
|
|
||||||
$registrars->addUsers([$registrar->getId]);
|
$registrars->addUsers([$registrar->getId]);
|
||||||
$submitGroupA->addUsers([$userA->userId,$userC->userId]);
|
$submitGroupA->addUsers([$userA->userId,$userC->userId]);
|
||||||
|
|
@ -81,6 +82,8 @@ WebGUI::Test->tagsToRollback($versionTag);
|
||||||
# Do our work in the import node
|
# Do our work in the import node
|
||||||
my $node = WebGUI::Asset->getImportNode($session);
|
my $node = WebGUI::Asset->getImportNode($session);
|
||||||
|
|
||||||
|
loginRgstr ;
|
||||||
|
|
||||||
# Add an EMS asset
|
# Add an EMS asset
|
||||||
my $ems = $node->addChild({
|
my $ems = $node->addChild({
|
||||||
className =>'WebGUI::Asset::Wobject::EventManagementSystem',
|
className =>'WebGUI::Asset::Wobject::EventManagementSystem',
|
||||||
|
|
@ -159,26 +162,32 @@ my $submission = {
|
||||||
description => 'the description',
|
description => 'the description',
|
||||||
startDate => '1255150800',
|
startDate => '1255150800',
|
||||||
};
|
};
|
||||||
ok( $frmA->validateSubmission($submission)->{isValid}, 'a valid submission' );
|
my $result = $frmA->validateSubmission($submission);
|
||||||
|
ok( $result->{isValid}, 'a valid submission' );
|
||||||
|
print join( "\n", @{$result->{errors}} ),"\n" if defined $result->{errors};
|
||||||
$submission = {
|
$submission = {
|
||||||
title => 'titlea',
|
title => 'titlea',
|
||||||
description => 'the description',
|
description => 'the description',
|
||||||
startDate => '1205150800',
|
startDate => '1205150800',
|
||||||
};
|
};
|
||||||
ok( !$frmA->validateSubmission($submission)->{isValid}, 'not a valid submission: invalid value in startDate' );
|
$result = $frmA->validateSubmission($submission);
|
||||||
|
ok( !$result->{isValid}, 'not a valid submission: invalid value in startDate' );
|
||||||
|
print join( "\n", @{$result->{errors}} ),"\n" if defined $result->{errors};
|
||||||
$submission = {
|
$submission = {
|
||||||
title => 'titlea',
|
title => 'titlea',
|
||||||
duration => 3.0,
|
duration => 3.0,
|
||||||
description => 'the description',
|
description => 'the description',
|
||||||
startDate => '1255150800',
|
startDate => '1255150800',
|
||||||
};
|
};
|
||||||
ok( $frmA->validateSubmission($submission)->{isValid}, 'valid submission: readonly field ignored' );
|
$result = $frmA->validateSubmission($submission);
|
||||||
|
ok( $result->{isValid} && ! defined $result->{duration}, 'valid submission: readonly field ignored' );
|
||||||
|
print join( "\n", @{$result->{errors}} ),"\n" if defined $result->{errors};
|
||||||
|
|
||||||
|
|
||||||
my $formBdesc = {
|
my $formBdesc = {
|
||||||
title => { type => 'text' },
|
title => { type => 'text' },
|
||||||
description => { type => 'textarea' },
|
description => { type => 'textarea' },
|
||||||
duration => { type => 'integer', default => 0.5, max => 0.5 },
|
duration => { type => 'float', default => 0.5, max => 0.5 },
|
||||||
startDate => { default => '1255150800' },
|
startDate => { default => '1255150800' },
|
||||||
mfRequiredUrl => { type => 'url' },
|
mfRequiredUrl => { type => 'url' },
|
||||||
};
|
};
|
||||||
|
|
@ -186,7 +195,7 @@ my $frmB = $ems->addSubmissionForm({
|
||||||
className => 'WebGUI::Asset::EMSSubmissionForm',
|
className => 'WebGUI::Asset::EMSSubmissionForm',
|
||||||
title => 'test B -- short',
|
title => 'test B -- short',
|
||||||
daysBeforeCleanup => 0,
|
daysBeforeCleanup => 0,
|
||||||
canSubmitGroup => $submitGroupB->getId,
|
canSubmitGroupId => $submitGroupB->getId,
|
||||||
formDescription => to_json($formBdesc),
|
formDescription => to_json($formBdesc),
|
||||||
});
|
});
|
||||||
$submission = {
|
$submission = {
|
||||||
|
|
@ -194,21 +203,27 @@ $submission = {
|
||||||
description => 'description',
|
description => 'description',
|
||||||
mfRequiredUrl => 'http://google.com/',
|
mfRequiredUrl => 'http://google.com/',
|
||||||
};
|
};
|
||||||
ok( $frmB->validateSubmission($submission)->{isValid}, 'valid submission: test valid metafield value' );
|
$result = $frmB->validateSubmission($submission);
|
||||||
|
ok( $result->{isValid}, 'valid submission: test valid metafield value' );
|
||||||
|
print join( "\n", @{$result->{errors}} ),"\n" if defined $result->{errors};
|
||||||
$submission = {
|
$submission = {
|
||||||
title => 'title',
|
title => 'title',
|
||||||
description => 'description',
|
description => 'description',
|
||||||
mfRequiredUrl => 'joe@sams.org',
|
mfRequiredUrl => 'joe@sams.org',
|
||||||
};
|
};
|
||||||
ok( !$frmB->validateSubmission($submission)->{isValid}, 'invalid submission: test invalid metafield value' );
|
$result = $frmB->validateSubmission($submission);
|
||||||
|
ok( !$result->{isValid}, 'invalid submission: test invalid metafield value' );
|
||||||
|
print join( "\n", @{$result->{errors}} ),"\n" if defined $result->{errors};
|
||||||
$submission = {
|
$submission = {
|
||||||
title => 'titlea',
|
title => 'titlea',
|
||||||
duration => 0.6,
|
duration => 0.6,
|
||||||
description => 'the description',
|
description => 'the description',
|
||||||
adminOverride => to_json( { duration => 0.6 } ),
|
mfRequiredUrl => 'http://google.com/',
|
||||||
|
adminOverride => to_json( { duration => { value => 0.6, type => 'float' } } ),
|
||||||
};
|
};
|
||||||
ok( $frmB->validateSubmission($submission)->{isValid}, 'valid submission: field value override by admin' );
|
$result = $frmB->validateSubmission($submission);
|
||||||
|
ok( $result->{isValid}, 'valid submission: field value override by admin' );
|
||||||
|
print join( "\n", @{$result->{errors}} ),"\n" if defined $result->{errors};
|
||||||
logout;
|
logout;
|
||||||
|
|
||||||
ok( !$ems->canSubmit, 'Visitor cannot submit to this ems' );
|
ok( !$ems->canSubmit, 'Visitor cannot submit to this ems' );
|
||||||
|
|
@ -219,19 +234,25 @@ loginUserA;
|
||||||
ok( $ems->canSubmit, 'UserA can submit to this ems' );
|
ok( $ems->canSubmit, 'UserA can submit to this ems' );
|
||||||
ok( $frmA->canSubmit, 'UserA can submit to formA' );
|
ok( $frmA->canSubmit, 'UserA can submit to formA' );
|
||||||
ok( !$frmB->canSubmit, 'UserA cannot submit to formB' );
|
ok( !$frmB->canSubmit, 'UserA cannot submit to formB' );
|
||||||
|
#print 'press return to complete test' ; <>;
|
||||||
ok( !$ems->hasSubmissions, 'UserA has no submissions' );
|
ok( !$ems->hasSubmissions, 'UserA has no submissions' );
|
||||||
# this one should work
|
# this one should work
|
||||||
my $sub1 = $frmA->addSubmission({
|
my $sub1 = $frmA->addSubmission({
|
||||||
title => 'my favorite thing to talk about',
|
title => 'my favorite thing to talk about',
|
||||||
|
description => 'the description',
|
||||||
|
startDate => '1255150800',
|
||||||
});
|
});
|
||||||
isa_ok( $sub1, 'WebGUI::Asset::EMSSubmission', "valid submission succeeded" );
|
push @cleanup, sub { $sub1->delete; };
|
||||||
|
print join( "\n", @{$sub1->{errors}} ),"\n" if defined $sub1->{errors};
|
||||||
|
isa_ok( $sub1, 'WebGUI::Asset::EMSSubmission', "userA/formA valid submission succeeded" );
|
||||||
is( $ems->hasSubmissions, 1, 'UserA has submissions on this ems' );
|
is( $ems->hasSubmissions, 1, 'UserA has submissions on this ems' );
|
||||||
|
|
||||||
#this one should fail
|
#this one should fail
|
||||||
my $sub2 = $frmB->addSubmission({
|
my $sub2 = $frmB->addSubmission({
|
||||||
title => 'why i like to be important',
|
title => 'why i like to be important',
|
||||||
});
|
});
|
||||||
ok( not defined $sub2, "UserA cannot submit to formB" );
|
print join( "\n", @{$sub2->{errors}} ),"\n" if defined $sub2->{errors};
|
||||||
|
ok( ref $sub2 eq 'HASH' && !$sub2->{isValid}, "UserA cannot submit to formB" );
|
||||||
|
|
||||||
loginUserB;
|
loginUserB;
|
||||||
|
|
||||||
|
|
@ -239,33 +260,43 @@ ok( $ems->canSubmit, 'UserB can submit to this ems' );
|
||||||
ok( !$frmA->canSubmit, 'UserB cannot submit to formA' );
|
ok( !$frmA->canSubmit, 'UserB cannot submit to formA' );
|
||||||
ok( $frmB->canSubmit, 'UserB can submit to formB' );
|
ok( $frmB->canSubmit, 'UserB can submit to formB' );
|
||||||
|
|
||||||
|
$sub2 = $frmB->addSubmission({
|
||||||
|
title => 'why i like to be important',
|
||||||
|
description => 'the description',
|
||||||
|
mfRequiredUrl => 'http://google.com',
|
||||||
|
});
|
||||||
|
push @cleanup, sub { $sub2->delete; };
|
||||||
|
print join( "\n", @{$sub2->{errors}} ),"\n" if defined $sub2->{errors};
|
||||||
|
isa_ok( $sub2, 'WebGUI::Asset::EMSSubmission', "userB/FormB valid submission succeeded" );
|
||||||
|
|
||||||
loginUserC;
|
loginUserC;
|
||||||
|
|
||||||
ok( $ems->canSubmit, 'UserC can submit to this ems' );
|
ok( $ems->canSubmit, 'UserC can submit to this ems' );
|
||||||
ok( $frmA->canSubmit, 'UserC can submit to formA' );
|
ok( $frmA->canSubmit, 'UserC can submit to formA' );
|
||||||
ok( $frmB->canSubmit, 'UserC can submit to formB' );
|
ok( $frmB->canSubmit, 'UserC can submit to formB' );
|
||||||
|
|
||||||
SKIP: { skip 'create submission failed', 8 unless defined $sub1;
|
SKIP: { skip 'create submission failed', 8 unless ref $sub1 eq 'WebGUI::Asset::EMSSubmission' and ref $sub1 eq ref $sub2;
|
||||||
|
|
||||||
loginUserA;
|
loginUserA;
|
||||||
|
|
||||||
$sub1->addComment( 'this is a test comment' );
|
$sub1->addComment( 'this is a test comment' );
|
||||||
cmp_deeply($sub1->get('comments')->[0],{
|
cmp_deeply($sub1->get('comments')->[0],{
|
||||||
id => re( qr/.+/ ),
|
id => re( qr/.+/ ),
|
||||||
alias => '',
|
alias => 'userA',
|
||||||
userId => $userC->userId,
|
userId => $userA->userId,
|
||||||
comment => 'this is a test comment',
|
comment => 'this is a test comment',
|
||||||
rating => 0,
|
rating => 0,
|
||||||
date => re( qr/\d{10}/ ),
|
date => re( qr/\d{10}/ ),
|
||||||
ip => undef,
|
ip => undef,
|
||||||
}, "successfully added comment" );
|
}, "successfully added comment" );
|
||||||
|
|
||||||
ok($sub1->update({
|
$sub1->update({
|
||||||
title => 'the new title'
|
title => 'the new title'
|
||||||
}),'update submission');
|
});
|
||||||
|
|
||||||
is( $sub1->get('title'),'the new title','successfully changed the title');
|
is( $sub1->get('title'),'the new title','successfully changed the title');
|
||||||
|
|
||||||
|
loginRgstr;
|
||||||
|
|
||||||
$sub1->update({ status => 'approved' });
|
$sub1->update({ status => 'approved' });
|
||||||
is($sub1->get('status'),'approved','set status to approved');
|
is($sub1->get('status'),'approved','set status to approved');
|
||||||
|
|
@ -281,23 +312,36 @@ my $cleanupSubmissions = WebGUI::Test::Activity->create( $session,
|
||||||
"WebGUI::Workflow::Activity::CleanupEMSSubmissions"
|
"WebGUI::Workflow::Activity::CleanupEMSSubmissions"
|
||||||
);
|
);
|
||||||
|
|
||||||
WebGUI::Test->workflowsToDelete($approveSubmissions,$cleanupSubmissions);
|
push @cleanup, sub { $approveSubmissions->delete; $cleanupSubmissions->delete; };
|
||||||
|
|
||||||
is($approveSubmissions->run, 'complete', 'approval complete');
|
is($approveSubmissions->run, 'complete', 'approval complete');
|
||||||
is($approveSubmissions->run, 'done', 'approval done');
|
is($approveSubmissions->run, 'done', 'approval done');
|
||||||
|
|
||||||
is( $sub1->get('status'),'created','submission has been created');
|
is( $sub1->get('status'),'failed','submission failed to create');
|
||||||
|
|
||||||
my $TODO = q{
|
# TODO fill in the rest of the data required by EMSTicket
|
||||||
can we look for the EMSTicket asset for the created submission?
|
|
||||||
-- perhaps it should be assigned to the ticket somehow?
|
is($approveSubmissions->run, 'complete', 'approval complete');
|
||||||
run addpoval on a submission that is missing data
|
is($approveSubmissions->run, 'done', 'approval done');
|
||||||
-- approval runs fine, but status should be failed
|
|
||||||
update submissions to be more than a day old
|
is( $sub1->get('status'),'created','approval successfull');
|
||||||
run submission cleanup activity
|
|
||||||
-- cleanup only denied entries
|
my $ticket = WebGUI::Asset->newByDynamicClass($session, $sub1->get('ticketId'));
|
||||||
-- cleanup denied and created entries
|
isa_ok( $ticket, 'WebGUI::Asset::Sku::EMS_Ticket', 'approval created a ticket');
|
||||||
};
|
push @cleanup, sub { $ticket->delete; };
|
||||||
|
|
||||||
|
$sub2->update({
|
||||||
|
lastModified => time - ( 60 * 60 * 72 ), # last modified 3 days ago
|
||||||
|
});
|
||||||
|
my $submissionId = $sub2->get('assetId');
|
||||||
|
|
||||||
|
is($cleanupSubmissions->run, 'complete', 'cleanup complete');
|
||||||
|
is($cleanupSubmissions->run, 'done', 'cleanup done');
|
||||||
|
|
||||||
|
$sub2 = WebGUI::Asset->newByDynamicClass($session, $submissionId);
|
||||||
|
is( $sub2, undef, 'approval created a ticket');
|
||||||
|
|
||||||
|
# TODO add a test to cleanup denied and created entries
|
||||||
|
|
||||||
} # end of skip
|
} # end of skip
|
||||||
|
|
||||||
|
|
@ -308,6 +352,6 @@ print 'press return to complete test' ; <>;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Cleanup
|
# Cleanup
|
||||||
END {
|
END {
|
||||||
# nothing to cleanup;
|
map { eval { $_->() } } ( @cleanup );
|
||||||
}
|
}
|
||||||
#vim:ft=perl
|
#vim:ft=perl
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue