fixed problems with tests

This commit is contained in:
daviddelikat 2009-11-08 09:50:57 -06:00
parent 799db1090f
commit 494c8ded0e
5 changed files with 439 additions and 91 deletions

View file

@ -384,19 +384,6 @@ sub getFormDescription {
return JSON->new->decode($self->get('formDescription'));
}
#-------------------------------------------------------------------
=head2 getQueueUrl
returns the URL for the submission queue page with the submisison id in the hash part
=cut
sub getQueueUrl {
my $self = shift;
return $self->ems->getUrl('func=viewSubmissionQueue#' . $self->getId );
}
#-------------------------------------------------------------------
=head2 getQueueUrl

View file

@ -1,5 +1,6 @@
package WebGUI::Asset::Wobject::EventManagementSystem;
=head1 LEGAL
-------------------------------------------------------------------
@ -190,30 +191,30 @@ sub definition {
hoverHelp => $i18n->get('print ticket template help'),
namespace => 'EMS/PrintTicket',
},
eventSubmissionMainTemplateId => {
fieldType => 'template',
defaultValue => 'DoVNijm6lMDE0cYrtvEbDQ',
tab => 'display',
label => $i18n->get('event submission main template'),
hoverHelp => $i18n->get('event submission main template help'),
namespace => 'EMS/SubmissionMain',
},
eventSubmissionTemplateId => {
fieldType => 'template',
defaultValue => '8tqyQx-LwYUHIWOlKPjJrA',
tab => 'display',
label => $i18n->get('event submission template'),
hoverHelp => $i18n->get('event submission template help'),
namespace => 'EMS/Submission',
},
eventSubmissionQueueTemplateId => {
fieldType => 'template',
defaultValue => 'ktSvKU8riGimhcsxXwqvPQ',
tab => 'display',
label => $i18n->get('event submission queue template'),
hoverHelp => $i18n->get('event submission queue template help'),
namespace => 'EMS/SubmissionQueue',
},
eventSubmissionMainTemplateId => {
fieldType => 'template',
defaultValue => 'DoVNijm6lMDE0cYrtvEbDQ',
tab => 'display',
label => $i18n->get('event submission main template'),
hoverHelp => $i18n->get('event submission main template help'),
namespace => 'EMS/SubmissionMain',
},
eventSubmissionTemplateId => {
fieldType => 'template',
defaultValue => '8tqyQx-LwYUHIWOlKPjJrA',
tab => 'display',
label => $i18n->get('event submission template'),
hoverHelp => $i18n->get('event submission template help'),
namespace => 'EMS/Submission',
},
eventSubmissionQueueTemplateId => {
fieldType => 'template',
defaultValue => 'ktSvKU8riGimhcsxXwqvPQ',
tab => 'display',
label => $i18n->get('event submission queue template'),
hoverHelp => $i18n->get('event submission queue template help'),
namespace => 'EMS/SubmissionQueue',
},
printRemainingTicketsTemplateId => {
fieldType => 'template',
defaultValue => 'hreA_bgxiTX-EzWCSZCZJw',
@ -224,8 +225,8 @@ sub definition {
},
badgeInstructions => {
fieldType => 'HTMLArea',
defaultValue => $i18n->get('default badge instructions'),
tab => 'properties',
defaultValue => $i18n->get('default badge instructions'),
tab => 'properties',
label => $i18n->get('badge instructions'),
hoverHelp => $i18n->get('badge instructions help'),
},
@ -257,18 +258,18 @@ sub definition {
label => $i18n->get('registration staff group'),
hoverHelp => $i18n->get('registration staff group help'),
},
submittedLocationsList => {
fieldType => 'text',
tab => 'properties',
defaultValue => '',
label => $i18n->get('submitted location list label'),
hoverHelp => $i18n->get('submitted location list help'),
},
eventSubmissionGroups => {
fieldType => 'hidden',
defaultValue => '',
submittedLocationsList => {
fieldType => 'text',
tab => 'properties',
defaultValue => '',
label => $i18n->get('submitted location list label'),
hoverHelp => $i18n->get('submitted location list help'),
},
eventSubmissionGroups => {
fieldType => 'hidden',
defaultValue => '',
noFormPost => 1,
},
},
nextSubmissionId => {
tab => "properties",
fieldType => "integer",
@ -304,6 +305,21 @@ sub deleteEventMetaField {
}
#-------------------------------------------------------------------
=head2 ems
this is called by the submission sub-system
it is for compatability and ensures that the ems
object is used for certain calls
=cut
sub ems {
my $self = shift;
return $self;
}
#-------------------------------------------------------------------
=head2 getBadges ()
@ -402,6 +418,7 @@ sub getEventFieldsForImport {
type => $field->{dataType},
options => $field->{possibleValues},
defaultValue => $field->{defaultValues},
helpText => $field->{defaultValues},
});
}
return \@fields;
@ -418,7 +435,7 @@ may be SQL optimized for quick access
sub getLocations {
my $self = shift;
my $dateRef = shift ;
my $dateRef = shift;
my %hash;
my %hashDate;
@ -700,9 +717,16 @@ sub view {
addBadgeUrl => $self->getUrl('func=add;class=WebGUI::Asset::Sku::EMSBadge'),
buildBadgeUrl => $self->getUrl('func=buildBadge'),
viewScheduleUrl => $self->getUrl('func=viewSchedule'),
addSubmissionUrl => $self->getUrl('func=viewSubmissionQueue#addSubmission'),
viewSubmissionQueueUrl => $self->getUrl('func=viewSubmissionQueue'),
addSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue#addSubmissionForm'),
manageBadgeGroupsUrl=> $self->getUrl('func=manageBadgeGroups'),
getBadgesUrl => $self->getUrl('func=getBadgesAsJson'),
canEdit => $self->canEdit,
isRegistrationStaff => $self->isRegistrationStaff,
canEdit => $self->canEdit,
canSubmit => $self->canSubmit,
hasSubmissions => $self->hasSubmissions,
hasSubmissionForms => $self->hasSubmissionForms,
lookupRegistrantUrl => $self->getUrl('func=lookupRegistrant'),
);
@ -981,6 +1005,62 @@ sub www_editBadgeGroupSave {
#-------------------------------------------------------------------
=head2 www_editSubmission
use getLineage to find the item to edit based on submissionId
then call www_editSubmission on it
=cut
sub www_editSubmission {
my $self = shift;
my $submissionId = $self->session->form->get('submissionId');
my $asset = $self->getLineage(['descendants'], { returnObjects => 1,
joinClass => "WebGUI::Asset::EMSSubmission",
whereClause => 'submissionId = ' . int($submissionId),
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
} );
return $asset->[0]->www_editSubmission;
}
#-------------------------------------------------------------------
=head2 www_editSubmissionForm
calls editSubmissionForm in WebGUI::Asset::EMSSubmissionForm
=cut
sub www_editSubmissionForm {
my $self = shift;
return $self->session->privilege->insufficient() unless $self->isRegistrationStaff || $self->canEdit;
return WebGUI::Asset::EMSSubmissionForm->www_editSubmissionForm($self,shift);
}
#-------------------------------------------------------------------
=head2 www_editSubmissionFormSave
test and save data posted from editSubmissionForm...
=cut
sub www_editSubmissionFormSave {
my $self = shift;
return $self->session->privilege->insufficient() unless $self->isRegistrationStaff;
my $formParams = WebGUI::Asset::EMSSubmissionForm->processForm($self);
if( $formParams->{_isValid} ) {
delete $formParams->{_isValid};
$self->addSubmissionForm($formParams);
return $self->www_viewSubmissionQueue;
} else {
return $self->www_editSubmissionForm($formParams);
}
}
#-------------------------------------------------------------------
=head2 www_editEventMetaField ( )
Displays the edit form for event meta fields.
@ -1007,6 +1087,7 @@ sub www_editEventMetaField {
required => $self->session->form->process("required",'yesNo'),
possibleValues => $self->session->form->process("possibleValues",'textarea'),
defaultValues => $self->session->form->process("defaultValues",'textarea'),
helpText => $self->session->form->process("helpText",'textarea'),
};
$f->readOnly(
-name => 'error',
@ -1063,6 +1144,12 @@ sub www_editEventMetaField {
-hoverHelp => $i18n->get('488 description'),
-value => $data->{defaultValues},
);
$f->textarea(
-name => "helpText",
-label => $i18n2->get('meta field help text'),
-hoverHelp => $i18n2->get('meta field help text description'),
-value => $data->{helpText},
);
$f->submit;
return $self->processStyle($f->print);
}
@ -1095,6 +1182,7 @@ sub www_editEventMetaFieldSave {
required => $self->session->form->process("required",'yesNo'),
possibleValues => $self->session->form->process("possibleValues",'textarea'),
defaultValues => $self->session->form->process("defaultValues",'textarea'),
helpText => $self->session->form->process("helpText",'textarea'),
},1,1);
return $self->www_manageEventMetaFields();
}
@ -1179,6 +1267,90 @@ sub www_exportEvents {
return "chunked";
}
#----------------------------------------------------------------------------
=head2 www_getAllSubmissions ( )
Get a page of Asset Manager data, ajax style. Returns a JSON array to be
formatted in a WebGUI submission queue data table.
=cut
sub www_getAllSubmissions {
my $self = shift;
my $session = $self->session;
my $datetime = $session->datetime;
my $form = $session->form;
my $tableInfo = {};
return $session->privilege->insufficient unless $self->canSubmit || $self->isRegistrationStaff;
my $orderByColumn = $form->get( 'orderByColumn' ) || $self->get("sortColumn");
my $dir = $form->get('orderByDirection') || $self->get('sortOrder');
my $orderByDirection = lc ($dir) eq "asc" ? "ASC" : "DESC";
my $whereClause ;
if(!$self->isRegistrationStaff) {
my $userId = $session->user->userId;
$whereClause .= qq{ createdBy='$userId'};
}
my $rules;
$rules->{'joinClass' } = "WebGUI::Asset::EMSSubmission";
$rules->{'whereClause' } = $whereClause;
$rules->{'includeOnlyClasses'} = ['WebGUI::Asset::EMSSubmission'];
$rules->{'orderByClause' } = $session->db->dbh->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection if $orderByColumn;
my $sql = "";
$sql = $self->getLineageSql(['descendants'], $rules);
my $startIndex = $form->get( 'startIndex' ) || 1;
my $rowsPerPage = $form->get( 'rowsPerPage' ) || 25;
my $currentPage = int ( $startIndex / $rowsPerPage ) + 1;
my $p = WebGUI::Paginator->new( $session, '', $rowsPerPage, 'pn', $currentPage );
$p->setDataByQuery($sql);
$tableInfo->{'recordsReturned'} = $rowsPerPage;
$tableInfo->{'totalRecords' } = $p->getRowCount;
$tableInfo->{'startIndex' } = $startIndex;
$tableInfo->{'sort' } = $orderByColumn;
$tableInfo->{'dir' } = $orderByDirection;
$tableInfo->{'records' } = [];
for my $record ( @{ $p->getPageData } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $record->{assetId} );
my $lastReplyBy = $asset->get("lastReplyBy");
if ($lastReplyBy) {
$lastReplyBy = WebGUI::User->new($session,$lastReplyBy)->username;
}
# Populate the required fields to fill in
my $lastReplyDate = $asset->get("lastReplyDate");
if($lastReplyDate) {
$lastReplyDate = $datetime->epochToHuman($lastReplyDate,"%y-%m-%d @ %H:%n %p");
}
my %fields = (
submissionId => $asset->get("submissionId"),
url => $asset->getQueueUrl,
title => $asset->get( "title" ),
createdBy => WebGUI::User->new($session,$asset->get( "createdBy" ))->username,
creationDate => $datetime->epochToSet($asset->get( "creationDate" )),
submissionStatus => $self->getSubmissionStatus($asset->get( "submissionStatus" ) || 'pending' ),
lastReplyDate => $lastReplyDate || '',
lastReplyBy => $lastReplyBy || '',
);
push @{ $tableInfo->{ records } }, \%fields;
}
$session->http->setMimeType( 'application/json' );
return JSON->new->encode( $tableInfo );
}
#-------------------------------------------------------------------
=head2 www_getBadgesAsJson ()
@ -1217,6 +1389,36 @@ sub www_getBadgesAsJson {
#-------------------------------------------------------------------
=head2 www_getSubmissionById
returns a JSON dataset with info about the requested submission
=cut
sub www_getSubmissionById {
my $self = shift;
my $submissionId = $self->session->form->get('submissionId');
my $result;
my $res = $self->getLineage(['descendants'],{ limit => 1, returnObjects=>1,
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
joinClass => "WebGUI::Asset::EMSSubmission",
whereClause => q{submissionId='} . $submissionId . q/'/,
} );
if( scalar(@$res) == 0 ) {
$result->{hasError} = 1;
$result->{errors} = [ 'failed to load submission' ];
} else {
$result->{text} = $res->[0]->www_editSubmission;
$result->{title} = $submissionId;
$result->{id} = $submissionId;
}
$self->session->http->setMimeType('application/json');
return JSON->new->encode($result);
}
#-------------------------------------------------------------------
=head2 www_getRegistrantAsJson ( )
Retrieves the properties of a specific badge and the items attached to it. Expects badgeId to be one of the form params.
@ -1559,8 +1761,6 @@ sub www_getScheduleDataJSON {
return JSON->new->encode(\%results);
}
#-------------------------------------------------------------------
=head2 www_getTicketsAsJson ()
@ -2440,7 +2640,6 @@ View the schedule table.
sub www_viewSchedule {
my $self = shift;
return $self->session->privilege->insufficient() unless $self->canView;
my $db = $self->session->db;
my $rowsPerPage = 25;
my $locationsPerPage = $self->get('scheduleColumnsPerPage');

View file

@ -1897,7 +1897,178 @@ normal templates.|,
context => q|help text for the columns per page field|,
},
'edit submission form' => {
message => q|Edit Submission Form|,
lastUpdated => 1147050475,
context => q|Label for the link to edit a submission form.|,
},
'new submission form' => {
message => q|New Submission Form|,
lastUpdated => 1147050475,
context => q|Label for the link to create a new submission form.|,
},
'view submission queue' => {
message => q|Submission Queue|,
lastUpdated => 1147050475,
context => q|Label for link to view submission queue.|,
},
'add submission' => {
message => q|New|,
lastUpdated => 1147050475,
context => q|This is appended to the title of a submission form when user is submitting a new event.|,
},
'new submission' => {
message => q|New Submission|,
lastUpdated => 1147050475,
context => q|Label for link to create a new submission for an event.|,
},
'view my submissions' => {
message => q|My Submissions|,
lastUpdated => 1147050475,
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 main template' => {
message => q|Event Submission Main Template|,
lastUpdated => 1131394072,
context => q|Label for the event submission main template.|
},
'event submission main template help' => {
message => q|This template is used to describe main page of the submission module. It has a dynamic tabset on it which is used to hold one or more pieces of the submission interface.|,
lastUpdated => 1131394072,
context => q|Help text for the event submission main template.|
},
'select form to edit' => {
message => q|Select a Form to Edit|,
lastUpdated => 1147050475,
context => q|Label for list of submission forms; user must choose one to edit.|,
},
'select form to submit' => {
message => q|Select a Form to Submit|,
lastUpdated => 1147050475,
context => q|Label for list of submission forms; user must choose one to proceed to a submission form.|,
},
'pending' => {
message => q|Pending|,
lastUpdated => 1147050475,
context => q|Label for pending status on submission.|,
},
'feedback' => {
message => q|Feedback|,
lastUpdated => 1147050475,
context => q|Label for feedback requested on a submission.|,
},
'denied' => {
message => q|Denied|,
lastUpdated => 1147050475,
context => q|Label for denied status on a submission.|,
},
'approved' => {
message => q|Approved|,
lastUpdated => 1147050475,
context => q|Label for approved status on a submission.|,
},
'created' => {
message => q|Created|,
lastUpdated => 1147050475,
context => q|Label for status indicating ticket is created for submission.|,
},
'failed' => {
message => q|Failed|,
lastUpdated => 1147050475,
context => q|Label indicating ticket creation failed for submission.|,
},
'meta field help text' => {
message => q|Help Text|,
lastUpdated => 1147050475,
context => q|The label for the meta field help text field.|,
},
'meta field help text description' => {
message => q|This help text will be provided in the event submission interface.|,
lastUpdated => 1147050475,
context => q|Describes the help text that is attached to meta fields.|,
},
'default submitted location list' => {
message => q||,
lastUpdated => 1147050475,
context => q|This is the default value for the list of locations for event submission.|,
},
'submitted location list label' => {
message => q|Locations Available for Event Submissions|,
lastUpdated => 1147050475,
context => q|Label for the submitted location list|,
},
'submitted location list help' => {
message => q|Enter a listy of location names here, one name on a line. This list will be available on the event submission form in the location select box. If this field is filled in then only these locations will be available.|,
lastUpdated => 1147050475,
context => q|This is help text for the submitted location list field.|,
},
'submission queue' => {
message => q|Submission Queue|,
lastUpdated => 1147050475,
context => q|Label for the submission list tab for registration staff.|,
},
'my submissions' => {
message => q|My Submissions|,
lastUpdated => 1147050475,
context => q|Label for the submission list tab for event submitters.|,
},
'next submission id label' => {
message => q|Next Submission Id|,
lastUpdated => 1131394072,
context => q|Label for the field which indicates the next id used to create a submission.|
},
'next submission id label help' => {
message => q|This is the value that will be used to fill in the first submission, do not edit it.|,
lastUpdated => 1131394072,
context => q|This is the help text for the 'next submission id' field, the user should be reminded not to edit this field.|
},
'print remaining ticket template help' => {
message => q|EMS Print Remaining Ticket Template|,
lastUpdated => 1147050475,
@ -2084,6 +2255,23 @@ normal templates.|,
context => q|Field Label|,
},
'new form' => {
message => q|New Form|,
lastUpdated => 1147050475,
context => q|The label for the link to create a new submission form.|,
},
'next submission id label' => {
message => q|Next Submission Id|,
lastUpdated => 1131394072,
context => q|Label for the field which indicates the next id used to create a submission.|
},
'next submission id label help' => {
message => q|This is the value that will be used to fill in the first submission, do not edit it.|,
lastUpdated => 1131394072,
- context => q|This is the help text for the 'next submission id' field, the user should be reminded not to edit this field.|
},
'eventMetaData' => {
message => q|Meta data for the event returned as a JSON data structure|,
lastUpdated => 1147050475,

View file

@ -38,7 +38,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 52; # Increment this number for each test you create
plan tests => 49; # Increment this number for each test you create
(my $submitGroupA = WebGUI::Group->new($session,'new'))->name('groupA');
(my $submitGroupB = WebGUI::Group->new($session,'new'))->name('groupB');
@ -68,13 +68,6 @@ sub logout { $session->user({userId => 1}); }
#----------------------------------------------------------------------------
# put your tests here
eval {
my $use = use_ok( 'WebGUI::Asset::EMSSubmissionForm' )
&& use_ok( 'WebGUI::Asset::EMSSubmission' )
&& use_ok( 'WebGUI::Workflow::Activity::CleanupEMSSubmissions' )
&& use_ok( 'WebGUI::Workflow::Activity::ProcessEMSApprovals' );
SKIP: { skip 'package compile failed!', 1 unless $use;
loginAdmin;
@ -358,8 +351,11 @@ $sub1 = $sub1->cloneFromDb;
is( $sub1->get('submissionStatus'),'created','approval successfull');
my $ticket = WebGUI::Asset->newByDynamicClass($session, $sub1->get('ticketId'));
isa_ok( $ticket, 'WebGUI::Asset::Sku::EMSTicket', 'approval created a ticket');
WebGUI::Test->assetsToPurge( $ticket ) if $ticket ;
SKIP: {
skip 'no ticket created', 1 unless isa_ok( $ticket, 'WebGUI::Asset::Sku::EMSTicket', 'approval created a ticket');
is( $ticket->get('title'), $sub1->get('title'), 'Ticket title matches submission title' );
}
my $newDate = time - ( 60 * 60 * 24 * ( $sub2->getParent->get('daysBeforeCleanup') + 1 ) ),
$sub2->update({
@ -501,10 +497,6 @@ $sub1->getFormattedComments;
} [], 'no warnings from calling a bunch of functions';
} # end of use packages skip
}; # end of eval
print $@ if $@;
#done_testing();
#print 'press return to complete test' ; <>;
#----------------------------------------------------------------------------

View file

@ -1,8 +1,7 @@
package WebGUI::Test::Activity;
use WebGUI::Workflow;
my @cleanup; # TODO fix WebGUI::Text::assetsToPurge so that it works with workflows and activities
use WebGUI::Test;
=head Name
@ -43,7 +42,7 @@ params -- params to set in the workflow
sub create {
my $myClass = shift;
my $session = shift;
my $workflowClass = shift;
my $activityClass = shift;
my $activityParams;
if( exists $_[0] and ref $_[0] eq 'HASH' ) {
$activityParams = shift ;
@ -57,10 +56,10 @@ sub create {
mode => 'realtime',
},
);
my $activity = $workflow->addActivity($workflowClass);
my $activity = $workflow->addActivity($activityClass);
if( scalar( keys %$activityParams ) > 0 ) {
$activity->set(%$activityParams);
}
}
my $instance = WebGUI::Workflow::Instance->create($session,
{
@ -69,10 +68,7 @@ sub create {
}
);
my $tag = WebGUI::VersionTag->getWorking($session);
$tag->commit;
WebGUI::Test->tagsToRollback($tag);
WebGUI::Test->workflowsToDelete($instance,$workflow);
addToCleanup($workflow);
return bless { instance => $instance,
session => $session,
@ -92,20 +88,6 @@ sub rerun {
skipSpectreNotification => 1,
}
);
# WebGUI::Test->assetsToPurge($self->{instance}); -- does not work
push @cleanup, $self->{instance};
my $tag = WebGUI::VersionTag->getWorking($session, 1);
if( $tag ) {
$tag->commit;
WebGUI::Test->tagsToRollback($tag);
}
}
END {
map { $_->delete; } ( @cleanup );
}
1;