cleaned up the EMS submission system

This commit is contained in:
daviddelikat 2009-11-11 22:29:21 -06:00
parent 9d14e8b420
commit 3b9902e395
11 changed files with 85 additions and 40 deletions

View file

@ -449,7 +449,7 @@ sub www_editSubmission {
}
$newform->submit;
my $title = $assetId eq 'new' ? $i18n_WG->get(99) : $asset->get('title');
my $content = $asset->processStyle(
my $content =
$asset->processTemplate({
errors => $params->{errors} || [],
backUrl => $parent->getUrl,
@ -457,14 +457,16 @@ sub www_editSubmission {
pageForm => $newform->print,
commentForm => $self ? $self->getFormattedComments : '',
commentFlag => $self ? 1 : 0 ,
},$parent->getParent->get('eventSubmissionTemplateId')));
},$parent->getParent->get('eventSubmissionTemplateId'));
WebGUI::Macro::process( $session, \$content );
if( $session->form->get('asJson') ) {
if( $params->{asHashRef} ) {
return { text => $content, title => $title, };
} elsif( $session->form->get('asJson') ) {
$session->http->setMimeType( 'application/json' );
return JSON->new->encode( { text => $content, title => $title, id => $assetId ne 'new' ? $assetId : 'new' . rand } );
} else {
$session->http->setMimeType( 'text/html' );
return $content;
return $asset->processStyle( $content );
}
}

View file

