[Jifty-commit] r4093 - in apps/CASPlus: . trunk/lib/CASPlus

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Sep 11 18:49:44 EDT 2007


Author: sterling
Date: Tue Sep 11 18:49:41 2007
New Revision: 4093

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

Log:
 r11990 at dynpc145:  andrew | 2007-09-11 17:45:14 -0500
  r11980 at dynpc145:  andrew | 2007-09-11 17:44:23 -0500
   r11966 at dynpc145 (orig r1986):  andrew | 2007-09-11 17:31:52 -0500
    r11962 at dynpc145:  andrew | 2007-09-11 17:17:54 -0500
    Adding a dispatcher rule that auto-generates CRUD views for profile objects on demand.
   
  
 


Modified: apps/CASPlus/trunk/lib/CASPlus/Dispatcher.pm
==============================================================================
--- apps/CASPlus/trunk/lib/CASPlus/Dispatcher.pm	(original)
+++ apps/CASPlus/trunk/lib/CASPlus/Dispatcher.pm	Tue Sep 11 18:49:41 2007
@@ -52,16 +52,11 @@
         # Stop now if they ain't an admin
         return unless $current_user->may_administrate;
 
-        # Top-level items
-        my $profiles = 
-            $menu->child( Profiles => label => 'Profiles', side => 'left' );
-        my $users    =
-            $menu->child( Users    => label => 'Users',    side => 'left' );
-        my $sessions =
-            $menu->child( Sessions => label => 'Sessions', side => 'right' );
-
         # Profile menu items
         if ($current_user->may_manage_profiles) {
+            my $profiles = 
+                $menu->child( Profiles => label => 'Profiles', side => 'left' );
+
             $profiles->child( Profile => 
                 label       => _('Profile Definitions'), 
                 url         => '/admin/profile/definitions',
@@ -89,6 +84,12 @@
             );
         }
 
+        my $users;
+        if ($current_user->may_manage_users || $current_user->may_manage_roles) {
+            $users =
+                $menu->child( Users => label => 'Users', side => 'left' );
+        }
+
         # User menu
         if ($current_user->may_manage_users) {
             $users->child( User =>
@@ -106,6 +107,9 @@
         }
 
         # Sessions menu
+        my $sessions =
+            $menu->child( Sessions => label => 'Sessions', side => 'right' );
+
         $sessions->child( AccessLog =>
             label       => _('Access Log'),
             url         => '/admin/session/access',
@@ -122,6 +126,22 @@
             description => _('The status screen is a dashboard showing basic usage statistics and reports about the CAS server.'),
         );
 
+        if ($current_user->may_manage_profile_objects) {
+            my $objects =
+                $menu->child( Objects => label => 'Objects', side => 'right' );
+
+            my $profiles = CASPlus::Model::ProfileCollection->new;
+            $profiles->unlimit;
+
+            while (my $profile = $profiles->next) {
+                $objects->child( $profile->model_class->name,
+                    label => $profile->name,
+                    url   => '/admin/object/' . $profile->model_class->name,
+                    description => _($profile->description),
+                );
+            }
+        }
+
         # Add the Administer item to main navigation
         my $nav = Jifty->web->navigation;
         $nav->child( Administer =>
@@ -476,6 +496,37 @@
         unless Jifty->web->current_user->may_administrate;
 };
 
+=head2 /admin/object/*
+
+Makes sure the profile object view exists for the named page and then calls it.
+
+=cut
+
+on 'admin/object/*' => run {
+    my $name = $1;
+
+    # Load the associated profile
+    my $profile = CASPlus::Model::Profile->new;
+    $profile->load_by_cols( name => $1 );
+
+    # Stop now unless the profile exists
+    next_rule unless $profile->id;
+
+    # Only create the CRUD view if it doesn't exist yet
+    unless (Template::Declare->resolve_template('/admin/object/'.$name)) {
+        use Jifty::View::Declare::CRUD;
+
+        # Install a CRUD view for the profile object
+        alias Jifty::View::Declare::CRUD under '/admin/object/'.$name, {
+            object_type  => $name,
+            record_class => $profile->record_class,
+        };
+    }
+
+    # Show that CRUD view!
+    show '/admin/object/'.$name;
+};
+
 =head2 /error, /error/**
 
 Handle any direct hits to the unknown errors page.


More information about the Jifty-commit mailing list