From: Chris W. <la...@us...> - 2004-12-05 08:52:21
|
Update of /cvsroot/openinteract/OpenInteract2/pkg/lookup/OpenInteract2/Action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16278/pkg/lookup/OpenInteract2/Action Modified Files: LookupEdit.pm Log Message: update packages to move as many messages as possible out of code and into message files; use new add_status/add_error shortcuts Index: LookupEdit.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/pkg/lookup/OpenInteract2/Action/LookupEdit.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** LookupEdit.pm 14 Jun 2004 23:38:43 -0000 1.13 --- LookupEdit.pm 5 Dec 2004 08:51:23 -0000 1.14 *************** *** 59,71 **** $self->_find_lookup_info( $request->param( 'lookup_type' ) ); unless ( $lookup_info ) { ! $self->param_add( error_msg => $error_msg ); return $self->execute({ task => 'list_lookups' }); } } unless ( $lookup_info->{partition_field} ) { ! my $error_part_msg = join( '', ! "Cannot use $lookup_info->{lookup_type} as partitioned -- ", ! "no value for 'partition_field' specified in action config." ); ! $self->param_add( error_msg => $error_part_msg ); return $self->execute({ task => 'list_lookups' }); } --- 59,69 ---- $self->_find_lookup_info( $request->param( 'lookup_type' ) ); unless ( $lookup_info ) { ! $self->add_error( $error_msg ); return $self->execute({ task => 'list_lookups' }); } } unless ( $lookup_info->{partition_field} ) { ! $self->add_error_key( 'lookup.error.no_partition_value', ! $lookup_info->{lookup_type} ); return $self->execute({ task => 'list_lookups' }); } *************** *** 75,84 **** }; if ( $@ ) { ! $self->param_add( ! error_msg => "Could not retrieve values for " . ! "$lookup_info->{partition_field}: $@" ); } ! my %params = ( value_list => $partition_values, ! lookup_type => $lookup_info->{lookup_type} ); return $self->generate_content( \%params ); } --- 73,83 ---- }; if ( $@ ) { ! $self->add_error_key( 'lookup.error.fetch_partition_values', ! $lookup_info->{partition_field}, $@ ); } ! my %params = ( ! value_list => $partition_values, ! lookup_type => $lookup_info->{lookup_type}, ! ); return $self->generate_content( \%params ); } *************** *** 96,100 **** $self->_find_lookup_info( $lookup_type ); unless ( $lookup_info ) { ! $self->param_add( error_msg => $error_msg ); return $self->execute({ task => 'list_lookups' }); } --- 95,99 ---- $self->_find_lookup_info( $lookup_type ); unless ( $lookup_info ) { ! $self->add_error( $error_msg ); return $self->execute({ task => 'list_lookups' }); } *************** *** 113,118 **** if ( $params{partition_field} ) { ! $params{partition_value} = ! $request->param( 'partition_value' ); unless ( $params{partition_value} ) { $self->param( lookup_info => $lookup_info ); --- 112,116 ---- if ( $params{partition_field} ) { ! $params{partition_value} = $request->param( 'partition_value' ); unless ( $params{partition_value} ) { $self->param( lookup_info => $lookup_info ); *************** *** 130,134 **** }; if ( $@ ) { ! $self->param_add( error_msg => "Failed to lookup entries: $@" ); } else { --- 128,132 ---- }; if ( $@ ) { ! $self->add_error_key( 'lookup.error.fetch_lookup_values', $@ ); } else { *************** *** 151,156 **** }; if ( $@ ) { ! $self->param_add( ! error_msg => "Cannot lookup related $field_name: $@" ); } } --- 149,154 ---- }; if ( $@ ) { ! $self->add_error_key( 'lookup.error.fetch_lookup_related', ! $field_name, $@ ); } } *************** *** 175,179 **** $self->_find_lookup_info( $lookup_type ); unless ( $lookup_info ) { ! $self->param_add( error_msg => $error_msg ); return $self->execute({ task => 'list_lookups' }); } --- 173,177 ---- $self->_find_lookup_info( $lookup_type ); unless ( $lookup_info ) { ! $self->add_error( $error_msg ); return $self->execute({ task => 'list_lookups' }); } *************** *** 197,206 **** if ( $@ ) { $log->error( "Cannot save ID '$id': $@" ); ! $self->param_add( error_msg => "Error saving $id: $@" ); } else { if ( $value ) { my $show_id = ( $id =~ /^$NEW_KEY/ ) ? 'new item' : $id; ! $self->param_add( status_msg => "Saved $show_id ($value) ok" ); } } --- 195,205 ---- if ( $@ ) { $log->error( "Cannot save ID '$id': $@" ); ! $self->add_error_key( 'lookup.error.save', $id, $@ ); } else { if ( $value ) { my $show_id = ( $id =~ /^$NEW_KEY/ ) ? 'new item' : $id; ! $self->add_status_key( 'lookup.status.save', ! $show_id, $value ); } } *************** *** 236,241 **** my ( $lookup_info, $error_msg ) = $self->_find_lookup_info( $key ); if ( $lookup_info ) { ! $log->is_debug && ! $log->debug( "Found lookup item '$key'" ); push @lookup_list, $lookup_info; } --- 235,239 ---- my ( $lookup_info, $error_msg ) = $self->_find_lookup_info( $key ); if ( $lookup_info ) { ! $log->is_debug && $log->debug( "Found lookup item '$key'" ); push @lookup_list, $lookup_info; } *************** *** 248,257 **** my ( $self, $object_type, $field ) = @_; my $object_class = CTX->lookup_object( $object_type ); ! return $object_class->db_select( ! { select_modifier => 'DISTINCT', ! select => [ $field ], ! from => [ $object_class->table_name ], ! order => $field, ! return => 'single-list' }); } --- 246,256 ---- my ( $self, $object_type, $field ) = @_; my $object_class = CTX->lookup_object( $object_type ); ! return $object_class->db_select({ ! select_modifier => 'DISTINCT', ! select => [ $field ], ! from => [ $object_class->table_name ], ! order => $field, ! return => 'single-list', ! }); } *************** *** 262,271 **** unless ( $lookup_type ) { ! return ( undef, 'Cannot list lookup entries without a lookup type.' ); } my $lookup_info = CTX->lookup_action_info( $lookup_type ); unless ( ref $lookup_info and $lookup_info->{action_type} eq 'lookup' ) { ! return ( undef, "Cannot list lookup entries: $lookup_type " . ! "is not a valid lookup." ); } $log->is_debug && --- 261,269 ---- unless ( $lookup_type ) { ! return ( undef, $self->_msg( 'lookup.error.no_lookup_type' ) ); } my $lookup_info = CTX->lookup_action_info( $lookup_type ); unless ( ref $lookup_info and $lookup_info->{action_type} eq 'lookup' ) { ! return ( undef, $self->_msg( 'lookup.error.no_lookup_type', $lookup_type ) ); } $log->is_debug && *************** *** 324,329 **** foreach my $field ( @{ $field_list } ) { my $value = $request->param( "$field-$id" ); ! $log->is_debug && ! $log->debug( "Found in '$id' [$field: $value]" ); $object->{ $field } = $value; $not_blank++ if ( $value ); --- 322,326 ---- foreach my $field ( @{ $field_list } ) { my $value = $request->param( "$field-$id" ); ! $log->is_debug && $log->debug( "Found in '$id' [$field: $value]" ); $object->{ $field } = $value; $not_blank++ if ( $value ); |