@ -142,7 +142,7 @@ sub definition {
submissionDeadline => {
tab => "properties",
fieldType => "Date",
defaultValue => '677496912', # far in the future...
defaultValue => time , # + ( 30 * 24 * 60 * 60 ) , # 30 days
label => $i18n->get("submission deadline label"),
hoverHelp => $i18n->get("submission deadline label help")
},
@ -251,7 +251,9 @@ sub www_editSubmissionForm {
} ( @$res ) );
my $title = $i18n->get('select form to edit') ;
my $content = '<h1>' . $title . '</h1><ul>' . $listOfLinks . '</ul>' ;
if( $session->form->get('asJson') ) {
if( $params->{asHashRef} ) {
return { text => $content, title => $title, } ;
} elsif( $session->form->get('asJson') ) {
$session->http->setMimeType( 'application/json' );
return JSON->new->encode( { text => $content, title => $title, id => 'list' . rand } );
} else {
@ -317,7 +319,9 @@ sub www_editSubmissionForm {
}
$newform->submit;
my $title = $assetId eq 'new' ? $i18n->get('new form') || 'new' : $asset->get('title');
if( $session->form->get('asJson') ) {
if( $params->{asHashRef} ) {
; # not setting mimie type
} elsif( $session->form->get('asJson') ) {
$session->http->setMimeType( 'application/json' );
} else {
$session->http->setMimeType( 'text/html' );
@ -329,7 +333,9 @@ sub www_editSubmissionForm {
pageForm => $newform->print,
},$parent->get('eventSubmissionTemplateId'));
WebGUI::Macro::process( $session, \$content );
if( $session->form->get('asJson') ) {
if( $params->{asHashRef} ) {
return { text => $content, title => $title };
} elsif( $session->form->get('asJson') ) {
return JSON->new->encode( { text => $content, title => $title, id => $assetId ne 'new' ? $assetId : 'new' . rand } );
} else {
return $asset->ems->processStyle( $content );
@ -501,7 +507,8 @@ calls www_editSubmission with assetId == new
sub www_addSubmission {
my $self = shift;
$self->www_editSubmission( { assetId => 'new' } );
my $params = shift || { };
$self->www_editSubmission( { assetId => 'new', %$params } );
}
#-------------------------------------------------------------------
@ -533,7 +540,7 @@ calls WebGUI::Asset::EMSSubmission->editSubmission
sub www_editSubmission {
my $self = shift;
return $self->session->privilege->insufficient() unless $self->canEdit;
return $self->session->privilege->insufficient() unless $self->canSubmit;
return WebGUI::Asset::EMSSubmission->www_editSubmission($self,shift);
}
@ -547,7 +554,7 @@ validate and create a new submission
sub www_editSubmissionSave {
my $self = shift;
return $self->session->privilege->insufficient() unless $self->canEdit;
return $self->session->privilege->insufficient() unless $self->canSubmit;
my $formParams = WebGUI::Asset::EMSSubmission->processForm($self);
if( $formParams->{_isValid} ) {
delete $formParams->{_isValid};

View file

@ -270,13 +270,6 @@ sub definition {
defaultValue => '',
noFormPost => 1,
},
nextSubmissionId => {
tab => "properties",
fieldType => "integer",
defaultValue => 1,
label => $i18n->get("next submission id label"),
hoverHelp => $i18n->get("next submission id label help")
},
);
push(@{$definition}, {
assetName=>$i18n->get('assetName'),
@ -461,9 +454,7 @@ get a sequence number for the submission id
sub getNextSubmissionId {
my $self = shift;
my ($submissionId) = $self->session->db->read('select nextSubmissionId from EventManagementSystem where assetId = ?', [ $self->getId ] )->array;
$self->update( { nextSubmissionId => ($submissionId + 1) } );
return $submissionId;
return $self->session->db->getNextId( 'SubmissionId' );
}
#-------------------------------------------------------------------
@ -512,6 +503,37 @@ sub getSubmissionLocations {
}
#-------------------------------------------------------------------
=head2 getSubmissionForms
returns a list of objects; one for each submission form related to this EMS
this function is called twice in just a few lines of code so the results are cached
to prevent extra hits to the database
=cut
sub getSubmissionForms {
my $self = shift;
return $self->{_submissionForms} if $self->{_submissionFormTime} > time;
$self->{_submissionForms} = $self->getLineage( ['children'], { returnObjects => 1,
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
} );
$self->{_submissionFormTime} = time + 60;
return $self->{_submissionForms};
}
#-------------------------------------------------------------------
=head2 getSubmissionStatus
returns internationalized hash of submission status values or one internationalized name if a status is passed in
=cut
sub getSubmissionStatus {
my $self = shift;
my $key = shift;
@ -724,7 +746,7 @@ sub view {
getBadgesUrl => $self->getUrl('func=getBadgesAsJson'),
isRegistrationStaff => $self->isRegistrationStaff,
canEdit => $self->canEdit,
canSubmit => $self->canSubmit,
canSubmit => $self->canSubmit && ! $self->isRegistrationStaff,
hasSubmissions => $self->hasSubmissions,
hasSubmissionForms => $self->hasSubmissionForms,
lookupRegistrantUrl => $self->getUrl('func=lookupRegistrant'),
@ -772,9 +794,7 @@ sub www_addSubmission {
my $form;
if( ! defined $formId ) {
my $res = $self->getLineage(['children'],{ returnObjects => 1,
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
} );
my $res = $self->getSubmissionForms;
my @new = map { $_->canSubmit ? $_ : () } ( @$res);
if( scalar(@new) == 0 ) {
return $self->www_view;
@ -2669,7 +2689,7 @@ sub www_viewSchedule {
sub www_viewSubmissionQueue {
my $self = shift;
my $isRegistrationStaff = $self->isRegistrationStaff;
my $canSubmit = $self->canSubmit;
my $canSubmit = $self->canSubmit && ! $isRegistrationStaff;
my $canEdit = $self->canEdit;
my $i18n = $self->i18n;
return $self->session->privilege->insufficient() unless $canSubmit || $isRegistrationStaff;
@ -2687,9 +2707,7 @@ sub www_viewSubmissionQueue {
linkUrl => $self->getUrl('func=viewSubmissionQueue#' . $_->getId . '_new' ),
ajaxUrl => $_->getUrl('func=addSubmission'),
} } (
@{$self->getLineage( ['children'],{ returnObjects => 1,
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
} ) }
@{$self->getSubmissionForms}
);
my $params = {
backUrl => $self->getUrl,
@ -2707,9 +2725,26 @@ sub www_viewSubmissionQueue {
addSubmissionFormAjaxUrl => $self->getUrl('func=addSubmissionForm'),
addSubmissionAjaxUrl => $self->getUrl('func=addSubmission'),
submissionFormUrls => \@submissionFormUrls,
queueTabTitle => $isRegistrationStaff ? $i18n->get('submission queue') : $i18n->get('my submissions'),
};
$params->{QueueTabData} = $self->processTemplate($params,$self->get('eventSubmissionQueueTemplateId'));
push( @{$params->{tabs}}, {
title => $isRegistrationStaff ? $i18n->get('submission queue') : $i18n->get('my submissions'),
text => $self->processTemplate($params,$self->get('eventSubmissionQueueTemplateId')),
} );
if( $isRegistrationStaff ) {
for my $tabSource ( @{$self->getSubmissionForms} ) {
push @{$params->{tabs}}, $tabSource->www_editSubmissionForm( { asHashRef => 1 } );
}
$params->{tabs}[0]{selected} = 1; # the submission queue tab
}
elsif( $canSubmit ) {
for my $tabSource ( @{$self->getSubmissionForms} ) {
next unless $tabSource->canSubmit;
push @{$params->{tabs}}, $tabSource->www_addSubmission( { asHashRef => 1 } );
}
$params->{tabs}[$#{$params->{tabs}}]{selected} = 1;
}
my $tabid = 'tab01';
for my $tab ( @{$params->{tabs}} ) { $tab->{id} = $tabid ++; }
return $self->processStyle(
$self->processTemplate( $params, $self->get('eventSubmissionMainTemplateId')));

View file

@ -1904,7 +1904,7 @@ normal templates.|,
},
'new submission form' => {
message => q|New Submission Form|,
message => q|Manage Event Submissions|,
lastUpdated => 1147050475,
context => q|Label for the link to create a new submission form.|,
},
@ -1922,7 +1922,7 @@ normal templates.|,
},
'new submission' => {
message => q|New Submission|,
message => q|Submit an Event|,
lastUpdated => 1147050475,
context => q|Label for link to create a new submission for an event.|,
},
@ -2042,7 +2042,7 @@ normal templates.|,
},
'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.|,
message => q|Enter a list 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.|,
},