rather a lot of debugging in the EMS Submission system

This commit is contained in:
daviddelikat 2009-11-15 22:02:36 -06:00
parent c089da4c4f
commit 7f6c24e7e0
10 changed files with 82 additions and 49 deletions

View file

@ -50,6 +50,21 @@ These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 addComment ( comment [, rating, user ] )
send email when a comment is added
=cut
sub addComment {
my $self = shift;
$self->next::method(@_);
$self->sendEmailUpdate;
}
#-------------------------------------------------------------------
=head2 addRevision
@ -341,7 +356,7 @@ sub sendEmailUpdate {
my $session = $self->session;
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmission" );
if( $self->get('sendEmailOnChange') ) {
WebGUI::Inbox->new($session)->addMessage( $session,{
WebGUI::Inbox->new($session)->addMessage( {
status => 'unread',
message => $i18n->get('your submission has been updated') . "\n\n" .
$self->get('title'),
@ -367,7 +382,6 @@ parameters for the submission
=cut
sub www_editSubmission {
my $this = shift;
my $self;
@ -396,11 +410,11 @@ sub www_editSubmission {
$newform->hidden(name => 'assetId', value => $assetId);
my $formDescription = $parent->getFormDescription;
my @defs = reverse @{__PACKAGE__->definition($session)};
my @fieldNames = qw/title submissionStatus startDate duration seatsAvailable location description/;
my @fieldNames = qw/title submissionStatus sendEmailOnChange startDate duration seatsAvailable location description/;
my $fields;
for my $def ( @defs ) {
my $properties = $def->{properties};
for my $fieldName ( %$properties ) {
for my $fieldName ( keys %$properties ) {
if( defined $formDescription->{$fieldName} ) {
$fields->{$fieldName} = { %{$properties->{$fieldName}} }; # a simple first level copy
if( $fieldName eq 'description' ) {
@ -448,10 +462,11 @@ sub www_editSubmission {
}
}
$newform->submit;
my $title = $assetId eq 'new' ? $i18n_WG->get(99) : $asset->get('title');
my $title = $assetId eq 'new' ? $i18n->get('new submission') : $asset->get('title');
my $content =
$asset->processTemplate({
errors => $params->{errors} || [],
isDynamic => $session->form->get('asJson') || 0,
backUrl => $parent->getUrl,
pageTitle => $title,
pageForm => $newform->print,
@ -517,10 +532,10 @@ sub getEditForm {
my $tabform = $self->SUPER::getEditForm;
my $comments = $tabform->getTab( 'comments' );
#add the comments...
# TODO once comments can be submitted using AJAX this will work...
# be sure to uncomment the tab in the next function also...
#my $comments = $tabform->getTab( 'comments' );
# $comments->div({name => 'comments',
# contentCallback => sub { $self->getFormattedComments },
# });
@ -543,7 +558,10 @@ sub getEditTabs {
my $self = shift;
my $i18n = WebGUI::International->new($self->session,"Asset_EMSSubmission");
my $sku_i18n = WebGUI::International->new($self->session,"Asset_Sku");
return ($self->SUPER::getEditTabs(), ['shop', $sku_i18n->get('shop'), 9], ['comments', $i18n->get('comments'), 9]);
return ($self->SUPER::getEditTabs(), ['shop', $sku_i18n->get('shop'), 9],
# The comment tab is not available because comments are not AJAX yet...
# ['comments', $i18n->get('comments'), 9]
);
}
#-------------------------------------------------------------------

View file

@ -142,7 +142,7 @@ sub definition {
submissionDeadline => {
tab => "properties",
fieldType => "Date",
defaultValue => time , # + ( 30 * 24 * 60 * 60 ) , # 30 days
defaultValue => time + ( 30 * 24 * 60 * 60 ) , # 30 days
label => $i18n->get("submission deadline label"),
hoverHelp => $i18n->get("submission deadline label help")
},
@ -308,7 +308,7 @@ sub www_editSubmissionForm {
my $formDescription = $params->{formDescription} || $self ? $self->getFormDescription : { };
for my $fieldId ( @fieldNames ) {
next if $fieldId eq 'submissionStatus';
next if $fieldId =~ /^(submissionStatus|sendEmailOnChange)$/;
my $field = $fields->{$fieldId};
$newform->yesNo(
label => $field->{label},
@ -328,6 +328,7 @@ sub www_editSubmissionForm {
}
my $content = $asset->processTemplate({
errors => $params->{errors} || [],
isDynamic => $session->form->get('asJson') || 0,
backUrl => $parent->getUrl,
pageTitle => $title,
pageForm => $newform->print,
@ -599,8 +600,9 @@ sub processForm {
}
my @fieldNames = split( ' ', $form->get('fieldNames') );
$params->{formDescription} = { map { $_ => $form->get($_ . '_yesNo') } ( @fieldNames ) };
$params->{formDescription}{_fieldList} = [ map { $params->{formDescription}{$_} ? $_ : () } ( @fieldNames ) ];
$params->{formDescription}{submissionStatus} = 0;
$params->{formDescription}{sendEmailOnChange} = 1;
$params->{formDescription}{_fieldList} = [ map { $params->{formDescription}{$_} ? $_ : () } ( @fieldNames ) ];
if( scalar( @{$params->{formDescription}{_fieldList}} ) == 0 ) {
$params->{_isValid} = 0;
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" );

View file

@ -259,7 +259,7 @@ sub definition {
hoverHelp => $i18n->get('registration staff group help'),
},
submittedLocationsList => {
fieldType => 'text',
fieldType => 'textarea',
tab => 'properties',
defaultValue => '',
label => $i18n->get('submitted location list label'),
@ -499,7 +499,7 @@ sub getSubmissionLocations {
my $self = shift;
my $text = $self->get('submittedLocationsList');
return undef if $text eq '';
return [ split( /\s+/, $text ) ];
return [ split( /[\s\n]+/, $text ) ];
}
#-------------------------------------------------------------------
@ -659,7 +659,7 @@ A WebGUI::User object. Defaults to $session->user.
sub isRegistrationStaff {
my $self = shift;
my $user = shift || $self->session->user;
$user->isInGroup($self->get('registrationStaffGroupId'));
$user->isInGroup($self->get('registrationStaffGroupId')) || $self->canEdit;
}
#-------------------------------------------------------------------
@ -739,9 +739,11 @@ 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'),
addSubmissionUrl => $self->getUrl('func=viewSubmissionQueue'),
# addSubmissionUrl => $self->getUrl('func=viewSubmissionQueue#addSubmission'),
viewSubmissionQueueUrl => $self->getUrl('func=viewSubmissionQueue'),
addSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue#addSubmissionForm'),
addSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue'),
# addSubmissionFormUrl => $self->getUrl('func=viewSubmissionQueue#addSubmissionForm'),
manageBadgeGroupsUrl=> $self->getUrl('func=manageBadgeGroups'),
getBadgesUrl => $self->getUrl('func=getBadgesAsJson'),
isRegistrationStaff => $self->isRegistrationStaff,
@ -842,8 +844,9 @@ call www_editSubmissionForm with assetId == new
=cut
sub www_addSubmissionForm {
my $self = shift;
$self->www_editSubmissionForm( { assetId => 'new' } );
my $self = shift;
my $params = shift || { };
$self->www_editSubmissionForm( { assetId => 'new', %$params } );
}
#-------------------------------------------------------------------
@ -1068,7 +1071,7 @@ test and save data posted from editSubmissionForm...
sub www_editSubmissionFormSave {
my $self = shift;
return $self->session->privilege->insufficient() unless $self->isRegistrationStaff;
return $self->session->privilege->insufficient() unless $self->isRegistrationStaff || $self->canEdit;
my $formParams = WebGUI::Asset::EMSSubmissionForm->processForm($self);
if( $formParams->{_isValid} ) {
delete $formParams->{_isValid};
@ -2734,7 +2737,12 @@ sub www_viewSubmissionQueue {
for my $tabSource ( @{$self->getSubmissionForms} ) {
push @{$params->{tabs}}, $tabSource->www_editSubmissionForm( { asHashRef => 1 } );
}
$params->{tabs}[0]{selected} = 1; # the submission queue tab
if( scalar( @{$params->{tabs}} ) == 1 ) { # there were no existing forms
push @{$params->{tabs}}, $self->www_addSubmissionForm( { asHashRef => 1 } );
$params->{tabs}[1]{selected} = 1; # the new submission form tab
} else {
$params->{tabs}[0]{selected} = 1; # the submission queue tab
}
}
elsif( $canSubmit ) {
for my $tabSource ( @{$self->getSubmissionForms} ) {

View file

@ -12,7 +12,7 @@ our $I18N = { ##hashref of hashes
'send email label' => {
message => q|Send Email when Submission Editted|,
lastUpdated => 1131394072,
context => q|This is the lable for the flag for setting the option to send email to the owner when the submission is eddited.|
context => q|This is the lable for the flag for setting the option to send email to the owner when the submission is edited.|
},
'send email label help' => {
message => q|Check this box if you would like to recieve email for all changes made to your submission|,

View file

@ -19,6 +19,7 @@ use lib "$FindBin::Bin/../lib";
use Test::More;
use Test::Deep;
use Test::Warn;
use HTML::Form;
use JSON;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Test::Activity;
@ -96,7 +97,7 @@ my $ems = $node->addChild({
});
# 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",{
my $mf1Id = $ems->setCollateral("EMSEventMetaField", "fieldId",{
fieldId=> 'new',
label => 'mfRequiredUrl',
dataType => 'url',
@ -106,7 +107,7 @@ my $ems = $node->addChild({
defaultValues => '',
},1,1);
$ems->setCollateral("EMSEventMetaField", "fieldId",{
my $mf2Id = $ems->setCollateral("EMSEventMetaField", "fieldId",{
fieldId=> 'new',
label => 'mfDate',
dataType => 'date',
@ -243,10 +244,10 @@ cmp_deeply( from_json($ems->www_getAllSubmissions), {
records => [
{
lastReplyDate => '',
submissionId => '3',
submissionId => $sub1->get('submissionId'),
creationDate => ignore(),
createdBy => 'userA',
url => '/test-ems?func=viewSubmissionQueue#3',
url => ignore(),
submissionStatus => $i18n->get('pending'),
title => 'my favorite thing to talk about',
lastReplyBy => ''
@ -257,10 +258,10 @@ cmp_deeply( from_json($ems->www_getAllSubmissions), {
dir => 'DESC',
}, 'test getAllSubmissions for UserA' );
$session->request->setup_body({submissionId => 3});
$session->request->setup_body({submissionId => $sub1->get('submissionId')});
cmp_deeply( from_json($ems->www_getSubmissionById), {
title => 3,
id => 3,
title => $sub1->get('submissionId'),
id => $sub1->get('submissionId'),
text => ignore(),
}, 'test getSubmissionById');
@ -283,20 +284,20 @@ cmp_deeply( from_json($ems->www_getAllSubmissions), {
records => [
{
lastReplyDate => '',
submissionId => '4',
submissionId => $sub2->get('submissionId'),
creationDate => ignore(),
createdBy => 'userB',
url => '/test-ems?func=viewSubmissionQueue#4',
url => ignore(),
submissionStatus => $i18n->get('pending'),
title => 'why i like to be important',
lastReplyBy => ''
},
{
lastReplyDate => '',
submissionId => '3',
submissionId => $sub1->get('submissionId'),
creationDate => ignore(),
createdBy => 'userA',
url => '/test-ems?func=viewSubmissionQueue#3',
url => ignore(),
submissionStatus => $i18n->get('pending'),
title => 'my favorite thing to talk about',
lastReplyBy => ''
@ -380,13 +381,12 @@ is( $sub2, undef, 'submission deleted');
$versionTag->commit;
SKIP: { skip 'requires HTML::Form', 2 unless use_ok 'HTML::Form';
# this is not the greatest testm but it does run through the basic create submissionForm code.
# this is not the greatest test but it does run through the basic create submissionForm code.
loginRgstr;
my %settings = (
assetId => 'new',
fieldNames => 'title description startDate duration seatsAvailable location nzymEeuHPQIsgXY0hZxDxA xlvMNwFi1FWwP0PrUAnxSQ',
fieldNames => "title description startDate duration seatsAvailable location $mf1Id $mf2Id",
title => 'Untitled',
menuTitle => 'Untitled',
url => '',
@ -401,17 +401,18 @@ my %settings = (
duration_yesNo => 1,
seatsAvailable_yesNo => 1,
location_yesNo => 1,
nzymEeuHPQIsgXY0hZxDxA_yesNo => 1,
xlvMNwFi1FWwP0PrUAnxSQ_yesNo => 1,
$mf1Id . '_yesNo' => 1,
$mf2Id . '_yesNo' => 1,
);
my $expected = {
'submissionDeadline' => '1991-06-21',
'menuTitle' => 'Untitled',
'pastDeadlineMessage' => 'The deadline for this submission is past, no more submissions will be taken at this time.',
'pastDeadlineMessage' => $settings{pastDeadlineMessage},
'formDescription' => {
'location' => '1',
'nzymEeuHPQIsgXY0hZxDxA' => 'xlvMNwFi1FWwP0PrUAnxSQ',
$mf1Id => 1,
$mf2Id => 1,
'seatsAvailable' => '1',
'duration' => '1',
'title' => '1',
@ -425,7 +426,8 @@ my $expected = {
'duration',
'seatsAvailable',
'location',
'nzymEeuHPQIsgXY0hZxDxA'
$mf1Id,
$mf2Id,
]
},
'description' => undef,
@ -440,12 +442,16 @@ my $expected = {
my $htmlText = $ems->www_addSubmissionForm;
my $form = HTML::Form->parse($htmlText,'http://localhost/');
for my $input ( $form->inputs ) {
$input->value($settings{$input->name})if exists $settings{$input->name};
isnt( $form, undef, 'form created successfully' );
my $result;
SKIP: { skip 'failed to create form', 1 unless $form;
for my $input ( $form->inputs ) {
$input->value($settings{$input->name})if exists $settings{$input->name};
}
$session->request->setup_body( { $form->form } );
$result = WebGUI::Asset::EMSSubmissionForm->processForm($ems);
cmp_deeply( $result, $expected , 'test process form -- with data' );
}
$session->request->setup_body( { $form->form } );
my $result = WebGUI::Asset::EMSSubmissionForm->processForm($ems);
cmp_deeply( $result, $expected , 'test process form' );
$expected = {
'errors' => [
{
@ -470,8 +476,7 @@ $expected = {
};
$session->request->setup_body( { } );
$result = WebGUI::Asset::EMSSubmissionForm->processForm($ems);
cmp_deeply( $result, $expected , 'test process form' );
} # end of skip HTML::Form
cmp_deeply( $result, $expected , 'test process form -- no data' );
# these run code to see that it runs, but do not check for correctness

View file

@ -182,7 +182,7 @@ WebGUI.EMS = function (configs) {
WebGUI.EMS.i18n.get('Asset_EventManagementSystem','close tab') + '" /></span>',
contentEl: myContent
});
initHoverHelp( myTab );
// initHoverHelp( myTab );
WebGUI.EMS.tabs.addTab( myTab );
var index = WebGUI.EMS.tabs.getTabIndex(myTab);
YAHOO.util.Event.on(myTab.getElementsByClassName('close')[0], 'click', WebGUI.EMS.closeTab , myTab);