[Jifty-commit] r3498 - in apps/CASPlus/trunk: lib/CASPlus/Model

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Jun 14 23:57:36 EDT 2007


Author: sterling
Date: Thu Jun 14 23:57:35 2007
New Revision: 3498

Modified:
   apps/CASPlus/trunk/   (props changed)
   apps/CASPlus/trunk/lib/CASPlus/Model/ProfileProperty.pm

Log:
 r7638 at riddle:  andrew | 2007-06-14 21:24:02 -0500
 Fixing up ProfileProperty so that it works from the Administration screens.


Modified: apps/CASPlus/trunk/lib/CASPlus/Model/ProfileProperty.pm
==============================================================================
--- apps/CASPlus/trunk/lib/CASPlus/Model/ProfileProperty.pm	(original)
+++ apps/CASPlus/trunk/lib/CASPlus/Model/ProfileProperty.pm	Thu Jun 14 23:57:35 2007
@@ -6,6 +6,9 @@
 
 use constant CLASS_UUID => 'FE2175BE-CCB1-11DB-B4B7-1C4A29635B38';
 
+use Carp;
+use Scalar::Util qw/ looks_like_number /;
+
 =head1 NAME
 
 CASPlus::Model::ProfileProperty - Properties for profiles
@@ -57,7 +60,6 @@
     column model_class_column =>
         refers_to Jifty::Model::ModelClassColumn,
         label is 'Model class column',
-        is mandatory,
         is distinct,
         is immutable;
 };
@@ -78,6 +80,18 @@
     my $self = shift;
     my $args = shift;
 
+    # Not a class, load the class from the given ID
+    if (looks_like_number($args->{profile})) {
+        my $profile = CASPlus::Model::Profile->new;
+        $profile->load($args->{profile});
+
+        if (!$profile->id) {
+            croak "Unknown profile ID $args->{profile} given.";
+        }
+
+        $args->{profile} = $profile;
+    }
+
     # Create a column_name out of "Column Name"
     my $name = CASPlus::Util->convert_to_identifier($args->{name});
 


More information about the Jifty-commit mailing list