[Rt-commit] r6136 - in commitbit: . trunk/lib/CommitBit/Model trunk/share/web/templates/project

jesse at bestpractical.com jesse at bestpractical.com
Sun Oct 1 16:15:02 EDT 2006


Author: jesse
Date: Sun Oct  1 16:15:01 2006
New Revision: 6136

Modified:
   commitbit/   (props changed)
   commitbit/trunk/lib/CommitBit/Dispatcher.pm
   commitbit/trunk/lib/CommitBit/Model/User.pm
   commitbit/trunk/share/web/templates/project/index.html

Log:
 r27988 at 120:  jesse | 2006-10-01 16:15:05 -0400
 * More sensical menu structure. Auth fixes for signup. ability for project admins to admin projects


Modified: commitbit/trunk/lib/CommitBit/Dispatcher.pm
==============================================================================
--- commitbit/trunk/lib/CommitBit/Dispatcher.pm	(original)
+++ commitbit/trunk/lib/CommitBit/Dispatcher.pm	Sun Oct  1 16:15:01 2006
@@ -10,15 +10,45 @@
     )->run;
 };
 before '*' => run {
-    if (Jifty->web->current_user->id) {
-        Jifty->web->navigation->child( prefs=>label=>_( 'Preferences'), url => '/prefs', sort_order => 998);
-        Jifty->web->navigation->child( logout=>label=>_( 'Logout'), url => '/logout', sort_order => 999);
+        Jifty->web->navigation->child(
+                 Home => # override the jifty default. ew
+
+                label => _('Home'),
+            url        => '/',
+            sort_order => 1);
+
+
+    if ( Jifty->web->current_user->id ) {
+        Jifty->web->navigation->child(
+            prefs     =>
+                label => _('Preferences'),
+            url        => '/prefs',
+            sort_order => 998
+        );
+        Jifty->web->navigation->child(
+            logout    =>
+                label => _('Logout'),
+            url        => '/logout',
+            sort_order => 999
+        );
     } else {
-        Jifty->web->navigation->child(login=>label=>_( 'Login'), url => '/login', sort_order => 999);
+        Jifty->web->navigation->child(
+            login     =>
+                label => _('Login'),
+            url        => '/login',
+            sort_order => 999
+        );
+    }
+
+    if (    Jifty->web->current_user->user_object
+        and Jifty->web->current_user->user_object->admin )
+    {
+        Jifty->web->navigation->child(
+            admin     =>
+                label => _('Admin'),
+            url => '/admin'
+        );
     }
-    if (Jifty->web->current_user->user_object and Jifty->web->current_user->user_object->admin) {
-        Jifty->web->navigation->child(admin=>label=>_( 'Admin'), url => '/admin');
-   }
 
 };
 
@@ -89,15 +119,23 @@
 
 
 before qr'^/admin' => run {
-    my $admin =   Jifty->web->navigation->child('admin');
-     $admin->child( 'repos' => label => 'Repositories', url => '/admin/repositories');
+    my $admin =   Jifty->web->navigation->child('admin') || Jifty->web->navigation->child( admin => label => _('Admin'), url => '/admin');
+    if (Jifty->web->current_user->user_object->admin ) {
+        $admin->child( 'repos' => label => 'Repositories', url => '/admin/repositories');
+    }
      $admin->child( 'proj' => label => 'Projects', url => '/admin/projects');
 
 
 };
 
+before qr'^/admin/repository' => run {
+    unless  (Jifty->web->current_user->user_object->admin ) {
+        redirect '/__jifty/error/permission_denied/not_admin'; 
+    }
+
+};
+
 before qr'^/admin/project/([^/]+)(/.*|)$' => run  {
-    warn "Setting nav";
     my $admin =   Jifty->web->navigation->child('admin')->child('proj');
     my $proj = $admin->child( $1 => label => $1, url => '/admin/project/'.$1.'/index.html');
     $proj->child( base => label => _('Overview'), url => '/admin/project/'.$1.'/index.html'); 
@@ -131,6 +169,11 @@
     my $path    = $3;
     warn "Got to $1 $2 $3";
 
+
+    unless (lc($prefix) eq 'admin') {
+        Jifty->web->navigation->child(admin => label => _('Admin project'), url =>  '/admin/project/'.$name, order => 5);
+    }
+
     $name = URI::Escape::uri_unescape($name);
     my $project = CommitBit::Model::Project->new();
     $project->load_by_cols( name => $name );
@@ -138,11 +181,16 @@
         redirect '/__jifty/error/project/not_found';
     }
 
+    if (lc($prefix) eq 'admin') {
+    unless  ($project->is_project_admin(Jifty->web->current_user)
+             or Jifty->web->current_user->user_object->admin) {
+        redirect '/__jifty/error/permission_denied/not_admin'; 
+    }
+    }
+
     set project => $project;
     my $url = $prefix . ($path ? '/project/' . $path : '/project/index.html' );
 
-#    Jifty->web->navigation->child( $project->name => label => $project->name, url => $ENV{'REQUEST_URI'});
-
     show $url;
 };
 

Modified: commitbit/trunk/lib/CommitBit/Model/User.pm
==============================================================================
--- commitbit/trunk/lib/CommitBit/Model/User.pm	(original)
+++ commitbit/trunk/lib/CommitBit/Model/User.pm	Sun Oct  1 16:15:01 2006
@@ -10,8 +10,8 @@
     column 'email' => type is 'text', is 'distinct', is 'immutable', is 'mandatory';
     column 'password' => type is 'text', render_as 'password';
     column 'created' => type is 'timestamp', is immutable;
-    column admin => type is 'boolean', default is 'false';
-    column email_confirmed => type is 'boolean', default is 'false';
+    column admin => type is 'boolean', default is '0';
+    column email_confirmed => type is 'boolean', default is '0';
 
 };
 
@@ -66,7 +66,7 @@
         return 1;
     }
 
-    if ($right eq 'update' and ($self->current_user->user_object == $self->id)) {
+    if ($right eq 'update' and ($self->current_user->user_object->id == $self->id)) {
         if ($args{'column'} =~ /^(?:nickname|password)$/) {
             return 1;
         }

Modified: commitbit/trunk/share/web/templates/project/index.html
==============================================================================
--- commitbit/trunk/share/web/templates/project/index.html	(original)
+++ commitbit/trunk/share/web/templates/project/index.html	Sun Oct  1 16:15:01 2006
@@ -66,6 +66,11 @@
 % }
 </ul>
 %}
+% if (Jifty->web->current_user->user_object) {
+% if ($project->is_project_admin(Jifty->web->current_user) || Jifty->web->current_user->user_object->admin) { 
+<% Jifty->web->link( label => _('Invite someone'), url => '/admin/project/'.$project->name.'/people')%>
+% }
+% }
 </div>
 </div>
 </div>


More information about the Rt-commit mailing list