--- lib/A3C/Model/StrixSiteSelection.pm 2008/06/15 11:03:50 158 +++ lib/A3C/Model/StrixInstanceSelection.pm 2008/06/17 21:28:28 195 @@ -1,18 +1,18 @@ use strict; use warnings; -package A3C::Model::StrixSiteSelection; +package A3C::Model::StrixInstanceSelection; use Jifty::DBI::Schema; use Data::Dump qw/dump/; use A3C::Record schema { - column strix => - label is _('Site identifier'), + column instance => + label is _('Instance identifier'), is mandatory, type is 'text', - refers_to A3C::Model::StrixSite by 'site'; + refers_to A3C::Model::StrixInstance by 'instance'; column by_user => label is ('Selected by user'), @@ -26,15 +26,22 @@ sub since { '0.0.4' }; -sub validate_strix { +sub validate_instance { my $self = shift; - my $site = shift; + my $instance = shift; - my $strix = A3C::Model::StrixSiteSelection->new; - $strix->load_by_cols( strix => $site ); + my $strix = A3C::Model::StrixInstanceSelection->new; + $strix->load_by_cols( instance => $instance ); - return ( 0, _('Site %1 is allready selected', $site) ) if $strix->id; - return 1; + if ( $strix->id ) { + return ( 0, _('Instance %1 allready selected', $instance) ); + } else { + eval { + Strix->dbh( $instance ); + }; + return 1 unless $@; + return ( 0, $@ ); + } } sub current_user_can {